diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2025-05-31 08:55:43 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2025-05-31 08:55:43 +0700 |
| commit | 0d28dc8ff5fb8c5399e356ed6ecae4fce2019ca6 (patch) | |
| tree | 51c25a7c508b30e974551c69680a10a76470c147 | |
| parent | 62d2edfa5ae62cd8faa2d0322ddfd5dfa6ad2d2e (diff) | |
<hafid> fix repeat-order
| -rw-r--r-- | src/core/components/elements/Navbar/NavbarDesktop.jsx | 2 | ||||
| -rw-r--r-- | src/core/components/elements/Navbar/NavbarUserDropdown.jsx | 1 | ||||
| -rw-r--r-- | src/core/components/layouts/BasicLayout.jsx | 2 | ||||
| -rw-r--r-- | src/lib/auth/components/Menu.jsx | 14 | ||||
| -rw-r--r-- | src/lib/quotation/components/Quotationheader.jsx | 23 | ||||
| -rw-r--r-- | src/lib/transaction/components/Transactions.jsx | 124 | ||||
| -rw-r--r-- | src/pages/my/transactions/index.jsx | 4 |
7 files changed, 127 insertions, 43 deletions
diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx index 03d7fa0c..db4fcbb8 100644 --- a/src/core/components/elements/Navbar/NavbarDesktop.jsx +++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx @@ -51,7 +51,7 @@ const NavbarDesktop = () => { const { transactions } = useTransactions({ query }); const data = transactions?.data?.saleOrders.filter( - (transaction) => transaction.status === 'draft' + (transaction) => transaction.status === 'waiting' ); const [showPopup, setShowPopup] = useState(false); diff --git a/src/core/components/elements/Navbar/NavbarUserDropdown.jsx b/src/core/components/elements/Navbar/NavbarUserDropdown.jsx index b2ad6309..5fe0cfa7 100644 --- a/src/core/components/elements/Navbar/NavbarUserDropdown.jsx +++ b/src/core/components/elements/Navbar/NavbarUserDropdown.jsx @@ -16,7 +16,6 @@ const NavbarUserDropdown = () => { <div className='navbar-user-dropdown-wrapper'> <div className='navbar-user-dropdown'> <Link href='/my/profile'>Profil Saya</Link> - <Link href='/my/quotations'>Daftar Quotation</Link> <Link href='/my/transactions'>Daftar Transaksi</Link> <Link href='/my/shipments'>Daftar Pengiriman</Link> <Link href='/my/invoices'>Invoice & Faktur Pajak</Link> diff --git a/src/core/components/layouts/BasicLayout.jsx b/src/core/components/layouts/BasicLayout.jsx index 2998fa63..81f8b41f 100644 --- a/src/core/components/layouts/BasicLayout.jsx +++ b/src/core/components/layouts/BasicLayout.jsx @@ -54,6 +54,8 @@ const BasicLayout = ({ children }) => { useEffect(() => { const handleMouseOut = (event) => { + + if (!buttonRef.current) return; const rect = buttonRef.current.getBoundingClientRect(); if (event.clientY <= 0) { setButtonPosition(rect); diff --git a/src/lib/auth/components/Menu.jsx b/src/lib/auth/components/Menu.jsx index df33314c..20bc54fd 100644 --- a/src/lib/auth/components/Menu.jsx +++ b/src/lib/auth/components/Menu.jsx @@ -85,20 +85,6 @@ const Menu = () => { <div className='mt-2 mb-1 font-medium'>Menu</div> <div className='flex flex-col gap-y-2'> <LinkItem - href='/my/quotations' - active={routeStartWith('/my/quotations')} - className='' - > - <div className='flex gap-x-3 items-center'> - <ImageNext - src='/images/icon/icon_daftar_quotation.svg' - width={18} - height={20} - /> - <p>Daftar Quotation</p> - </div> - </LinkItem> - <LinkItem href='/my/transactions' active={routeStartWith('/my/transactions')} > diff --git a/src/lib/quotation/components/Quotationheader.jsx b/src/lib/quotation/components/Quotationheader.jsx index d94a55de..6551296a 100644 --- a/src/lib/quotation/components/Quotationheader.jsx +++ b/src/lib/quotation/components/Quotationheader.jsx @@ -53,7 +53,7 @@ const Quotationheader = (quotationCount) => { }; const getCart = () => { - if (!productQuotation && auth) { + if ((productQuotation?.length === 0) && auth) { refreshCartf(); } }; @@ -62,7 +62,7 @@ const Quotationheader = (quotationCount) => { const refreshCartf = useCallback(async () => { setIsloading(true); let pendingTransactions = transactions?.data?.saleOrders.filter( - (transaction) => transaction.status === 'draft' + (transaction) => transaction.status === 'waiting' ); setProductQuotation(pendingTransactions); setCountQuotation( @@ -107,20 +107,21 @@ const Quotationheader = (quotationCount) => { }; }, []); + const handleCheckout = async () => { SetButtonTerapkan(true); let checkoutAll = await odooApi( 'POST', `/api/v1/user/${auth.id}/cart/select-all` ); - router.push('/my/quotations'); + router.push('/my/transactions'); }; return ( <div className='relative group'> <div> <Link - href='/my/quotations' + href='/my/transactions' target='_blank' rel='noreferrer' className='flex items-center gap-x-2 !text-gray_r-12/80' @@ -138,7 +139,7 @@ const Quotationheader = (quotationCount) => { <span> List <br /> - Quotation + Transactions </span> </Link> </div> @@ -168,7 +169,7 @@ const Quotationheader = (quotationCount) => { > <div className='p-2 flex justify-between items-center'> <h5 className='text-base font-semibold leading-none'> - Daftar Quotation + Daftar Transaksi </h5> </div> <hr className='mt-3 mb-3 border border-gray-100' /> @@ -183,7 +184,7 @@ const Quotationheader = (quotationCount) => { > Login </Link>{' '} - Untuk Melihat Daftar Quotation Anda + Untuk Melihat Daftar Transaksi Anda </p> </div> )} @@ -209,7 +210,7 @@ const Quotationheader = (quotationCount) => { {auth && qotation.length === 0 && !isLoading && ( <div className='justify-center p-4'> <p className='text-gray-500 text-center '> - Tidak Ada Quotation + Tidak Ada Transaksi </p> </div> )} @@ -225,7 +226,7 @@ const Quotationheader = (quotationCount) => { <li className='py-1 sm:py-2'> <div className='flex justify-between border p-2 flex-col gap-y-2 hover:border-red-500'> <Link - href={`/my/quotations/${product?.id}`} + href={`/my/transactions/${product?.id}`} className='hover:border-red-500' > <div className='flex justify-between mb-2'> @@ -241,8 +242,8 @@ const Quotationheader = (quotationCount) => { <p className='text-xs opacity-80 mr-[2px]'> Status : </p> - <p className='badge-red h-fit text-xs whitespace-nowrap'> - Pending Quotation + <p className='badge-yellow h-fit text-xs whitespace-nowrap'> + Pesanan Diterima </p> </div> </div> diff --git a/src/lib/transaction/components/Transactions.jsx b/src/lib/transaction/components/Transactions.jsx index 45821901..c4651119 100644 --- a/src/lib/transaction/components/Transactions.jsx +++ b/src/lib/transaction/components/Transactions.jsx @@ -78,6 +78,8 @@ const Transactions = ({ context = '' }) => { const [dateRange, setDateRange] = useState([null, null]); // const [startDate, endDate] = dateRange; const [isOpenCalender, setIsOpenCalender] = useState(false); + const [cachedAllData, setCachedAllData] = useState(null); // Simpan data "All" + const [currentData, setCurrentData] = useState([]); // Data yang ditampilkan const parseDate = (date) => { if (null || 'null') return null; @@ -263,7 +265,16 @@ const Transactions = ({ context = '' }) => { const getAllData = async () => { const query = { name: q, - context, + offset: (pageNew - 1) * limitNew, + limit: limitNew, + context: contextMap[statusNew], // gunakan contextMap + sort: sortNew, + startDate: state[0]?.startDate + ? state[0].startDate.toLocaleDateString('id-ID') + : null, + endDate: state[0]?.endDate + ? state[0].endDate.toLocaleDateString('id-ID') + : null, site: siteFilter || (auth?.webRole === null && auth?.site ? auth.site : null), }; @@ -345,22 +356,29 @@ const Transactions = ({ context = '' }) => { } }; - const handleStatusChange = (status) => { + + const handleStatusChange = async (status) => { setStatusNew(status); + setPageNew(1); - if (['quotation', 'cancel', 'diterima', ''].includes(status)) { - setcontextNew('quotation'); - } else { - setcontextNew(''); + if (status === 'all' && cachedAllData) { + setCurrentData(cachedAllData); + return; } - + const data = await fetchSite(status, 1); + if (status === 'all') { - router.push(`${router.pathname}`); - } else { - setPageNew(1); + setCachedAllData(data); } + + setCurrentData(data); }; + useEffect(() => { + setCachedAllData([]); + }, []); + + const handleReset = () => { setState([ { @@ -857,9 +875,7 @@ const Transactions = ({ context = '' }) => { <div className='text-justify flex flex-col gap-1'> <p className='font-bold text-black'>Info Transaksi</p> <span className='text-black'> - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed - do eiusmod tempor incididunt ut labore et dolore magna - aliqua. + Gunakan filter status untuk mempermudah pencarian transaksi anda di Daftar Transaksi </span> </div> </div> @@ -928,6 +944,86 @@ const Transactions = ({ context = '' }) => { </button> </form> </div> + <div className='flex flex-col gap-2 pb-2'> + <button + type='button' + className='form-input btn py-4 mt-1 cursor-pointer hover:bg-gray-100 rounded transition duration-150 ease-in-out text-left w-full' + onClick={() => setIsOpenCalender(true)} + > + <span className='text-nowrap px-1 truncate'> + {state[0]?.startDate + ? `${state[0].startDate.toLocaleDateString()} - ${state[0].endDate.toLocaleDateString()}` + : 'Filter By Tanggal'} + </span> + </button> + {isOpenCalender && ( + <div className='absolute mt-2 bg-white p-4 rounded shadow-lg'> + {/* Tombol silang di sudut kanan atas */} + <button + onClick={() => setIsOpenCalender(false)} + className='absolute top-2 right-2 text-gray-600 hover:text-black text-xl font-bold' + > + × + </button> + <DateRangePicker + onChange={(item) => setState([item.selection])} + showSelectionPreview={true} + maxDate={new Date()} + moveRangeOnFirstSelection={false} + months={1} + ranges={state} + className='w-full' + /> + <style>{` + /* Atur container agar menjadi column */ + .rdrCalendarWrapper { + display: flex; + flex-direction: column; + } + .rdrDateRangePickerWrapper { + display: flex; + flex-direction: column; + } + + /* Pindahkan rdrStaticRanges ke atas */ + .rdrDefinedRangesWrapper { + order: -1; + width: fit-content; + } + .rdrStaticRanges { + flex-direction: row; + margin-right: 2px; + } + + /* Sembunyikan bagian input manual */ + .rdrInputRanges { + display: none !important; + } + + .rdrStaticRangeLabel { + padding: 10px 10px; + } + .rdrMonth { + width: -moz-available; + } + `}</style> + <div className='flex flex-row justify-end gap-3 mt-2'> + <button + className='px-4 py-1 bg-gray-500 text-white rounded' + onClick={() => setIsOpenCalender(false)} + > + Done + </button> + <button + className='px-4 py-1 bg-red-500 text-white rounded' + onClick={handleReset} + > + Reset + </button> + </div> + </div> + )} + </div> <div className='flex flex-row gap-4 items-center justify-center'> <p> Menampilkan {startItem}- @@ -980,7 +1076,7 @@ const Transactions = ({ context = '' }) => { {transactions.data.saleOrders.map((saleOrder, index) => ( <div key={index} - className='border py-2 px-4 hover:border-red-500 w-full rounded-lg' + className='border py-2 px-4 hover:border-red-500 w-full rounded-lg data-item' > <Link href={`${router.pathname}/${saleOrder?.id}`} diff --git a/src/pages/my/transactions/index.jsx b/src/pages/my/transactions/index.jsx index c1fb9a67..987d851d 100644 --- a/src/pages/my/transactions/index.jsx +++ b/src/pages/my/transactions/index.jsx @@ -15,13 +15,13 @@ export default function MyTransactions() { <MobileView> <AppLayout title='Transaksi'> - <TransactionsComponent /> + <TransactionsComponent context='transactions' /> </AppLayout> </MobileView> <DesktopView> <BasicLayout> - <TransactionsComponent /> + <TransactionsComponent context='transactions' /> </BasicLayout> </DesktopView> </IsAuth> |
