Skip to content

Commit

Permalink
create bill bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ElyasMehraein committed Apr 29, 2024
1 parent a0b355b commit 1c26dce
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/api/auth/signup/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import connectToDb from "@/configs/db"
import { createHash } from "crypto";
import { SMSOtpvalidator } from "@/controllers/smsotp.js"
import jwt from "jsonwebtoken";
import { phoneFormatCheck, SMSFormatCheck } from "@/controllers/Validator"
import { phoneFormatCheck, SMSFormatCheck } from "@/controllers/validator"
import { cookies } from 'next/headers'


Expand Down
20 changes: 11 additions & 9 deletions components/templates/index/Bills/CreateBill.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ export default function CreateBill({ user, fabHandler }) {
const [unitOfMeasurement, setUnitOfMeasurement] = React.useState("")
const [amount, setAmount] = React.useState("")
const [bills, setbills] = React.useState([])
const [customerCode, setCustomerCode] = React.useState([])
const [customerCode, setCustomerCode] = React.useState("")

const addToBills = () => {
setbills([{ id: bills.length + 1, productName: selectedProduct, unitOfMeasurement, amount }, ...bills])
setSelectedProduct("")
setUnitOfMeasurement("")
setAmount("")
}
Expand All @@ -42,12 +43,12 @@ export default function CreateBill({ user, fabHandler }) {

const handleSnackbarClose = () => {
setOpenSnackbar(false);
// fabHandler();
};
const handleShowSnackbar = () => {
setOpenSnackbar(true);
};
async function createThisBill(selectedBusiness, customerCode, bills) {
fabHandler();
setIsLoading(true);
const res = await fetch('api/createBill', {
method: "POST",
Expand All @@ -62,19 +63,18 @@ export default function CreateBill({ user, fabHandler }) {
setIsLoading(false)
} else if (res.status === 404) {
setOpenSnackbar404Error(true)
setIsLoading(false)
} else if (res.status === 406) {
setOpenSnackbarError(true)
setIsLoading(false)
} else if (res.status === 407) {
setOpenSnackbar407Error(true)
setIsLoading(false)
}
}
const [expanded, setExpanded] = React.useState(false);
return (
<Container maxWidth="md">

{/* <Box className="inMiddle">
<CircularProgress />
</Box>: */}
<Container maxWidth="md" sx={{ pb: 5 }}>
<Accordion sx={{ boxShadow: 0 }} expanded={expanded}>
<Chip
label="راهنمایی"
Expand Down Expand Up @@ -106,13 +106,13 @@ export default function CreateBill({ user, fabHandler }) {
/>
<CustomSnackbar
open={openSnackbar404Error}
onClose={() => setOpenSnackbarError(false)}
onClose={() => setOpenSnackbar404Error(false)}
message="کاربر یافت نشد کد کاربری را مجدد بررسی نمایید"
severity="error"
/>
<CustomSnackbar
open={openSnackbar407Error}
onClose={() => setOpenSnackbarError(false)}
onClose={() => setOpenSnackbar407Error(false)}
message="کاربر انتخاب شده فاقد کسب و کار اصلی است"
severity="error"
/>
Expand Down Expand Up @@ -186,6 +186,7 @@ export default function CreateBill({ user, fabHandler }) {
sx={{ mt: 2 }}
children={"اضافه نمودن به فاکتور"}
variant="contained"
disabled={selectedProduct && unitOfMeasurement && amount ? false : true}
onClick={addToBills}
/>
{bills[0] &&
Expand All @@ -204,6 +205,7 @@ export default function CreateBill({ user, fabHandler }) {
/>
< Button
sx={{ mt: 2 }}
disabled={customerCode ? false : true}
children={"ارسال صورتحساب"}
variant="contained"
onClick={() => createThisBill(selectedBusiness, customerCode, bills)}
Expand Down
2 changes: 1 addition & 1 deletion components/templates/welcome/Welcome.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import TextField from "@mui/material/TextField";
import { useState, useEffect } from "react";
import hands from "@/public/m-hands.png"
import { useRouter } from "next/navigation";
import { phoneFormatCheck, SMSFormatCheck } from "@/controllers/Validator";
import { phoneFormatCheck, SMSFormatCheck } from "@/controllers/validator";
import { Alert, Snackbar } from "@mui/material";


Expand Down

0 comments on commit 1c26dce

Please sign in to comment.