Skip to content

Commit

Permalink
refactor: add trad and clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
gca-axelor authored and lme-axelor committed Dec 11, 2024
1 parent 8833fb9 commit cd7c3d4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import React, {useCallback, useState} from 'react';
import React, {useCallback, useMemo, useState} from 'react';
import {StyleSheet, View} from 'react-native';
import {
useDispatch,
Expand Down Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
);
},
Expand Down
6 changes: 3 additions & 3 deletions packages/apps/hr/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
8 changes: 4 additions & 4 deletions packages/apps/hr/src/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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é"
}

0 comments on commit cd7c3d4

Please sign in to comment.