|
- "use client";
-
- import { Box, Button } from "@mui/material";
- import { useTranslation } from "react-i18next";
-
- export type StockInLineActionStyle = {
- label: string;
- color: string;
- };
-
- type Props = {
- btnSx: StockInLineActionStyle;
- onPrimaryClick: () => void;
- canEmail: boolean;
- canPrint: boolean;
- canDelete: boolean;
- onEmail: () => void;
- onPrint: () => void;
- onDelete: () => void;
- btnIsLoading: boolean;
- isDeleting: boolean;
- };
-
- export default function StockInLineRowActions({
- btnSx,
- onPrimaryClick,
- canEmail,
- canPrint,
- canDelete,
- onEmail,
- onPrint,
- onDelete,
- btnIsLoading,
- isDeleting,
- }: Props) {
- const { t } = useTranslation("purchaseOrder");
-
- const buttonSx = {
- whiteSpace: "nowrap" as const,
- fontSize: 14,
- px: 1.5,
- py: 0.75,
- minHeight: 34,
- width: "100%",
- justifyContent: "center",
- };
-
- return (
- <Box
- sx={{
- display: "flex",
- flexDirection: "column",
- alignItems: "stretch",
- gap: 0.75,
- width: "100%",
- py: 0.5,
- boxSizing: "border-box",
- }}
- onClick={(e) => e.stopPropagation()}
- >
- <Button
- variant="contained"
- size="small"
- sx={{
- ...buttonSx,
- backgroundColor: btnSx.color,
- }}
- onClick={onPrimaryClick}
- >
- {btnSx.label}
- </Button>
- {canEmail && (
- <Button
- id="emailSupplier"
- type="button"
- variant="contained"
- color="primary"
- size="small"
- sx={buttonSx}
- onClick={onEmail}
- >
- {t("email supplier")}
- </Button>
- )}
- {canPrint && (
- <Button
- id="printQrCode"
- type="button"
- variant="contained"
- size="small"
- sx={{
- ...buttonSx,
- backgroundColor: "#7f434a",
- }}
- disabled={btnIsLoading}
- onClick={onPrint}
- >
- {t("printQrCode")}
- </Button>
- )}
- {canDelete && (
- <Button
- variant="outlined"
- color="error"
- size="small"
- sx={buttonSx}
- disabled={isDeleting || btnIsLoading}
- onClick={onDelete}
- >
- {t("delete")}
- </Button>
- )}
- </Box>
- );
- }
|