push rasad front on new repo

This commit is contained in:
2026-01-18 14:32:49 +03:30
commit 4fe6e70525
2139 changed files with 303150 additions and 0 deletions

View File

@@ -0,0 +1,131 @@
import React, { useContext, useState } from "react";
import {
Button,
TextField,
Typography,
Checkbox,
FormControlLabel,
} from "@mui/material";
import { useDispatch } from "react-redux";
import { Grid } from "../../../../components/grid/Grid";
import { SPACING } from "../../../../data/spacing";
import { CLOSE_MODAL } from "../../../../lib/redux/slices/appSlice";
import { AppContext } from "../../../../contexts/AppContext";
import { slaughterEditDelegatesService } from "../../services/slaughter-get-delegates-service";
export const DelegatesLimitationForm = ({ item, updateTable }) => {
const dispatch = useDispatch();
const [openNotif] = useContext(AppContext);
const [hasLimitation, setHasLimitation] = useState(item?.limitation || false);
const [governmentalValue, setGovernmentalValue] = useState(
item?.governmentalLimitationWeight || 0
);
const [freeValue, setFreeValue] = useState(item?.freeLimitationWeight || 0);
const handleSubmit = (e) => {
e.preventDefault();
const submitData = {
key: item?.key,
limitation: hasLimitation,
governmental_limitation_weight: hasLimitation
? Number(governmentalValue)
: 0,
free_limitation_weight: hasLimitation ? Number(freeValue) : 0,
};
dispatch(slaughterEditDelegatesService(submitData)).then((r) => {
if (r.payload?.error) {
openNotif({
vertical: "top",
horizontal: "center",
msg: r.payload.error,
severity: "error",
});
} else {
openNotif({
vertical: "top",
horizontal: "center",
msg: "عملیات با موفقیت انجام شد.",
severity: "success",
});
if (updateTable) {
updateTable();
}
dispatch(CLOSE_MODAL());
}
});
};
return (
<form onSubmit={handleSubmit}>
<Grid container gap={SPACING.SMALL} p={2}>
<Grid container item xs={12} alignItems="center" gap={1}>
<Typography variant="body2" color="text.secondary">
اطلاعات نماینده:
</Typography>
<Typography variant="h6" mb={0.75}>
{item?.firstName || item?.first_name}{" "}
{item?.lastName || item?.last_name}
</Typography>
</Grid>
<Grid item xs={12} mb={1}>
<FormControlLabel
control={
<Checkbox
checked={hasLimitation}
onChange={(e) => setHasLimitation(e.target.checked)}
color="primary"
/>
}
label="محدودیت فروش روزانه"
/>
</Grid>
{hasLimitation && (
<>
<Grid item xs={12}>
<TextField
label="حداکثر فروش دولتی (کیلوگرم)"
variant="outlined"
fullWidth
type="number"
value={governmentalValue}
onChange={(e) => setGovernmentalValue(e.target.value)}
inputProps={{ min: 0 }}
/>
</Grid>
<Grid item xs={12}>
<TextField
label="حداکثر فروش آزاد (کیلوگرم)"
variant="outlined"
fullWidth
type="number"
value={freeValue}
onChange={(e) => setFreeValue(e.target.value)}
inputProps={{ min: 0 }}
/>
</Grid>
</>
)}
<Grid item xs={12} mt={2}>
<Button
type="submit"
variant="contained"
color="primary"
fullWidth
disabled={
hasLimitation && governmentalValue === 0 && freeValue === 0
}
>
ثبت
</Button>
</Grid>
</Grid>
</form>
);
};