FPSMS-frontend
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 

116 linhas
2.3 KiB

  1. "use client";
  2. import { Box, Button } from "@mui/material";
  3. import { useTranslation } from "react-i18next";
  4. export type StockInLineActionStyle = {
  5. label: string;
  6. color: string;
  7. };
  8. type Props = {
  9. btnSx: StockInLineActionStyle;
  10. onPrimaryClick: () => void;
  11. canEmail: boolean;
  12. canPrint: boolean;
  13. canDelete: boolean;
  14. onEmail: () => void;
  15. onPrint: () => void;
  16. onDelete: () => void;
  17. btnIsLoading: boolean;
  18. isDeleting: boolean;
  19. };
  20. export default function StockInLineRowActions({
  21. btnSx,
  22. onPrimaryClick,
  23. canEmail,
  24. canPrint,
  25. canDelete,
  26. onEmail,
  27. onPrint,
  28. onDelete,
  29. btnIsLoading,
  30. isDeleting,
  31. }: Props) {
  32. const { t } = useTranslation("purchaseOrder");
  33. const buttonSx = {
  34. whiteSpace: "nowrap" as const,
  35. fontSize: 14,
  36. px: 1.5,
  37. py: 0.75,
  38. minHeight: 34,
  39. width: "100%",
  40. justifyContent: "center",
  41. };
  42. return (
  43. <Box
  44. sx={{
  45. display: "flex",
  46. flexDirection: "column",
  47. alignItems: "stretch",
  48. gap: 0.75,
  49. width: "100%",
  50. py: 0.5,
  51. boxSizing: "border-box",
  52. }}
  53. onClick={(e) => e.stopPropagation()}
  54. >
  55. <Button
  56. variant="contained"
  57. size="small"
  58. sx={{
  59. ...buttonSx,
  60. backgroundColor: btnSx.color,
  61. }}
  62. onClick={onPrimaryClick}
  63. >
  64. {btnSx.label}
  65. </Button>
  66. {canEmail && (
  67. <Button
  68. id="emailSupplier"
  69. type="button"
  70. variant="contained"
  71. color="primary"
  72. size="small"
  73. sx={buttonSx}
  74. onClick={onEmail}
  75. >
  76. {t("email supplier")}
  77. </Button>
  78. )}
  79. {canPrint && (
  80. <Button
  81. id="printQrCode"
  82. type="button"
  83. variant="contained"
  84. size="small"
  85. sx={{
  86. ...buttonSx,
  87. backgroundColor: "#7f434a",
  88. }}
  89. disabled={btnIsLoading}
  90. onClick={onPrint}
  91. >
  92. {t("printQrCode")}
  93. </Button>
  94. )}
  95. {canDelete && (
  96. <Button
  97. variant="outlined"
  98. color="error"
  99. size="small"
  100. sx={buttonSx}
  101. disabled={isDeleting || btnIsLoading}
  102. onClick={onDelete}
  103. >
  104. {t("delete")}
  105. </Button>
  106. )}
  107. </Box>
  108. );
  109. }