From e6feac8e6ce2ea3c428d4307251634708b676c25 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Wed, 23 Aug 2023 17:03:23 +0700 Subject: page daftar pengiriman --- src/lib/shipment/api/listShipment.js | 9 ++ src/lib/shipment/components/Shipments.jsx | 219 ++++++++++++++++++++++++++++++ 2 files changed, 228 insertions(+) create mode 100644 src/lib/shipment/api/listShipment.js create mode 100644 src/lib/shipment/components/Shipments.jsx (limited to 'src/lib/shipment') diff --git a/src/lib/shipment/api/listShipment.js b/src/lib/shipment/api/listShipment.js new file mode 100644 index 00000000..a9237b76 --- /dev/null +++ b/src/lib/shipment/api/listShipment.js @@ -0,0 +1,9 @@ +import odooApi from "@/core/api/odooApi"; +import { getAuth } from "@/core/utils/auth" + +export const listShipments = async ({query}) => { + const auth = getAuth() + const list = await odooApi('GET', `/api/v1/partner/${auth.partnerId}/stock-picking?${query}`) + + return list; +} diff --git a/src/lib/shipment/components/Shipments.jsx b/src/lib/shipment/components/Shipments.jsx new file mode 100644 index 00000000..eb14c77f --- /dev/null +++ b/src/lib/shipment/components/Shipments.jsx @@ -0,0 +1,219 @@ +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 ImageNext from 'next/image' +import { useRouter } from 'next/router' +import { useQuery } from 'react-query' +import _ from 'lodash-contrib' +import Spinner from '@/core/components/elements/Spinner/Spinner' +import Manifest from '@/lib/treckingAwb/component/Manifest' +import { useState } from 'react' + +const { listShipments } = require('../api/listShipment') + +const Shipments = () => { + const router = useRouter() + const { q = '', page = 1 } = router.query + + const limit = 15 + + const query = { + name: q, + offset: (page - 1) * limit, + limit + } + + const queryString = _.toQuery(query) + + const { data: shipments } = useQuery('shipments', () => listShipments({ query: queryString })) + const [ idAWB, setIdAWB ] = useState(null) + + const closePopup = () => { + setIdAWB(null) + } + + const handleSubmit = async () => {} + return ( + <> + +
+
+
+
+ +
+

Pending

+

99 {'>'}

+
+
+
+ +
+

Pengiriman

+

99 {'>'}

+
+
+
+ +
+

Selesai

+

99 {'>'}

+
+
+ +
+ setInputQuery(e.target.value)} + /> + +
+
+
+ +
+
+ +
+
+
+

Pengiriman

+ +
+
+

Pending

+
+
+ +
+
+

+ {shipments?.summary?.pendingCount} Pesanan +

+
+
+
Pengiriman
+
+
+ +
+
+

+ {shipments?.summary?.shipmentCount} Pesanan +

+
+
+
Pesanan Tiba
+
+
+ +
+
+

+ {shipments?.summary?.completedCount} Pesanan +

+
+
+
+
+
+

Detail Pengiriman

+
+ setInputQuery(e.target.value)} + /> + +
+
+ + + + + + + + + + + + + + {!shipments && ( + + + + )} + {shipments && shipments?.pickings?.length == 0 && ( + + + + )} + {shipments?.pickings.map((shipment) => ( + + + + + + + + + + ))} + +
TanggalNo. ResiNo. PengirimanSales OrderPurchase OrderExpedisiStatus
+
+ +
+
Tidak ada transaksi
{shipment.date || '-'}{shipment.trackingNumber || '-'}{shipment.name || '-'}{shipment.saleOrder.name || '-'}{shipment.saleOrder.clientOrderRef || '-'}{shipment.carrierName || '-'} + +
+
+
+
+ +
+ + ) +} + +export default Shipments -- cgit v1.2.3 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 From 0dab223d410e1c6011bfb4e1e850dfe566c8d044 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Tue, 29 Aug 2023 14:11:23 +0700 Subject: add params etd di checkout --- src/lib/shipment/components/Shipments.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/lib/shipment') diff --git a/src/lib/shipment/components/Shipments.jsx b/src/lib/shipment/components/Shipments.jsx index d62afcb7..c9d3e627 100644 --- a/src/lib/shipment/components/Shipments.jsx +++ b/src/lib/shipment/components/Shipments.jsx @@ -144,8 +144,8 @@ const Shipments = () => { onClick={() => setIdAWB(shipment.id)} className='flex items-center mt-1 gap-x-1 min-w-full' > - -

+ +

{shipment.lastManifest.description}

{'>'}

-- cgit v1.2.3