-
Notifications
You must be signed in to change notification settings - Fork 0
New SigView page #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
New SigView page #124
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,204 @@ | ||
| import { | ||
| Title, | ||
| Box, | ||
| TextInput, | ||
| Textarea, | ||
| Switch, | ||
| Select, | ||
| Button, | ||
| Loader, | ||
| Container, | ||
| Transition, | ||
| useMantineColorScheme, | ||
| Table, | ||
| Group, | ||
| Stack, | ||
| } from '@mantine/core'; | ||
| import { DateTimePicker } from '@mantine/dates'; | ||
| import { useForm, zodResolver } from '@mantine/form'; | ||
| import { notifications } from '@mantine/notifications'; | ||
| import dayjs from 'dayjs'; | ||
| import React, { useEffect, useState } from 'react'; | ||
| import { useNavigate, useParams } from 'react-router-dom'; | ||
| import { z } from 'zod'; | ||
| import { AuthGuard } from '@ui/components/AuthGuard'; | ||
| import { getRunEnvironmentConfig } from '@ui/config'; | ||
| import { useApi } from '@ui/util/api'; | ||
| import { AppRoles } from '@common/roles'; | ||
|
|
||
| const baseSigSchema = z.object({ | ||
| sigid: z.string().min(1), | ||
| signame: z.string().min(1), | ||
| description: z.string().optional(), | ||
| }); | ||
|
|
||
| const baseSigMemberSchema = z.object({ | ||
| sigGroupId: z.string().min(1), | ||
| email: z.string().email('Invalid email'), | ||
| designation: z.enum(['L', 'M']), | ||
| id: z.string().optional(), | ||
| memberName: z.string(), | ||
| }); | ||
|
|
||
| type sigDetails = z.infer<typeof baseSigSchema>; | ||
| type sigMemberDetails = z.infer<typeof baseSigMemberSchema>; | ||
|
|
||
| export const ViewSigLeadPage: React.FC = () => { | ||
| const [isSubmitting, setIsSubmitting] = useState<boolean>(false); | ||
| const navigate = useNavigate(); | ||
| const api = useApi('core'); | ||
| const { colorScheme } = useMantineColorScheme(); | ||
| const { sigId } = useParams(); | ||
| const [sigMembers, setSigMembers] = useState<sigMemberDetails[]>([ | ||
| { | ||
| sigGroupId: sigId || '', | ||
| email: '[email protected]', | ||
| designation: 'L', | ||
| memberName: 'Alice', | ||
| }, | ||
| { | ||
| sigGroupId: sigId || '', | ||
| email: '[email protected]', | ||
| designation: 'M', | ||
| memberName: 'Bob', | ||
| }, | ||
| ]); | ||
| const [sigDetails, setSigDetails] = useState<sigDetails>({ | ||
| sigid: sigId || '', | ||
| signame: 'Default Sig', | ||
| description: | ||
| 'A cool Sig with a lot of money and members. Founded in 1999 by Sir Charlie of Edinburgh. Focuses on making money and helping others earn more money via education.', | ||
| }); | ||
|
|
||
| useEffect(() => { | ||
| // Fetch sig data and populate form / for now dummy data... | ||
| const getSig = async () => { | ||
| try { | ||
| /*const formValues = { | ||
| }; | ||
| form.setValues(formValues);*/ | ||
| } catch (error) { | ||
| console.error('Error fetching sig data:', error); | ||
| notifications.show({ | ||
| message: 'Failed to fetch sig data, please try again.', | ||
| }); | ||
| } | ||
| }; | ||
| getSig(); | ||
| }, [sigId]); | ||
|
|
||
| const renderSigMember = (members: sigMemberDetails, index: number) => { | ||
| const shouldShow = true; | ||
| return ( | ||
| <Transition mounted={shouldShow} transition="fade" duration={10000} timingFunction="ease"> | ||
| {(styles) => ( | ||
| <tr | ||
| style={{ | ||
| ...styles, | ||
| display: shouldShow ? 'table-row' : 'none', | ||
| backgroundColor: | ||
| colorScheme === 'dark' | ||
| ? index % 2 === 0 | ||
| ? '#333333' | ||
| : '#444444' | ||
| : index % 2 === 0 | ||
| ? '#f0f8ff' | ||
| : '#ffffff', | ||
| }} | ||
| > | ||
| <Table.Td>{members.memberName}</Table.Td> | ||
| <Table.Td>{members.email}</Table.Td> | ||
| <Table.Td>{members.designation}</Table.Td> | ||
| </tr> | ||
| )} | ||
| </Transition> | ||
| ); | ||
| }; | ||
|
|
||
| /* | ||
| const form = useForm<EventPostRequest>({ | ||
| validate: zodResolver(requestBodySchema), | ||
| initialValues: { | ||
| title: '', | ||
| description: '', | ||
| start: new Date(), | ||
| end: new Date(new Date().valueOf() + 3.6e6), // 1 hr later | ||
| location: 'ACM Room (Siebel CS 1104)', | ||
| locationLink: 'https://maps.app.goo.gl/dwbBBBkfjkgj8gvA8', | ||
| host: 'ACM', | ||
| featured: false, | ||
| repeats: undefined, | ||
| repeatEnds: undefined, | ||
| paidEventId: undefined, | ||
| }, | ||
| }); | ||
| /* | ||
| const handleSubmit = async (values: EventPostRequest) => { | ||
| try { | ||
| setIsSubmitting(true); | ||
| const realValues = { | ||
| ...values, | ||
| start: dayjs(values.start).format('YYYY-MM-DD[T]HH:mm:00'), | ||
| end: values.end ? dayjs(values.end).format('YYYY-MM-DD[T]HH:mm:00') : undefined, | ||
| repeatEnds: | ||
| values.repeatEnds && values.repeats | ||
| ? dayjs(values.repeatEnds).format('YYYY-MM-DD[T]HH:mm:00') | ||
| : undefined, | ||
| repeats: values.repeats ? values.repeats : undefined, | ||
| }; | ||
|
|
||
| const eventURL = isEditing ? `/api/v1/events/${eventId}` : '/api/v1/events'; | ||
| const response = await api.post(eventURL, realValues); | ||
| notifications.show({ | ||
| title: isEditing ? 'Event updated!' : 'Event created!', | ||
| message: isEditing ? undefined : `The event ID is "${response.data.id}".`, | ||
| }); | ||
| navigate('/events/manage'); | ||
| } catch (error) { | ||
| setIsSubmitting(false); | ||
| console.error('Error creating/editing event:', error); | ||
| notifications.show({ | ||
| message: 'Failed to create/edit event, please try again.', | ||
| }); | ||
| } | ||
| };*/ | ||
|
|
||
| return ( | ||
| <AuthGuard resourceDef={{ service: 'core', validRoles: [AppRoles.IAM_ADMIN] }}> | ||
| <Container> | ||
| <Group align="flex-start"> | ||
| <Box style={{ flex: 8 }}> | ||
| <Title order={1}>{sigDetails.sigid}</Title> | ||
| {sigDetails.description || ''} | ||
| </Box> | ||
| <Box style={{ flex: 1, textAlign: 'right', alignItems: 'right' }}> | ||
| <Stack> | ||
| <Button variant="white">Member Count: {sigMembers.length}</Button> | ||
|
|
||
| <Button>Add Member</Button> | ||
| <Button | ||
| onClick={() => navigate('../siglead-management')} | ||
| variant="outline" | ||
| color="gray" | ||
| > | ||
| Back | ||
| </Button> | ||
| </Stack> | ||
| </Box> | ||
| </Group> | ||
| <div style={{ width: '100%', overflowX: 'auto' }}> | ||
| <Table style={{ tableLayout: 'fixed', width: '100%' }}> | ||
| <Table.Thead> | ||
| <Table.Tr> | ||
| <Table.Th>Name</Table.Th> | ||
| <Table.Th>Email</Table.Th> | ||
| <Table.Th>Roles</Table.Th> | ||
| </Table.Tr> | ||
| </Table.Thead> | ||
| <Table.Tbody>{sigMembers.map(renderSigMember)}</Table.Tbody> | ||
| </Table> | ||
| </div> | ||
| </Container> | ||
| </AuthGuard> | ||
| ); | ||
| }; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace with "AppRoles.SIGLEAD_MANAGER"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good Work. Rest seems fine.