Browse Source

update

master
cyril.tsui 2 weeks ago
parent
commit
db38b7f7c1
2 changed files with 95 additions and 41 deletions
  1. +46
    -39
      src/components/PoDetail/PoDetail.tsx
  2. +49
    -2
      src/components/PoDetail/PoInfoCard.tsx

+ 46
- 39
src/components/PoDetail/PoDetail.tsx View File

@@ -62,6 +62,7 @@ import QrModal from "./QrModal";
import { PlayArrow } from "@mui/icons-material"; import { PlayArrow } from "@mui/icons-material";
import DoneIcon from "@mui/icons-material/Done"; import DoneIcon from "@mui/icons-material/Done";
import { getCustomWidth } from "@/app/utils/commonUtil"; import { getCustomWidth } from "@/app/utils/commonUtil";
import PoInfoCard from "./PoInfoCard";


type Props = { type Props = {
po: PoResult; po: PoResult;
@@ -71,8 +72,8 @@ type Props = {


type EntryError = type EntryError =
| { | {
[field in keyof StockInLine]?: string;
}
[field in keyof StockInLine]?: string;
}
| undefined; | undefined;
// type PolRow = TableRow<Partial<StockInLine>, EntryError>; // type PolRow = TableRow<Partial<StockInLine>, EntryError>;
const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => { const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => {
@@ -84,6 +85,7 @@ const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => {
const [rows, setRows] = useState<PurchaseOrderLine[]>( const [rows, setRows] = useState<PurchaseOrderLine[]>(
purchaseOrder.pol || [], purchaseOrder.pol || [],
); );
const searchParams = useSearchParams(); const searchParams = useSearchParams();
// const [currPoStatus, setCurrPoStatus] = useState(purchaseOrder.status); // const [currPoStatus, setCurrPoStatus] = useState(purchaseOrder.status);


@@ -186,7 +188,7 @@ const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => {
{/* <TableCell /> */} {/* <TableCell /> */}
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={12}> <TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={12}>
<Collapse in={true} timeout="auto" unmountOnExit> <Collapse in={true} timeout="auto" unmountOnExit>
{/* <Collapse in={open} timeout="auto" unmountOnExit> */}
{/* <Collapse in={open} timeout="auto" unmountOnExit> */}
<Table> <Table>
<TableBody> <TableBody>
<TableRow> <TableRow>
@@ -294,9 +296,9 @@ const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => {
switch (field) { switch (field) {
case FIRST_IN_FIELD: case FIRST_IN_FIELD:


return true;
return true;
case SECOND_IN_FIELD: case SECOND_IN_FIELD:
return true;
return true;
default: default:
return false; // Default case return false; // Default case
} }
@@ -306,8 +308,8 @@ const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => {
<> <>
<Stack <Stack
spacing={2} spacing={2}
// component="form"
// onSubmit={formProps.handleSubmit(onSubmit, onSubmitError)}
// component="form"
// onSubmit={formProps.handleSubmit(onSubmit, onSubmitError)}
> >
<Grid container xs={12} justifyContent="start"> <Grid container xs={12} justifyContent="start">
<Grid item> <Grid item>
@@ -333,7 +335,7 @@ const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => {
} }
}} }}
/> />
</Grid>
</Grid>
<Grid item xs={3}> <Grid item xs={3}>
<TextField <TextField
label={t("dnDate")} label={t("dnDate")}
@@ -399,37 +401,42 @@ const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => {
</Grid> </Grid>
</Grid> </Grid>
{/* tab 1 */} {/* tab 1 */}
<Grid sx={{ display: tabIndex === 0 ? "block" : "none" }}>
<TableContainer component={Paper} sx={{ width: 'fit-content', overflow: 'auto' }}>
{/* <TableContainer component={Paper} sx={{width: getCustomWidth(), overflow: 'auto' }}> */}
<Table aria-label="collapsible table" stickyHeader>
<TableHead>
<TableRow>
<TableCell /> {/* for the collapse button */}
<TableCell>{t("itemNo")}</TableCell>
<TableCell align="left">{t("itemName")}</TableCell>
<TableCell align="left">{t("qty")}</TableCell>
<TableCell align="left">{t("processed")}</TableCell>
<TableCell align="left">{t("uom")}</TableCell>
<TableCell align="left">{t("total weight")}</TableCell>
{/* <TableCell align="left">{t("weight unit")}</TableCell> */}
<TableCell align="left">{t("price")}</TableCell>
{/* <TableCell align="left">{t("expiryDate")}</TableCell> */}
<TableCell align="left">{t("status")}</TableCell>
{/* start == true && firstInQty == null ? no hide : hide*/}
{/* {renderFieldCondition(FIRST_IN_FIELD) ? <TableCell align="left">{t("receivedQty")}</TableCell> : undefined} */}
{/* start == true && firstInQty == null ? hide and disabled : no hide*/}
{/* {renderFieldCondition(SECOND_IN_FIELD) ? <TableCell align="left">{t("dnQty")}</TableCell> : undefined} */}
{/* <TableCell align="left">{"add icon button"}</TableCell> */}
</TableRow>
</TableHead>
<TableBody>
{rows.map((row) => (
<Row key={row.id} row={row} />
))}
</TableBody>
</Table>
</TableContainer>
<Grid rowSpacing={2} container sx={{ display: tabIndex === 0 ? "block" : "none" }}>
<Grid item xs={12}>
<PoInfoCard po={purchaseOrder} />
</Grid>
<Grid item xs={12}>
<TableContainer component={Paper} sx={{ width: 'fit-content', overflow: 'auto' }}>
{/* <TableContainer component={Paper} sx={{width: getCustomWidth(), overflow: 'auto' }}> */}
<Table aria-label="collapsible table" stickyHeader>
<TableHead>
<TableRow>
<TableCell /> {/* for the collapse button */}
<TableCell>{t("itemNo")}</TableCell>
<TableCell align="left">{t("itemName")}</TableCell>
<TableCell align="left">{t("qty")}</TableCell>
<TableCell align="left">{t("processed")}</TableCell>
<TableCell align="left">{t("uom")}</TableCell>
<TableCell align="left">{t("total weight")}</TableCell>
{/* <TableCell align="left">{t("weight unit")}</TableCell> */}
<TableCell align="left">{t("price")}</TableCell>
{/* <TableCell align="left">{t("expiryDate")}</TableCell> */}
<TableCell align="left">{t("status")}</TableCell>
{/* start == true && firstInQty == null ? no hide : hide*/}
{/* {renderFieldCondition(FIRST_IN_FIELD) ? <TableCell align="left">{t("receivedQty")}</TableCell> : undefined} */}
{/* start == true && firstInQty == null ? hide and disabled : no hide*/}
{/* {renderFieldCondition(SECOND_IN_FIELD) ? <TableCell align="left">{t("dnQty")}</TableCell> : undefined} */}
{/* <TableCell align="left">{"add icon button"}</TableCell> */}
</TableRow>
</TableHead>
<TableBody>
{rows.map((row) => (
<Row key={row.id} row={row} />
))}
</TableBody>
</Table>
</TableContainer>
</Grid>
</Grid> </Grid>
{/* tab 2 */} {/* tab 2 */}
<Grid sx={{ display: tabIndex === 1 ? "block" : "none" }}> <Grid sx={{ display: tabIndex === 1 ? "block" : "none" }}>


+ 49
- 2
src/components/PoDetail/PoInfoCard.tsx View File

@@ -1,3 +1,5 @@
import { PoResult } from "@/app/api/po";
import { arrayToDateString } from "@/app/utils/formatUtil";
import { import {
Box, Box,
Button, Button,
@@ -8,21 +10,66 @@ import {
Tab, Tab,
Tabs, Tabs,
TabsProps, TabsProps,
TextField,
Typography, Typography,
} from "@mui/material"; } from "@mui/material";
import { useTranslation } from "react-i18next";
type Props = { type Props = {
// id?: number // id?: number
po: PoResult;
}; };


const PoInfoCard: React.FC<Props> = async ( const PoInfoCard: React.FC<Props> = async (
{ {
// id // id
po
}, },
) => { ) => {

const { t } = useTranslation("purchaseOrder")
return ( return (
<> <>
<Card>
<CardContent></CardContent>
<Card sx={{ display: "block" }}>
<CardContent component={Stack} spacing={4}>
<Box>
<Grid container spacing={2} columns={{ xs: 6, sm: 12 }}>
<Grid item xs={6}>
<TextField
// {
// ...register("status")
// }
label={t("Supplier")}
fullWidth
disabled={true}
value={po.supplier}
/>
</Grid>
<Grid item xs={6} />
<Grid item xs={6}>
<TextField
// {
// ...register("code")
// }
label={t("Order Date")}
fullWidth
disabled={true}
value={arrayToDateString(po.orderDate)}
/>
</Grid>
<Grid item xs={6}>
<TextField
// {
// ...register("name")
// }
label={t("ETA")}
fullWidth
disabled={true}
value={arrayToDateString(po.estimatedArrivalDate)}
/>
</Grid>
</Grid>
</Box>
</CardContent>
</Card> </Card>
</> </>
); );


Loading…
Cancel
Save