Skip to content

Commit 73792fb

Browse files
authored
resend Invitations that has a pending status and fix the font size on invite user button (#530)
1 parent 1423c1c commit 73792fb

File tree

2 files changed

+96
-2
lines changed

2 files changed

+96
-2
lines changed

src/Mutations/invitationMutation.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,13 @@ export const CANCEL_INVITATION = gql`
6969
}
7070
}
7171
`;
72+
73+
export const RESEND_INVITATION = gql`
74+
mutation ResendInvitation($invitationId: ID!, $orgToken: String!) {
75+
resendInvitation(invitationId: $invitationId, orgToken: $orgToken) {
76+
success
77+
message
78+
}
79+
}
80+
`;
81+

src/pages/invitation.tsx

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
CANCEL_INVITATION,
2020
DELETE_INVITATION,
2121
UPDATE_INVITATION,
22+
RESEND_INVITATION
2223
} from '../Mutations/invitationMutation';
2324
import Button from '../components/Buttons';
2425
import {
@@ -55,6 +56,7 @@ function Invitation() {
5556
startDate: '',
5657
endDate: '',
5758
});
59+
const [resendInvitationModel,setResendInvatationModel]= useState(false)
5860
const { t }: any = useTranslation();
5961
const removeInviteeMod = () => {
6062
const newState = !removeInviteeModel;
@@ -69,6 +71,7 @@ function Invitation() {
6971
const [selectedRow, setSelectedRow] = useState<string | null>(null);
7072
const [removeInviteeModel, setRemoveInviteeModel] = useState(false);
7173
const [deleteInvitation, setDeleteInvitation] = useState('');
74+
const[invitationToResend,setInvitationToResend]=useState('')
7275
const [updateInviteeModel, setUpdateInviteeModel] = useState(false);
7376
const [buttonLoading, setButtonLoading] = useState(false);
7477
const [selectedRole, setSelectedRole] = useState('');
@@ -438,7 +441,12 @@ function Invitation() {
438441

439442
{row.original.Status === 'Pending' && (
440443
<div className="mb-4">
441-
<div className="flex items-center p-2 rounded-md cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800">
444+
<div className="flex items-center p-2 rounded-md cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800"
445+
onClick={() => {
446+
setResendInvatationModel(true);
447+
setInvitationToResend(row.original.id);
448+
toggleOptions(row.original.email);
449+
}}>
442450
<Icon
443451
icon="mdi:arrow-up-circle"
444452
width="40"
@@ -508,6 +516,28 @@ function Invitation() {
508516
);
509517
}
510518

519+
const [ResendInvitation]=useMutation(RESEND_INVITATION,{
520+
variables:{
521+
invitationId:invitationToResend,
522+
orgToken:organizationToken
523+
},
524+
onCompleted:(data)=>{
525+
setTimeout(()=>{
526+
setButtonLoading(false);
527+
toast.success(data.resendInvitation.message);
528+
refetch();
529+
setResendInvatationModel(false)
530+
})
531+
}
532+
,onError:(error)=>{
533+
setTimeout(() => {
534+
setButtonLoading(false);
535+
toast.error(error.message);
536+
}, 500);
537+
}
538+
539+
})
540+
511541
const [DeleteInvitation] = useMutation(DELETE_INVITATION, {
512542
variables: {
513543
invitationId: deleteInvitation,
@@ -631,7 +661,7 @@ function Invitation() {
631661
className="lg:bg-[#9e85f5] bg-none lg:text-white text-[#9e85f5] text-lg lg:text-lg rounded-md h-10 flex items-center justify-center w-[27%]"
632662
>
633663
<IoIosAddCircleOutline className="w-6 h-6 md:w-8 md:h-8 md:mr-2 xm:w-8 xm:h-8 sm:w-10 sm:h-10" />
634-
<span className="hidden lg:block">Invite User</span>
664+
<span className="hidden lg:block text-sm">Invite User</span>
635665
</button>
636666
</div>
637667
</div>
@@ -1028,6 +1058,60 @@ function Invitation() {
10281058
</div>
10291059
</div>
10301060
</div>
1061+
{/* resend invitation modal */}
1062+
1063+
<div
1064+
className={`h-screen w-screen bg-black bg-opacity-30 backdrop-blur-sm fixed top-0 left-0 z-20 flex items-center justify-center px-4 ${
1065+
resendInvitationModel === true ? 'block' : 'hidden'
1066+
}`}
1067+
>
1068+
<div className="w-full p-4 pb-8 bg-white rounded-lg dark:bg-dark-bg sm:w-3/4 xl:w-4/12">
1069+
<div className="flex flex-wrap items-center justify-center w-full card-title ">
1070+
<h3 className="w-11/12 text-sm font-bold text-center dark:text-white ">
1071+
{t('Resend Invitation')}
1072+
</h3>
1073+
<hr className="w-full my-3 border-b bg-primary" />
1074+
</div>
1075+
<div className="card-body">
1076+
<form className="px-8 py-3 ">
1077+
<div className="flex flex-wrap items-center justify-center w-full card-title ">
1078+
<h3 className="w-11/12 text-sm font-bold text-center dark:text-white ">
1079+
{t('Are you sure you want to Resend this invitation?')}
1080+
</h3>
1081+
</div>
1082+
1083+
<div className="flex justify-between w-full">
1084+
<Button
1085+
data-testid="removeModel2"
1086+
variant="info"
1087+
size="sm"
1088+
style="w-[40%] md:w-1/4 text-sm font-sans"
1089+
onClick={() => setResendInvatationModel(false)}
1090+
>
1091+
{t('Cancel')}
1092+
</Button>
1093+
<Button
1094+
variant="primary"
1095+
size="sm"
1096+
data-testid="removeMemberFromCohort"
1097+
style="w-[40%] md:w-1/4 text-sm font-sans"
1098+
onClick={() => {
1099+
setButtonLoading(true);
1100+
if (invitationToResend) {
1101+
ResendInvitation();
1102+
} else {
1103+
toast.error('No invitation selected');
1104+
}
1105+
}}
1106+
loading={buttonLoading}
1107+
>
1108+
{t('Proceed')}
1109+
</Button>
1110+
</div>
1111+
</form>
1112+
</div>
1113+
</div>
1114+
</div>
10311115
</div>
10321116
);
10331117
}

0 commit comments

Comments
 (0)