mirror of
https://github.com/lemeow125/Borrowing-TrackerFrontend.git
synced 2025-05-18 20:38:14 +08:00
Made SKU and item adding fully functional
This commit is contained in:
parent
614a9c4a24
commit
201822b271
5 changed files with 304 additions and 18 deletions
|
@ -18,7 +18,7 @@ export default function AddSKUModal() {
|
|||
const [sku, setSKU] = useState({
|
||||
name: "",
|
||||
description: "",
|
||||
category: "",
|
||||
category: "MISC",
|
||||
});
|
||||
const [error, setError] = useState("");
|
||||
|
||||
|
@ -76,10 +76,11 @@ export default function AddSKUModal() {
|
|||
</FormLabel>
|
||||
<RadioGroup
|
||||
aria-labelledby="demo-radio-buttons-group-label"
|
||||
defaultValue="female"
|
||||
defaultValue="MISC"
|
||||
name="radio-buttons-group"
|
||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setSKU({ ...sku, category: e.target.value });
|
||||
setError("");
|
||||
}}
|
||||
>
|
||||
<div style={styles.flex_row}>
|
||||
|
@ -144,20 +145,25 @@ export default function AddSKUModal() {
|
|||
const data = await EquipmentCreateAPI(sku);
|
||||
if (data[0]) {
|
||||
setError("Added successfully");
|
||||
toast("New SKU added successfuly", {
|
||||
position: "top-right",
|
||||
autoClose: 2000,
|
||||
hideProgressBar: false,
|
||||
closeOnClick: true,
|
||||
pauseOnHover: true,
|
||||
draggable: true,
|
||||
progress: undefined,
|
||||
theme: "light",
|
||||
});
|
||||
toast(
|
||||
`New SKU added successfuly, ${
|
||||
typeof data[1] == "object" ? "ID:" + data[1].id : ""
|
||||
}`,
|
||||
{
|
||||
position: "top-right",
|
||||
autoClose: 2000,
|
||||
hideProgressBar: false,
|
||||
closeOnClick: true,
|
||||
pauseOnHover: true,
|
||||
draggable: true,
|
||||
progress: undefined,
|
||||
theme: "light",
|
||||
}
|
||||
);
|
||||
queryClient.invalidateQueries({ queryKey: ["equipments"] });
|
||||
setSKU({ name: "", description: "", category: "" });
|
||||
setSKU({ name: "", description: "", category: "MISC" });
|
||||
} else {
|
||||
setError(JSON.stringify(data));
|
||||
setError(JSON.stringify(data[1]));
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue