Skip to content
Extraits de code Groupes Projets
Valider 81a2287e rédigé par Mohamed Lemine BAILLAHI's avatar Mohamed Lemine BAILLAHI
Parcourir les fichiers

Merge branch 'feature/MS-99' into 'develop'

Ms-99/add storation button

Closes MS-99

See merge request !499
parents 1b59e0c5 43c8fe40
Branches
1 requête de fusion!499Ms-99/add storation button
...@@ -737,4 +737,21 @@ export function useSearchUnregistredClient({ ...@@ -737,4 +737,21 @@ export function useSearchUnregistredClient({
isValidating, isValidating,
revalidate: mutate, revalidate: mutate,
}; };
} }
\ No newline at end of file
export function useRestoreOrder() {
const restoreOrder = async (orderId: string) => {
try {
const response = await axiosInstance.put(`${endpoints.salleSession.restoreOrder(orderId)}`);
await mutate(endpoints.salleSession.getOrdersBySessionId);
return response.data;
} catch (error) {
console.error("Failed to restore order", error);
throw error;
}
}
const memoizedValue = useMemo(() => ({ restoreOrder }), []);
return memoizedValue;
};
\ No newline at end of file
...@@ -446,7 +446,9 @@ export const endpoints = { ...@@ -446,7 +446,9 @@ export const endpoints = {
getTypeCount:"/api/cart/count-type", getTypeCount:"/api/cart/count-type",
getDeletedSeleSessionPage: "/api/cart/deleted/page", getDeletedSeleSessionPage: "/api/cart/deleted/page",
getDeletedTypeCount:"/api/cart/deleted/count-type", getDeletedTypeCount:"/api/cart/deleted/count-type",
getUnregisteredClientPage:"/api/user/unregistered-client/page" getUnregisteredClientPage:"/api/user/unregistered-client/page",
restoreOrder: (orderId:string) => `/api/cart/restore/${orderId}`
}, },
supplier: { supplier: {
getAllSupplier: "/api/user/supplier", getAllSupplier: "/api/user/supplier",
......
...@@ -3,12 +3,13 @@ import TableRow from "@mui/material/TableRow"; ...@@ -3,12 +3,13 @@ import TableRow from "@mui/material/TableRow";
import DeleteIcon from "@mui/icons-material/Delete"; import DeleteIcon from "@mui/icons-material/Delete";
import TableCell from "@mui/material/TableCell"; import TableCell from "@mui/material/TableCell";
import IconButton from "@mui/material/IconButton"; import IconButton from "@mui/material/IconButton";
import RestoreFromTrashIcon from "@mui/icons-material/RestoreFromTrash";
import ListItemText from "@mui/material/ListItemText"; import ListItemText from "@mui/material/ListItemText";
import Label from "../../../components/label"; import Label from "../../../components/label";
import { IOrder } from "@/shared/types/saleSession"; import { IOrder } from "@/shared/types/saleSession";
import { Checkbox } from "@mui/material"; import { Checkbox } from "@mui/material";
import { fDate, fTime } from "@/utils/format-time"; import { fDate, fTime } from "@/utils/format-time";
import { useDeleteOrder } from "@/shared/api/saleSession"; import { useDeleteOrder , useRestoreOrder } from "@/shared/api/saleSession";
import { useSnackbar } from "@/components/snackbar"; import { useSnackbar } from "@/components/snackbar";
import { useBoolean } from "@/hooks/use-boolean"; import { useBoolean } from "@/hooks/use-boolean";
import QuantityEditForm from "./order-quick-edit-quantity"; import QuantityEditForm from "./order-quick-edit-quantity";
...@@ -38,6 +39,7 @@ export default function OrderTableRow({ row, selected }: Props) { ...@@ -38,6 +39,7 @@ export default function OrderTableRow({ row, selected }: Props) {
const { enqueueSnackbar } = useSnackbar(); const { enqueueSnackbar } = useSnackbar();
const { deleteOrder } = useDeleteOrder(); const { deleteOrder } = useDeleteOrder();
const {restoreOrder} = useRestoreOrder();
const quickEdit = useBoolean(); const quickEdit = useBoolean();
const handleDelete = async () => { const handleDelete = async () => {
...@@ -49,6 +51,20 @@ export default function OrderTableRow({ row, selected }: Props) { ...@@ -49,6 +51,20 @@ export default function OrderTableRow({ row, selected }: Props) {
enqueueSnackbar("Échec de la suppression de la commande", { variant: "error" }); enqueueSnackbar("Échec de la suppression de la commande", { variant: "error" });
} }
}; };
const handleRestore = async () => {
try {
await restoreOrder(orderId);
enqueueSnackbar("Commande restoré avec succès", { variant: "success" });
} catch (error) {
enqueueSnackbar("Échec de la restoration de la commande", { variant: "error" });
}
};
const shouldShowActions = statutPanier !== "DELETED_BO" && statutPanier !== "PAYED"; const shouldShowActions = statutPanier !== "DELETED_BO" && statutPanier !== "PAYED";
const getStatutPanierLabel = (status: string) => { const getStatutPanierLabel = (status: string) => {
...@@ -61,7 +77,7 @@ export default function OrderTableRow({ row, selected }: Props) { ...@@ -61,7 +77,7 @@ export default function OrderTableRow({ row, selected }: Props) {
return "Supprimer depuis Site"; return "Supprimer depuis Site";
case "DELETED_BO": case "DELETED_BO":
return "Supprimer depuis Bo"; return "Supprimer depuis Bo";
case "PAYED" : case "PAYED":
return "payer" return "payer"
default: default:
return "Inconnu"; return "Inconnu";
...@@ -157,26 +173,40 @@ export default function OrderTableRow({ row, selected }: Props) { ...@@ -157,26 +173,40 @@ export default function OrderTableRow({ row, selected }: Props) {
/> />
</TableCell> </TableCell>
<TableCell align="right" sx={{ px: 1, whiteSpace: "nowrap" }}> <TableCell align="right" sx={{ px: 1, whiteSpace: "nowrap" }}>
{shouldShowActions ? ( {shouldShowActions ? (
<> <>
<Tooltip title="Modifier la quantité" placement="top" arrow> <Tooltip title="Modifier la quantité" placement="top" arrow>
<IconButton <IconButton
color="primary" color="primary"
onClick={() => { onClick={() => {
quickEdit.onTrue(); quickEdit.onTrue();
}} }}
> >
<Iconify icon="solar:pen-bold" /> <Iconify icon="solar:pen-bold" />
</IconButton> </IconButton>
</Tooltip> </Tooltip>
<Tooltip title="Supprimer" placement="top" arrow> <Tooltip title="Supprimer" placement="top" arrow>
<IconButton color="error" onClick={handleDelete}> <IconButton color="error" onClick={handleDelete}>
<DeleteIcon /> <DeleteIcon />
</IconButton> </IconButton>
</Tooltip> </Tooltip>
</>
) : null} {(row.statutPanier === 'DELETED_SITE' || row.statutPanier === 'DELETED_BO') && (
<Tooltip title="Restaurer" placement="top" arrow>
<IconButton
sx={{ color: "#ff9800" }}
onClick={handleRestore}
>
<RestoreFromTrashIcon />
</IconButton>
</Tooltip>
)}
</>
) : null}
</TableCell> </TableCell>
</TableRow> </TableRow>
<QuantityEditForm <QuantityEditForm
......
0% ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter