diff --git a/.env b/.env index 8c7a609..65a1dbe 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ -# VITE_API_BASE_URL = 'https://negareh-api.dev.danakcorp.com' -VITE_API_BASE_URL = 'https://negare-api.danakcorp.com' +VITE_API_BASE_URL = 'http://localhost:4000' +# VITE_API_BASE_URL = 'https://negare-api.danakcorp.com' VITE_TOKEN_NAME = 'negareh_at' VITE_REFRESH_TOKEN_NAME = 'negareh_art' diff --git a/src/components/Input.tsx b/src/components/Input.tsx index 6d0d353..201fd6d 100644 --- a/src/components/Input.tsx +++ b/src/components/Input.tsx @@ -88,7 +88,7 @@ const Input: FC = (props: Props) => { { setSearch(e.target.value) handleInputChange(e) - }} value={props.seprator ? formattedValue : props.value} type={props.type === 'password' && showPassword ? 'text' : props.type === 'password' ? 'password' : undefined} className={inputClass} /> + }} value={props.seprator ? formattedValue : props.value} type={props.type === 'password' ? (showPassword ? 'text' : 'password') : props.type} className={inputClass} /> { props.type === 'password' && diff --git a/src/pages/auth/components/LoginStep1.tsx b/src/pages/auth/components/LoginStep1.tsx index f4db8b7..04a6661 100644 --- a/src/pages/auth/components/LoginStep1.tsx +++ b/src/pages/auth/components/LoginStep1.tsx @@ -54,7 +54,9 @@ const LoginStep1: FC = () => { label={'شماره موبایل'} placeholder={'شماره موبایل خود را وارد کنید'} type='tel' - className='text-right' + autoComplete='tel' + inputMode='tel' + className='dltr text-left' name='phone_email' onChange={formik.handleChange} value={formik.values.phone_email} diff --git a/src/pages/invoice/Create.tsx b/src/pages/invoice/Create.tsx index 93efdf9..af77b3f 100644 --- a/src/pages/invoice/Create.tsx +++ b/src/pages/invoice/Create.tsx @@ -1,7 +1,7 @@ import { useEffect, useRef, useState, type FC } from "react"; import Button from "@/components/Button"; import Select from "@/components/Select"; -import { TickSquare } from "iconsax-react"; +import { Add, TickSquare } from "iconsax-react"; import { toast } from "@/shared/toast"; import { useNavigate, useSearchParams } from "react-router-dom"; import { Paths } from "@/config/Paths"; @@ -57,7 +57,6 @@ const CreateInvoice: FC = () => { userId: !requestId ? Yup.string().required("انتخاب مشتری اجباری است.") : Yup.string(), - approvalDeadline: Yup.string().required("مهلت تایید اجباری است."), }), onSubmit: async (values) => { const validItems = items.filter( @@ -92,8 +91,12 @@ const CreateInvoice: FC = () => { description: i.description || "", })), enableTax: values.enableTax, - approvalDeadline: moment(values.approvalDeadline, 'jYYYY/jMM/jDD').format('YYYY-MM-DD'), - ...(values.paymentMethod ? { paymentMethod: values.paymentMethod } : {}), + ...(values.approvalDeadline + ? { approvalDeadline: moment(values.approvalDeadline, 'jYYYY/jMM/jDD').format('YYYY-MM-DD') } + : {}), + ...(values.paymentMethod?.trim() + ? { paymentMethod: values.paymentMethod.trim() } + : {}), description: values.description, ...(attachments.length ? { attachments } : {}), }; @@ -141,8 +144,8 @@ const CreateInvoice: FC = () => { ); }; - const addItem = (currentIndex: number) => { - const current = items[currentIndex]; + const addItem = () => { + const current = items[items.length - 1]; const hasProduct = !!current?.productId; const hasQuantity = (current?.quantity ?? 0) > 0; const hasUnitPrice = (current?.unitPrice ?? 0) > 0; @@ -208,11 +211,21 @@ const CreateInvoice: FC = () => { item={item} index={index} onChange={handleItemChange} - onAdd={() => addItem(index)} onRemove={() => removeItem(index)} canRemove={items.length > 1} /> ))} +
+ +
@@ -256,11 +269,6 @@ const CreateInvoice: FC = () => { value={formik.values.paymentMethod} onChange={(e) => formik.setFieldValue("paymentMethod", e.target.value)} onBlur={formik.handleBlur} - error_text={ - formik.errors.paymentMethod && formik.touched.paymentMethod - ? formik.errors.paymentMethod - : "" - } />
diff --git a/src/pages/invoice/ProformaInvoice.tsx b/src/pages/invoice/ProformaInvoice.tsx index 93c4c8e..2d51c02 100644 --- a/src/pages/invoice/ProformaInvoice.tsx +++ b/src/pages/invoice/ProformaInvoice.tsx @@ -73,7 +73,15 @@ const ProformaInvoice: FC = () => { const getServiceLabel = (item: InvoiceType) => { if (!item.items?.length) return '-' if (item.items.length === 1) return item.items[0].product?.title ?? '-' - return `${item.items.length} خدمت` + return ( +
+ {item.items.map((line) => ( + + {line.product?.title ?? '-'} ({line.quantity.toLocaleString('fa-IR')}) + + ))} +
+ ) } return ( @@ -129,6 +137,7 @@ const ProformaInvoice: FC = () => { { key: 'service', title: 'خدمت', + className: '!whitespace-normal', render: (item) => getServiceLabel(item), }, { diff --git a/src/pages/invoice/Update.tsx b/src/pages/invoice/Update.tsx index f193dbd..0bda7de 100644 --- a/src/pages/invoice/Update.tsx +++ b/src/pages/invoice/Update.tsx @@ -1,12 +1,11 @@ import { useEffect, useState, type FC } from "react"; import Button from "@/components/Button"; -import { TickSquare } from "iconsax-react"; +import { Add, TickSquare } from "iconsax-react"; import { toast } from "@/shared/toast"; import { useNavigate, useParams } from "react-router-dom"; import { Paths } from "@/config/Paths"; import { extractErrorMessage } from "@/config/func"; import { useFormik } from "formik"; -import * as Yup from "yup"; import type { CreatePreInvoiceItemType, UpdatePreInvoiceType } from "./types/Types"; import InvoiceItemRow from "./components/InvoiceItemRow"; import { Checkbox } from "@/components/ui/checkbox"; @@ -55,9 +54,6 @@ const UpdateInvoice: FC = () => { paymentMethod: "", description: "", }, - validationSchema: Yup.object({ - approvalDeadline: Yup.string().required("مهلت تایید اجباری است."), - }), onSubmit: async (values) => { const validItems = items.filter( (i) => i.productId && i.quantity > 0 && i.unitPrice >= 0 @@ -96,11 +92,17 @@ const UpdateInvoice: FC = () => { description: i.description || "", })), enableTax: values.enableTax, - approvalDeadline: moment( - values.approvalDeadline, - "jYYYY/jMM/jDD" - ).format("YYYY-MM-DD"), - ...(values.paymentMethod ? { paymentMethod: values.paymentMethod } : {}), + ...(values.approvalDeadline + ? { + approvalDeadline: moment( + values.approvalDeadline, + "jYYYY/jMM/jDD" + ).format("YYYY-MM-DD"), + } + : {}), + ...(values.paymentMethod?.trim() + ? { paymentMethod: values.paymentMethod.trim() } + : {}), description: values.description, ...(attachments.length ? { attachments } : {}), }; @@ -164,8 +166,8 @@ const UpdateInvoice: FC = () => { ); }; - const addItem = (currentIndex: number) => { - const current = items[currentIndex]; + const addItem = () => { + const current = items[items.length - 1]; const hasProduct = !!current?.productId; const hasQuantity = (current?.quantity ?? 0) > 0; const hasUnitPrice = (current?.unitPrice ?? 0) > 0; @@ -231,11 +233,21 @@ const UpdateInvoice: FC = () => { item={item} index={index} onChange={handleItemChange} - onAdd={() => addItem(index)} onRemove={() => removeItem(index)} canRemove={items.length > 1} /> ))} +
+ +
@@ -279,11 +291,6 @@ const UpdateInvoice: FC = () => { value={formik.values.paymentMethod} onChange={(e) => formik.setFieldValue("paymentMethod", e.target.value)} onBlur={formik.handleBlur} - error_text={ - formik.errors.paymentMethod && formik.touched.paymentMethod - ? formik.errors.paymentMethod - : "" - } />
diff --git a/src/pages/invoice/components/InvoiceItemRow.tsx b/src/pages/invoice/components/InvoiceItemRow.tsx index ad6e4d4..505368f 100644 --- a/src/pages/invoice/components/InvoiceItemRow.tsx +++ b/src/pages/invoice/components/InvoiceItemRow.tsx @@ -9,7 +9,7 @@ import { getItemLineTotal, getItemSubTotal, } from "../utils/invoiceItem"; -import { Add, Trash } from "iconsax-react"; +import { Trash } from "iconsax-react"; import { Link } from "react-router-dom"; import { Paths } from "@/config/Paths"; type Props = { @@ -20,7 +20,6 @@ type Props = { field: keyof CreatePreInvoiceItemType, value: string | number | null, ) => void; - onAdd: () => void; onRemove: () => void; canRemove: boolean; onConvertToOrder?: () => void; @@ -31,7 +30,6 @@ const InvoiceItemRow: FC = ({ item, index, onChange, - onAdd, onRemove, canRemove, onConvertToOrder, @@ -170,14 +168,6 @@ const InvoiceItemRow: FC = ({
- {canRemove && (