From cd7c3d49ba6542266c0bef2b6cd3a993871a8c7a Mon Sep 17 00:00:00 2001 From: Gregory <117281520+gca-axelor@users.noreply.github.com> Date: Mon, 9 Dec 2024 11:36:40 +0100 Subject: [PATCH] refactor: add trad and clean code --- .../LeaveDetailsButtons.tsx | 25 +++++++++++-------- .../LeaveRefusalPopup/LeaveRefusalPopup.tsx | 4 +-- packages/apps/hr/src/i18n/en.json | 6 ++--- packages/apps/hr/src/i18n/fr.json | 8 +++--- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/packages/apps/hr/src/components/molecules/LeaveDetailsButtons/LeaveDetailsButtons.tsx b/packages/apps/hr/src/components/molecules/LeaveDetailsButtons/LeaveDetailsButtons.tsx index a3e994780d..35fa9a7e46 100644 --- a/packages/apps/hr/src/components/molecules/LeaveDetailsButtons/LeaveDetailsButtons.tsx +++ b/packages/apps/hr/src/components/molecules/LeaveDetailsButtons/LeaveDetailsButtons.tsx @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import React, {useCallback, useState} from 'react'; +import React, {useCallback, useMemo, useState} from 'react'; import {StyleSheet, View} from 'react-native'; import { useDispatch, @@ -53,35 +53,40 @@ const LeaveDetailsButtons = ({ const {user} = useSelector(state => state.user); + const leaveRequestParams = useMemo( + () => ({ + leaveRequestId: leaveId, + version: leaveVersion, + }), + [leaveId, leaveVersion], + ); + const sendLeaveAPI = useCallback(() => { dispatch( (sendLeave as any)({ - leaveRequestId: leaveId, - version: leaveVersion, + ...leaveRequestParams, userId: user?.id, }), ); - }, [dispatch, leaveId, leaveVersion, user?.id]); + }, [dispatch, leaveRequestParams, user?.id]); const validateLeaveAPI = useCallback(() => { dispatch( (validateLeave as any)({ - leaveRequestId: leaveId, - version: leaveVersion, + ...leaveRequestParams, user: user, }), ); - }, [dispatch, leaveId, leaveVersion, user]); + }, [dispatch, leaveRequestParams, user]); const cancelLeaveAPI = useCallback(() => { dispatch( (cancelLeave as any)({ - leaveRequestId: leaveId, - version: leaveVersion, + ...leaveRequestParams, userId: user?.id, }), ); - }, [dispatch, leaveId, leaveVersion, user]); + }, [dispatch, leaveRequestParams, user?.id]); if (statusSelect === LeaveRequest?.statusSelect.Draft) { return ( diff --git a/packages/apps/hr/src/components/templates/LeaveRefusalPopup/LeaveRefusalPopup.tsx b/packages/apps/hr/src/components/templates/LeaveRefusalPopup/LeaveRefusalPopup.tsx index 0cb742f40a..f55fd3cbf2 100644 --- a/packages/apps/hr/src/components/templates/LeaveRefusalPopup/LeaveRefusalPopup.tsx +++ b/packages/apps/hr/src/components/templates/LeaveRefusalPopup/LeaveRefusalPopup.tsx @@ -39,13 +39,13 @@ const LeaveRefusalPopup = ({ const {user} = useSelector(state => state.user); const rejectLeaveAPI = useCallback( - MeassageRefusal => { + (refusalMessage: string) => { dispatch( (rejectLeave as any)({ leaveRequestId: leaveId, version: leaveVersion, user: user, - groundForRefusal: MeassageRefusal, + groundForRefusal: refusalMessage, }), ); }, diff --git a/packages/apps/hr/src/i18n/en.json b/packages/apps/hr/src/i18n/en.json index 39ba839418..1b0ce0f9c3 100644 --- a/packages/apps/hr/src/i18n/en.json +++ b/packages/apps/hr/src/i18n/en.json @@ -155,7 +155,7 @@ "Hr_SliceAction_FetchLeaveById": "fetch leave request by id", "Hr_SliceAction_FetchLeaveReason": "fetch leave reason", "Hr_SliceAction_SendLeave": "send leave", - "Hr_SliceAction_ValidateLeave": "", - "Hr_SliceAction_CancelLeave": "", - "Hr_SliceAction_RejectLeave": "" + "Hr_SliceAction_ValidateLeave": "validate leave", + "Hr_SliceAction_CancelLeave": "cancel leave", + "Hr_SliceAction_RejectLeave": "reject leave" } diff --git a/packages/apps/hr/src/i18n/fr.json b/packages/apps/hr/src/i18n/fr.json index f8921ec3c0..b3fbbdbd27 100644 --- a/packages/apps/hr/src/i18n/fr.json +++ b/packages/apps/hr/src/i18n/fr.json @@ -42,7 +42,7 @@ "Hr_Send": "Envoyer", "Hr_Validate": "Valider", "Hr_Delete": "Supprimer", - "Hr_Cancel": "Annulé", + "Hr_Cancel": "Annuler", "Hr_CreateExpense": "Créer une note de frais", "Hr_CreateExpenseLine": "Créer une ligne de note de frais", "Hr_Refuse": "Refuser", @@ -155,7 +155,7 @@ "Hr_SliceAction_FetchLeaveById": "récupération d'une demande de congés par id", "Hr_SliceAction_FetchLeaveReason": "récupération des motif de congés", "Hr_SliceAction_SendLeave": "envoie de la demande de congé", - "Hr_SliceAction_ValidateLeave": "", - "Hr_SliceAction_CancelLeave": "", - "Hr_SliceAction_RejectLeave": "" + "Hr_SliceAction_ValidateLeave": "valider la demande de congé", + "Hr_SliceAction_CancelLeave": "annuler la demande de congé", + "Hr_SliceAction_RejectLeave": "rejeter la demande de congé" }