forked from PalisadoesFoundation/talawa-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9df0aa
commit 0fd8403
Showing
12 changed files
with
263 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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,43 @@ | ||
.loader, | ||
.loader:after { | ||
border-radius: 50%; | ||
width: 10em; | ||
height: 10em; | ||
} | ||
.loader { | ||
margin: 60px auto; | ||
margin-top: 35vh !important; | ||
font-size: 10px; | ||
position: relative; | ||
text-indent: -9999em; | ||
border-top: 1.1em solid rgba(255, 255, 255, 0.2); | ||
border-right: 1.1em solid rgba(255, 255, 255, 0.2); | ||
border-bottom: 1.1em solid rgba(255, 255, 255, 0.2); | ||
border-left: 1.1em solid #febc59; | ||
-webkit-transform: translateZ(0); | ||
-ms-transform: translateZ(0); | ||
transform: translateZ(0); | ||
-webkit-animation: load8 1.1s infinite linear; | ||
animation: load8 1.1s infinite linear; | ||
} | ||
|
||
@-webkit-keyframes load8 { | ||
0% { | ||
-webkit-transform: rotate(0deg); | ||
transform: rotate(0deg); | ||
} | ||
100% { | ||
-webkit-transform: rotate(360deg); | ||
transform: rotate(360deg); | ||
} | ||
} | ||
@keyframes load8 { | ||
0% { | ||
-webkit-transform: rotate(0deg); | ||
transform: rotate(0deg); | ||
} | ||
100% { | ||
-webkit-transform: rotate(360deg); | ||
transform: rotate(360deg); | ||
} | ||
} |
This file contains 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,131 @@ | ||
import React, {useState} from "react"; | ||
import { Modal, Button } from "react-bootstrap"; | ||
import { toast } from "react-toastify"; | ||
import { useMutation, useQuery } from "@apollo/client"; | ||
import { INVITE_USER } from "GraphQl/Mutations/EventAttendeeMutations"; | ||
import styles from './InviteUserModal.module.css' | ||
import Avatar from '@mui/material/Avatar'; | ||
import Chip from '@mui/material/Chip'; | ||
import Stack from '@mui/material/Stack'; | ||
import TextField from '@mui/material/TextField'; | ||
import Autocomplete from '@mui/material/Autocomplete'; | ||
import { GET_EVENT_ATTENDEE, MEMBERS_LIST } from "GraphQl/Queries/Queries"; | ||
|
||
type ModalPropType = { | ||
show: boolean; | ||
eventId: string; | ||
orgId: string; | ||
handleClose: () => void; | ||
}; | ||
|
||
interface InterfaceUser { | ||
_id: string; | ||
firstName: string; | ||
lastName: string; | ||
} | ||
|
||
export const InviteUserModal = (props: ModalPropType): JSX.Element => { | ||
const [member, setMember] = useState<InterfaceUser | null>(null); | ||
|
||
const [inviteUsersMutation] = useMutation(INVITE_USER); | ||
|
||
const { | ||
data: invitedUserData, | ||
loading: invitedUserLoading, | ||
refetch: invitedUsersRefectch, | ||
} = useQuery(GET_EVENT_ATTENDEE, { | ||
variables: { id: props.eventId }, | ||
}); | ||
|
||
const { data: memberData, loading: memberLoading } = useQuery(MEMBERS_LIST, { | ||
variables: { id: props.orgId }, | ||
}); | ||
|
||
const InviteEventAttendee = (): void => { | ||
if(member === null) { | ||
toast.warning(`Please choose an user to Invite first!`); | ||
return; | ||
} | ||
toast.warn(`Inviting the attendee...`); | ||
inviteUsersMutation({ | ||
variables: { | ||
userId: member._id, | ||
eventId: props.eventId, | ||
}, | ||
}) | ||
.then(() => { | ||
toast.success(`Invited the Attendee successfully!`); | ||
invitedUsersRefectch(); | ||
}) | ||
.catch((err) => { | ||
toast.error('There was an error in adding the attendee!'); | ||
toast.error(err.message); | ||
}); | ||
}; | ||
|
||
// Render the loading screen | ||
if (invitedUserLoading || memberLoading) { | ||
return ( | ||
<> | ||
<div className={styles.loader}></div> | ||
</> | ||
); | ||
} | ||
|
||
return ( | ||
<> | ||
<Modal | ||
show={props.show} | ||
onHide={props.handleClose} | ||
backdrop="static" | ||
centered | ||
> | ||
<Modal.Header closeButton className="bg-primary"> | ||
<Modal.Title className="text-white">Invite Event Attendee</Modal.Title> | ||
</Modal.Header> | ||
<Modal.Body> | ||
<h5 className="mb-2">Registered Registrants</h5> | ||
{invitedUserData.event.attendee.length == 0 | ||
? `There are no registered attendee for this event.` | ||
: null} | ||
<Stack direction="row" className="flex-wrap gap-2"> | ||
{invitedUserData.event.attendee.map((invitedAttendee: InterfaceUser) => { | ||
<Chip | ||
avatar={ | ||
<Avatar>{`${invitedAttendee.firstName[0]} ${invitedAttendee.lastName[0]}`}</Avatar> | ||
} | ||
label={`${invitedAttendee.firstName} ${invitedAttendee.lastName}`} | ||
variant="outlined" | ||
key={invitedAttendee._id} | ||
/> | ||
})} | ||
</Stack> | ||
<br/> | ||
<Autocomplete | ||
id="inviteAttendee" | ||
onChange={(_, member): void => { | ||
setMember(member); | ||
}} | ||
options={memberData.organizations[0].members} | ||
getOptionLabel={(member: InterfaceUser): string => | ||
`${member.firstName} ${member.lastName}` | ||
} | ||
renderInput={(params): React.ReactNode => ( | ||
<TextField | ||
{...params} | ||
label="Add an Registrant" | ||
placeholder="Choose the user that you want to add" | ||
/> | ||
)} | ||
/> | ||
<br/> | ||
</Modal.Body> | ||
<Modal.Footer> | ||
<Button variant="success" onClick={InviteEventAttendee}> | ||
Invite Attendee | ||
</Button> | ||
</Modal.Footer> | ||
</Modal> | ||
</> | ||
) | ||
} |
This file contains 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,14 @@ | ||
button .iconWrapper { | ||
width: 32px; | ||
padding-right: 4px; | ||
margin-right: 4px; | ||
transform: translateY(4px); | ||
} | ||
|
||
button .iconWrapperSm { | ||
width: 32px; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
Oops, something went wrong.