From 60f0b9d33335719b15f60f4b99bd80a48b7da346 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Mon, 28 Aug 2023 16:55:26 +0700 Subject: add icon menu sidebar, add pagination --- src/lib/shipment/components/Shipments.jsx | 122 ++++++++++++++++++++++++++---- 1 file changed, 109 insertions(+), 13 deletions(-) (limited to 'src/lib/shipment') diff --git a/src/lib/shipment/components/Shipments.jsx b/src/lib/shipment/components/Shipments.jsx index eb14c77f..d62afcb7 100644 --- a/src/lib/shipment/components/Shipments.jsx +++ b/src/lib/shipment/components/Shipments.jsx @@ -1,7 +1,7 @@ import DesktopView from '@/core/components/views/DesktopView' import MobileView from '@/core/components/views/MobileView' import Menu from '@/lib/auth/components/Menu' -import { MagnifyingGlassIcon } from '@heroicons/react/24/outline' +import { EllipsisVerticalIcon, MagnifyingGlassIcon } from '@heroicons/react/24/outline' import ImageNext from 'next/image' import { useRouter } from 'next/router' import { useQuery } from 'react-query' @@ -9,6 +9,9 @@ import _ from 'lodash-contrib' import Spinner from '@/core/components/elements/Spinner/Spinner' import Manifest from '@/lib/treckingAwb/component/Manifest' import { useState } from 'react' +import Pagination from '@/core/components/elements/Pagination/Pagination' +import Link from 'next/link' +import TransactionStatusBadge from '@/lib/transaction/components/TransactionStatusBadge' const { listShipments } = require('../api/listShipment') @@ -19,21 +22,30 @@ const Shipments = () => { const limit = 15 const query = { - name: q, + q: q, offset: (page - 1) * limit, limit } - + console.log('ini query', query) + const [inputQuery, setInputQuery] = useState(q) const queryString = _.toQuery(query) const { data: shipments } = useQuery('shipments', () => listShipments({ query: queryString })) - const [ idAWB, setIdAWB ] = useState(null) + const [idAWB, setIdAWB] = useState(null) + + const pageCount = Math.ceil(shipments?.pickingTotal / limit) + let pageQuery = _.omit(query, ['limit', 'offset', 'context']) + pageQuery = _.pickBy(pageQuery, _.identity) + pageQuery = _.toQuery(pageQuery) const closePopup = () => { setIdAWB(null) } - const handleSubmit = async () => {} + const handleSubmit = async (e) => { + e.preventDefault() + router.push(`${router.pathname}?q=${inputQuery}`) + } return ( <> @@ -44,21 +56,30 @@ const Shipments = () => {

Pending

-

99 {'>'}

+

+ {' '} + {shipments?.summary?.pendingCount} {'>'} +

- +

Pengiriman

-

99 {'>'}

+

+ {' '} + {shipments?.summary?.shipmentCount} {'>'} +

Selesai

-

99 {'>'}

+

+ {' '} + {shipments?.summary?.shipmentCount} {'>'} +

@@ -67,14 +88,80 @@ const Shipments = () => { type='text' className='form-input' placeholder='Cari Pengiriman...' - value='' + value={inputQuery} onChange={(e) => setInputQuery(e.target.value)} /> + + {shipments?.pickings.map((shipment) => ( +
+
+
+

+ Kurir :{' '} + + {shipment.carrierName || '-'} + +

+

No. Resi : {shipment.trackingNumber || '-'}

+
+
+ {shipment?.delivered && ( +
+

Pesanan Tiba

+
+ )} + {!shipment?.delivered && ( +
+

Sedang Dikirim

+
+ )} +
+
+
+
+
+ No. Transaksi + +

{shipment.saleOrder.name}

+ + {shipment.date} +
+
+ +
+
+
+ +
+ ))} + + + +
@@ -155,7 +242,7 @@ const Shipments = () => { type='text' className='form-input' placeholder='Cari Pengiriman...' - value='' + value={inputQuery} onChange={(e) => setInputQuery(e.target.value)} /> @@ -207,10 +297,16 @@ const Shipments = () => { ))} +
- +
) -- cgit v1.2.3