Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 37 additions & 4 deletions src/Mutations/invitationMutation.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import { gql } from '@apollo/client';

export const SEND_INVITATION = gql`
mutation SendInvitation($invitees: [InviteeInput!]!, $orgToken: String!) {
sendInvitation(invitees: $invitees, orgToken: $orgToken) {
mutation SendInvitation($invitees: [InviteeInput!]!,$orgName:String!,$orgToken: String!) {
sendInvitation(invitees: $invitees,orgName:$orgName, orgToken: $orgToken) {
status
invitees {
email
role
}
orgName
orgToken
createdAt
}
}
`;

export const UPLOAD_INVITATION_FILE = gql`
mutation uploadInvitationFile($file: Upload!, $orgToken: String!) {
uploadInvitationFile(file: $file, orgToken: $orgToken) {
mutation uploadInvitationFile($file: Upload!,$orgName:String!, $orgToken: String!) {
uploadInvitationFile(file: $file,orgName:$orgName,orgToken: $orgToken) {
filename
data {
email
Expand All @@ -36,3 +37,35 @@ export const DELETE_INVITATION = gql`
}
}
`;

export const UPDATE_INVITATION = gql`
mutation UpdateInvitation(
$invitationId: ID!
$orgToken: String!
$newEmail: String
$newRole: String
) {
updateInvitation(
invitationId: $invitationId
orgToken: $orgToken
newEmail: $newEmail
newRole: $newRole
) {
id
invitees {
email
role
}
inviterId
orgToken
}
}
`;
export const CANCEL_INVITATION = gql`
mutation CancelInvitation($id: ID!, $orgToken: String!) {
cancelInvitation(id: $id, orgToken: $orgToken) {
status
createdAt
}
}
`;
4 changes: 3 additions & 1 deletion src/Mutations/invitationStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ export const GET_INVITATIONS_STATISTICS_QUERY = gql`
) {
totalInvitations
pendingInvitationsCount
cancelledInvitationsCount
getPendingInvitationsPercentsCount
getAcceptedInvitationsPercentsCount
getCancelledInvitationsPercentsCount
acceptedInvitationsCount
}
}
`;
`;
5 changes: 1 addition & 4 deletions src/components/InvitationTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ function DataTableStats({ data, columns, error, loading }: TableData) {
};

return (
<div
className=""
>
<div className="">
<div className="flex items-center justify-between pb-6 " />
<div style={{ overflowX: 'auto' }}>
<table className="min-w-full leading-normal" {...getTableProps()}>
Expand Down Expand Up @@ -177,5 +175,4 @@ function DataTableStats({ data, columns, error, loading }: TableData) {
);
}


export default DataTableStats;
11 changes: 9 additions & 2 deletions src/components/invitationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function InviteForm({ onClose }: InviteFormProps) {
const [email, setEmail] = useState<string>('');
const [role, setRole] = useState<string>('Role');
const [orgToken, setOrgToken] = useState<string>('');
const [orgName,setOrgName] = useState<string>('');
const [isDropdownOpen, setIsDropdownOpen] = useState<boolean>(false);
const [emailError, setEmailError] = useState<string>('');
const [sendInvitation, { loading, error }] = useMutation(SEND_INVITATION);
Expand All @@ -37,6 +38,7 @@ function InviteForm({ onClose }: InviteFormProps) {
);

const organisationToken = localStorage.getItem('orgToken');
const organisationName = localStorage.getItem('orgName');

const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const selectedFile = e.target.files?.[0] || null;
Expand All @@ -52,7 +54,7 @@ function InviteForm({ onClose }: InviteFormProps) {
}

try {
const { data } = await uploadFile({ variables: { file, orgToken } });
const { data } = await uploadFile({ variables: { file,orgName,orgToken } });
if (data && data.uploadInvitationFile) {
const { message, sentEmails } = data.uploadInvitationFile;
if (sentEmails === 0) {
Expand All @@ -79,7 +81,10 @@ function InviteForm({ onClose }: InviteFormProps) {
if (organisationToken) {
setOrgToken(organisationToken);
}
}, [organisationToken]);
if(organisationName){
setOrgName(organisationName)
}
}, [organisationToken,organisationName]);

const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
Expand All @@ -95,12 +100,14 @@ function InviteForm({ onClose }: InviteFormProps) {
await sendInvitation({
variables: {
invitees: [{ email, role }],
orgName,
orgToken,
},
});
toast.success('Invitation sent successfully!');
setEmail('');
setRole('Role');
setOrgName('');
setOrgToken('');
onClose();
} catch (e: any) {
Expand Down
Loading
Loading