Skip to content

Commit

Permalink
Implement feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
vhande committed Oct 25, 2024
1 parent 4a9f7d1 commit e051288
Showing 1 changed file with 17 additions and 30 deletions.
47 changes: 17 additions & 30 deletions src/pages/organizers/[organizerId]/ownerships/index.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ const Ownership = () => {
const [selectedRequest, setSelectedRequest] = useState<OwnershipRequest>();
const [isQuestionModalVisible, setIsQuestionModalVisible] = useState(false);
const [actionType, setActionType] = useState<ActionType>();
const [isMutationSuccessful, setIsMutationSuccessful] = useState(false);
const [isSuccessAlertVisible, setIsSuccessAlertVisible] = useState(false);
const isApproveAction = actionType === ActionType.APPROVE;
const translationsPath = `organizers.ownerships.${
isApproveAction ? 'confirm' : 'reject'
}_modal`;

const organizerId = useMemo(
() => router.query.organizerId as string,
Expand Down Expand Up @@ -76,15 +79,15 @@ const Ownership = () => {
const approveOwnershipRequestMutation = useApproveOwnershipRequestMutation({
onSuccess: async () => {
await queryClient.invalidateQueries('ownership-requests');
setIsMutationSuccessful(true);
setIsSuccessAlertVisible(true);
setIsQuestionModalVisible(false);
},
});

const rejectOwnershipRequestMutation = useRejectOwnershipRequestMutation({
onSuccess: async () => {
await queryClient.invalidateQueries('ownership-requests');
setIsMutationSuccessful(true);
setIsSuccessAlertVisible(true);
setIsQuestionModalVisible(false);
},
});
Expand Down Expand Up @@ -114,19 +117,19 @@ const Ownership = () => {
<Alert variant={AlertVariants.PRIMARY} fullWidth>
{t('organizers.ownerships.info')}
</Alert>
{isMutationSuccessful && (
{isSuccessAlertVisible && (
<Alert
variant={AlertVariants.SUCCESS}
fullWidth
closable
onClose={() => setIsMutationSuccessful(false)}
onClose={() => {
setIsSuccessAlertVisible(false);
setSelectedRequest(undefined);
setActionType(undefined);
}}
>
<Trans
i18nKey={
isApproveAction
? 'organizers.ownerships.confirm_modal.success'
: 'organizers.ownerships.reject_modal.success'
}
i18nKey={`${translationsPath}.success`}
values={{
ownerEmail: selectedRequest?.ownerEmail,
organizerName: organizer?.name?.[i18n.language],
Expand Down Expand Up @@ -180,21 +183,9 @@ const Ownership = () => {
)}
/>
<Modal
title={
isApproveAction
? t('organizers.ownerships.confirm_modal.title')
: t('organizers.ownerships.reject_modal.title')
}
confirmTitle={
isApproveAction
? t('organizers.ownerships.confirm_modal.confirm')
: t('organizers.ownerships.reject_modal.confirm')
}
cancelTitle={
isApproveAction
? t('organizers.ownerships.confirm_modal.cancel')
: t('organizers.ownerships.reject_modal.cancel')
}
title={t(`${translationsPath}.title`)}
confirmTitle={t(`${translationsPath}.confirm`)}
cancelTitle={t(`${translationsPath}.cancel`)}
visible={isQuestionModalVisible}
variant={ModalVariants.QUESTION}
onConfirm={handleConfirm}
Expand All @@ -203,11 +194,7 @@ const Ownership = () => {
>
<Box padding={4}>
<Trans
i18nKey={
isApproveAction
? 'organizers.ownerships.confirm_modal.body'
: 'organizers.ownerships.reject_modal.body'
}
i18nKey={`${translationsPath}.body`}
values={{
ownerEmail: selectedRequest?.ownerEmail,
organizerName: organizer?.name?.[i18n.language],
Expand Down

0 comments on commit e051288

Please sign in to comment.