diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-04-14 15:21:49 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-04-14 15:21:49 +0700 |
| commit | 593dd8e50a55e7e33fe0a672c382e1228b0bb6bc (patch) | |
| tree | b9e408123bf183d08d473f96b3b30224c428123c | |
| parent | bed145acde22ef5ebf69972cf6592063e553bf85 (diff) | |
fix
| -rw-r--r-- | src/lib/form/components/KunjunganSales.jsx | 27 | ||||
| -rw-r--r-- | src/lib/transaction/components/Transaction.jsx | 61 | ||||
| -rw-r--r-- | src/styles/globals.css | 2 |
3 files changed, 28 insertions, 62 deletions
diff --git a/src/lib/form/components/KunjunganSales.jsx b/src/lib/form/components/KunjunganSales.jsx index bb7df05b..38a07345 100644 --- a/src/lib/form/components/KunjunganSales.jsx +++ b/src/lib/form/components/KunjunganSales.jsx @@ -47,22 +47,20 @@ const KunjunganSales = () => { return } - const descriptions = [ - `Nama Perusahaan: ${values.company}`, - `No. Telepon: ${values.phone}`, - `Alamat Lengkap: ${values.address}`, - `Kota: ${values.city}`, - `Unit Perusahaan: ${values.companyType}`, - `No. Handphone: ${values.mobile}`, - `Alamat Email: ${values.email}`, - `Keterangan: ${values.description}` - ] - const data = { - name: `Permintaan Kunjungan Sales - ${values.company}`, + name: `Pengajuan Kunjungan Sales - ${values.company}`, email_from: values.email, phone: values.phone, - description: descriptions.join('\n') + description: [ + `Nama Perusahaan: ${values.company}`, + `No. Telepon: ${values.phone}`, + `Alamat Lengkap: ${values.address}`, + `Kota: ${values.city}`, + `Unit Perusahaan: ${values.companyType}`, + `No. Handphone: ${values.mobile}`, + `Alamat Email: ${values.email}`, + `Keterangan: ${values.description}` + ].join('\n') } const createLead = await createLeadApi({ data }) @@ -168,7 +166,6 @@ const KunjunganSales = () => { <div> <label className='form-label mb-2'>Keterangan</label> <textarea {...register('description')} type='text' className='form-input' /> - <div className='text-caption-2 text-danger-500 mt-1'>{errors.description?.message}</div> </div> <ReCAPTCHA ref={recaptchaRef} sitekey={process.env.NEXT_PUBLIC_RECAPTCHA_GOOGLE} /> @@ -181,6 +178,7 @@ const KunjunganSales = () => { </div> ) } + const validationSchema = Yup.object().shape({ email: Yup.string().email('Format harus seperti contoh@email.com').required('Harus di-isi'), company: Yup.string().required('Harus di-isi'), @@ -189,6 +187,7 @@ const validationSchema = Yup.object().shape({ address: Yup.string().required('Harus di-isi'), city: Yup.string().required('Harus dipilih') }) + const defaultValues = { email: '', company: '', diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index b4e050c6..3e3f2cc7 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -25,25 +25,8 @@ import toTitleCase from '@/core/utils/toTitleCase' const Transaction = ({ id }) => { const { transaction } = useTransaction({ id }) - const [totalAmount, setTotalAmount] = useState(0) - const [totalDiscountAmount, setTotalDiscountAmount] = useState(0) - - useEffect(() => { - if (transaction?.data?.products) { - let calculateTotalAmount = 0 - let calculateTotalDiscountAmount = 0 - transaction.data.products.forEach((product) => { - calculateTotalAmount += product.price.price * product.quantity - calculateTotalDiscountAmount += - (product.price.price - product.price.priceDiscount) * product.quantity - }) - setTotalAmount(calculateTotalAmount) - setTotalDiscountAmount(calculateTotalDiscountAmount) - } - }, [transaction]) - - const poNumber = useRef('') - const poFile = useRef('') + const poNumber = useRef(null) + const poFile = useRef(null) const [uploadPo, setUploadPo] = useState(false) const openUploadPo = () => setUploadPo(true) const closeUploadPo = () => setUploadPo(false) @@ -97,11 +80,7 @@ const Transaction = ({ id }) => { <VariantGroupCard variants={transaction.data?.products} buyMore /> <div className='flex justify-between mt-1'> <p className='text-gray_r-12/70'>Subtotal</p> - <p>{currencyFormat(totalAmount)}</p> - </div> - <div className='flex justify-between mt-1'> - <p className='text-gray_r-12/70'>Total Diskon</p> - <p>{currencyFormat(-totalDiscountAmount)}</p> + <p>{currencyFormat(transaction.data?.amountUntaxed)}</p> </div> <div className='flex justify-between mt-1'> <p className='text-gray_r-12/70'>PPN 11%</p> @@ -113,7 +92,7 @@ const Transaction = ({ id }) => { </div> </div> ), - [transaction.data, totalAmount, totalDiscountAmount] + [transaction.data] ) if (transaction.isLoading) { @@ -295,7 +274,6 @@ const Transaction = ({ id }) => { <button type='button' className='btn-solid-red px-3 py-2' - // disabled={transaction.data?.status != 'draft'} onClick={() => downloadQuotation(transaction.data)} > Download @@ -337,14 +315,6 @@ const Transaction = ({ id }) => { <div className='font-medium mb-4'>Detail Pelanggan</div> <SectionContent address={transaction?.data?.address?.customer} /> </div> - {/* <div className='border border-gray_r-6 rounded p-3'> - <div className='font-medium mb-4'>Detail Pengiriman</div> - <SectionContent address={transaction?.data?.address?.shipping} /> - </div> - <div className='border border-gray_r-6 rounded p-3'> - <div className='font-medium mb-4'>Detail Penagihan</div> - <SectionContent address={transaction?.data?.address?.invoice} /> - </div> */} </div> <div className='text-h-sm font-semibold mt-6 mb-4'>Rincian Pembelian</div> @@ -352,9 +322,9 @@ const Transaction = ({ id }) => { <thead> <tr> <th>Nama Produk</th> + <th>Diskon</th> <th>Jumlah</th> <th>Harga</th> - <th>Diskon</th> <th>Subtotal</th> </tr> </thead> @@ -368,12 +338,12 @@ const Transaction = ({ id }) => { product?.parent.name, product?.parent.id )} - className='w-[25%] flex-shrink-0' + className='w-[20%] flex-shrink-0' > <Image src={product?.parent?.image} alt={product?.name} - className='object-contain object-center border border-gray_r-6 h-40 w-full rounded-md' + className='object-contain object-center border border-gray_r-6 h-32 w-full rounded-md' /> </Link> <div className='px-2 text-left'> @@ -395,6 +365,11 @@ const Transaction = ({ id }) => { </div> </div> </td> + <td> + {product.price.discountPercentage > 0 + ? `${product.price.discountPercentage}%` + : ''} + </td> <td>{product.quantity}</td> <td> {product.price.discountPercentage > 0 && ( @@ -404,11 +379,6 @@ const Transaction = ({ id }) => { )} <div>{currencyFormat(product.price.priceDiscount)}</div> </td> - <td> - {product.price.discountPercentage > 0 - ? `${product.price.discountPercentage}%` - : ''} - </td> <td>{currencyFormat(product.price.subtotal)}</td> </tr> ))} @@ -418,11 +388,8 @@ const Transaction = ({ id }) => { <div className='flex justify-end mt-4'> <div className='w-1/4 grid grid-cols-2 gap-y-3 text-gray_r-12/80'> <div className='text-right'>Subtotal</div> - <div className='text-right font-medium'>{currencyFormat(totalAmount)}</div> - - <div className='text-right'>Total Diskon</div> - <div className='text-right font-medium text-danger-500'> - {currencyFormat(-totalDiscountAmount)} + <div className='text-right font-medium'> + {currencyFormat(transaction.data?.amountUntaxed)} </div> <div className='text-right'>PPN 11%</div> diff --git a/src/styles/globals.css b/src/styles/globals.css index 5d5a6696..f1e9f5b1 100644 --- a/src/styles/globals.css +++ b/src/styles/globals.css @@ -470,7 +470,7 @@ button { .table-data thead th, .table-data tbody td { - @apply py-3 + @apply p-3 text-center; } |
