Skip to content

Commit 3f97c26

Browse files
shebz2023niyobertin
authored andcommitted
fx-rating-error (#492)
this commit refines the functions of validating this commit utilizes zod library for validating ttl rating trainees (#494) Fetch invitation statistics (#463)
1 parent f0d1c91 commit 3f97c26

File tree

6 files changed

+536
-193
lines changed

6 files changed

+536
-193
lines changed

src/Mutations/invitationMutation.tsx

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
import { gql } from '@apollo/client';
22

33
export const SEND_INVITATION = gql`
4-
mutation SendInvitation($invitees: [InviteeInput!]!, $orgToken: String!) {
5-
sendInvitation(invitees: $invitees, orgToken: $orgToken) {
4+
mutation SendInvitation($invitees: [InviteeInput!]!,$orgName:String!,$orgToken: String!) {
5+
sendInvitation(invitees: $invitees,orgName:$orgName, orgToken: $orgToken) {
66
status
77
invitees {
88
email
99
role
1010
}
11+
orgName
1112
orgToken
1213
createdAt
1314
}
1415
}
1516
`;
1617

1718
export const UPLOAD_INVITATION_FILE = gql`
18-
mutation uploadInvitationFile($file: Upload!, $orgToken: String!) {
19-
uploadInvitationFile(file: $file, orgToken: $orgToken) {
19+
mutation uploadInvitationFile($file: Upload!,$orgName:String!, $orgToken: String!) {
20+
uploadInvitationFile(file: $file,orgName:$orgName,orgToken: $orgToken) {
2021
filename
2122
data {
2223
email
@@ -36,3 +37,35 @@ export const DELETE_INVITATION = gql`
3637
}
3738
}
3839
`;
40+
41+
export const UPDATE_INVITATION = gql`
42+
mutation UpdateInvitation(
43+
$invitationId: ID!
44+
$orgToken: String!
45+
$newEmail: String
46+
$newRole: String
47+
) {
48+
updateInvitation(
49+
invitationId: $invitationId
50+
orgToken: $orgToken
51+
newEmail: $newEmail
52+
newRole: $newRole
53+
) {
54+
id
55+
invitees {
56+
email
57+
role
58+
}
59+
inviterId
60+
orgToken
61+
}
62+
}
63+
`;
64+
export const CANCEL_INVITATION = gql`
65+
mutation CancelInvitation($id: ID!, $orgToken: String!) {
66+
cancelInvitation(id: $id, orgToken: $orgToken) {
67+
status
68+
createdAt
69+
}
70+
}
71+
`;

src/Mutations/invitationStats.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ export const GET_INVITATIONS_STATISTICS_QUERY = gql`
1515
) {
1616
totalInvitations
1717
pendingInvitationsCount
18+
cancelledInvitationsCount
1819
getPendingInvitationsPercentsCount
1920
getAcceptedInvitationsPercentsCount
21+
getCancelledInvitationsPercentsCount
2022
acceptedInvitationsCount
2123
}
2224
}
23-
`;
25+
`;

src/components/InvitationTable.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,8 @@ function DataTableStats({ data, columns, error, loading }: TableData) {
6262
};
6363

6464
return (
65-
<div
66-
className={``}
67-
>
68-
<div className="flex items-center justify-between pb-6 ">
69-
</div>
65+
<div className="">
66+
<div className="flex items-center justify-between pb-6 " />
7067
<div style={{ overflowX: 'auto' }}>
7168
<table className="min-w-full leading-normal" {...getTableProps()}>
7269
<thead>
@@ -178,5 +175,4 @@ function DataTableStats({ data, columns, error, loading }: TableData) {
178175
);
179176
}
180177

181-
182178
export default DataTableStats;

src/components/invitationModal.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ function InviteForm({ onClose }: InviteFormProps) {
2727
const [email, setEmail] = useState<string>('');
2828
const [role, setRole] = useState<string>('Role');
2929
const [orgToken, setOrgToken] = useState<string>('');
30+
const [orgName,setOrgName] = useState<string>('');
3031
const [isDropdownOpen, setIsDropdownOpen] = useState<boolean>(false);
3132
const [emailError, setEmailError] = useState<string>('');
3233
const [sendInvitation, { loading, error }] = useMutation(SEND_INVITATION);
@@ -37,6 +38,7 @@ function InviteForm({ onClose }: InviteFormProps) {
3738
);
3839

3940
const organisationToken = localStorage.getItem('orgToken');
41+
const organisationName = localStorage.getItem('orgName');
4042

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

5456
try {
55-
const { data } = await uploadFile({ variables: { file, orgToken } });
57+
const { data } = await uploadFile({ variables: { file,orgName,orgToken } });
5658
if (data && data.uploadInvitationFile) {
5759
const { message, sentEmails } = data.uploadInvitationFile;
5860
if (sentEmails === 0) {
@@ -79,7 +81,10 @@ function InviteForm({ onClose }: InviteFormProps) {
7981
if (organisationToken) {
8082
setOrgToken(organisationToken);
8183
}
82-
}, [organisationToken]);
84+
if(organisationName){
85+
setOrgName(organisationName)
86+
}
87+
}, [organisationToken,organisationName]);
8388

8489
const handleSubmit = async (e: React.FormEvent) => {
8590
e.preventDefault();
@@ -95,12 +100,14 @@ function InviteForm({ onClose }: InviteFormProps) {
95100
await sendInvitation({
96101
variables: {
97102
invitees: [{ email, role }],
103+
orgName,
98104
orgToken,
99105
},
100106
});
101107
toast.success('Invitation sent successfully!');
102108
setEmail('');
103109
setRole('Role');
110+
setOrgName('');
104111
setOrgToken('');
105112
onClose();
106113
} catch (e: any) {

0 commit comments

Comments
 (0)