Skip to content

Commit 29b9a24

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 10b59d2 commit 29b9a24

30 files changed

+851
-418
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: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ function DataTableStats({ data, columns, error, loading }: TableData) {
6262
};
6363

6464
return (
65-
<div
66-
className=""
67-
>
65+
<div className="">
6866
<div className="flex items-center justify-between pb-6 " />
6967
<div style={{ overflowX: 'auto' }}>
7068
<table className="min-w-full leading-normal" {...getTableProps()}>
@@ -177,5 +175,4 @@ function DataTableStats({ data, columns, error, loading }: TableData) {
177175
);
178176
}
179177

180-
181178
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) {

src/components/tests/__snapshots__/AdminTraineeDashboard.test.tsx.snap

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Array [
6060
className="flex justify-between w-full"
6161
>
6262
<button
63-
className="btn info sm w-[30%] md:w-1/4 text-sm font-sans font-serif"
63+
className="btn info sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
6464
data-testid="removeInviteModel"
6565
disabled={false}
6666
onClick={[Function]}
@@ -69,7 +69,7 @@ Array [
6969
Cancel
7070
</button>
7171
<button
72-
className="btn primary sm w-[30%] md:w-1/4 text-sm font-sans font-serif"
72+
className="btn primary sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
7373
disabled={false}
7474
onClick={[Function]}
7575
type="button"
@@ -326,7 +326,7 @@ Array [
326326
className="flex justify-between w-full"
327327
>
328328
<button
329-
className="btn info sm w-[30%] md:w-1/4 text-sm font-sans font-serif"
329+
className="btn info sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
330330
data-testid="removeModel1"
331331
disabled={false}
332332
onClick={[Function]}
@@ -335,7 +335,7 @@ Array [
335335
Cancel
336336
</button>
337337
<button
338-
className="btn primary sm w-[30%] md:w-1/4 text-sm font-sans font-serif"
338+
className="btn primary sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
339339
disabled={false}
340340
onClick={[Function]}
341341
type="button"
@@ -384,7 +384,7 @@ Array [
384384
className="flex justify-between w-full"
385385
>
386386
<button
387-
className="btn info sm w-[30%] md:w-1/4 text-sm font-sans font-serif"
387+
className="btn info sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
388388
data-testid="removeModel2"
389389
disabled={false}
390390
onClick={[Function]}
@@ -393,7 +393,7 @@ Array [
393393
Cancel
394394
</button>
395395
<button
396-
className="btn primary sm w-[30%] md:w-1/4 text-sm font-sans font-serif"
396+
className="btn primary sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
397397
data-testid="removeMemberFromCohort"
398398
disabled={false}
399399
onClick={[Function]}
@@ -463,14 +463,14 @@ Array [
463463
name="date"
464464
readOnly={true}
465465
type="text"
466-
value="2024-09-13"
466+
value="2024-09-26"
467467
/>
468468
</div>
469469
<div
470470
className="flex justify-between w-full"
471471
>
472472
<button
473-
className="btn info sm w-[30%] md:w-1/4 text-sm font-sans font-serif"
473+
className="btn info sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
474474
data-testid="dropModel"
475475
disabled={false}
476476
onClick={[Function]}
@@ -479,7 +479,7 @@ Array [
479479
Cancel
480480
</button>
481481
<button
482-
className="btn primary sm w-[30%] md:w-1/4 text-sm font-sans font-serif"
482+
className="btn primary sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
483483
data-testid="dropMemberFromCohort"
484484
disabled={false}
485485
onClick={[Function]}
@@ -493,16 +493,16 @@ Array [
493493
</div>
494494
</div>,
495495
<div
496-
className="h-screen w-screen z-20 bg-black bg-opacity-30 backdrop-blur-sm fixed top-0 left-0 flex items-center justify-center px-4 hidden"
496+
className="h-screen w-screen z-20 bg-black bg-opacity-30 backdrop-blur-sm fixed top-0 left-0 flex items-center justify-center px-4 hidden"
497497
>
498498
<div
499499
className="w-full p-4 pb-8 bg-indigo-100 rounded-lg dark:bg-dark-bg sm:w-3/4 xl:w-4/12"
500500
>
501501
<div
502-
className="flex flex-wrap items-center justify-center w-full card-title "
502+
className="flex flex-wrap items-center justify-center w-full card-title"
503503
>
504504
<h3
505-
className="w-11/12 text-sm font-bold text-center dark:text-white "
505+
className="w-11/12 text-sm font-bold text-center dark:text-white"
506506
>
507507
Add Trainee
508508
</h3>
@@ -514,10 +514,10 @@ Array [
514514
className="card-body"
515515
>
516516
<form
517-
className="px-8 py-3 "
517+
className="px-8 py-3"
518518
>
519519
<div
520-
className="my-3 input h-9 "
520+
className="my-3 input h-9"
521521
>
522522
<div
523523
className="flex items-center w-full h-full rounded-md grouped-input"
@@ -625,7 +625,7 @@ Array [
625625
</div>
626626
</div>
627627
<div
628-
className="my-3 text-white input h-9 "
628+
className="my-3 text-white input h-9"
629629
>
630630
<div
631631
className="flex items-center w-full h-full text-white rounded-md grouped-input"
@@ -733,7 +733,7 @@ Array [
733733
</div>
734734
</div>
735735
<div
736-
className="my-3 text-white input h-9 "
736+
className="my-3 text-white input h-9"
737737
>
738738
<div
739739
className="flex items-center w-full h-full text-white rounded-md grouped-input"
@@ -844,7 +844,7 @@ Array [
844844
className="flex justify-between w-full"
845845
>
846846
<button
847-
className="btn info sm w-[30%] md:w-1/4 text-sm font-sans font-serif"
847+
className="btn info sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
848848
data-testid="removeModel"
849849
disabled={false}
850850
onClick={[Function]}
@@ -853,7 +853,7 @@ Array [
853853
Cancel
854854
</button>
855855
<button
856-
className="btn primary sm w-[30%] md:w-1/4 text-sm font-sans font-serif"
856+
className="btn primary sm w-[30%] md:w-1/4 text-sm font-sans font-serif "
857857
data-testid="saveButton"
858858
disabled={false}
859859
onClick={[Function]}
@@ -886,7 +886,7 @@ Array [
886886
className="flex gap-2"
887887
>
888888
<button
889-
className="btn primary lg m-0 font-serif"
889+
className="btn primary lg m-0 font-serif "
890890
data-testid="registerModel"
891891
disabled={false}
892892
onClick={[Function]}
@@ -897,7 +897,7 @@ Array [
897897
898898
</button>
899899
<button
900-
className="btn primary lg m-0 font-serif"
900+
className="btn primary lg m-0 font-serif "
901901
data-testid="inviteModel"
902902
disabled={false}
903903
onClick={[Function]}

0 commit comments

Comments
 (0)