From 4d021a4634a6bc84ee25f0d43cbc6450d94265f0 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Mon, 31 Jul 2023 14:08:34 +0700 Subject: google sing up --- src/lib/auth/components/LoginDesktop.jsx | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/lib') diff --git a/src/lib/auth/components/LoginDesktop.jsx b/src/lib/auth/components/LoginDesktop.jsx index 8ce2e4e3..74d259a8 100644 --- a/src/lib/auth/components/LoginDesktop.jsx +++ b/src/lib/auth/components/LoginDesktop.jsx @@ -3,11 +3,15 @@ import useLogin from '../hooks/useLogin' import Link from '@/core/components/elements/Link/Link' import PageContent from '@/lib/content/components/PageContent' import Alert from '@/core/components/elements/Alert/Alert' +import {useSession, signIn, SignOut} from 'next-auth/react' const LoginDesktop = () => { const { handleSubmit, handleChangeInput, isLoading, isValid, alert, emailRef, passwordRef } = useLogin() + const {data : session } = useSession + console.log('ini google', session) + return (
@@ -60,6 +64,13 @@ const LoginDesktop = () => { {!isLoading ? 'Masuk' : 'Loading...'} +
Belum punya akun Indoteknik?{' '} -- cgit v1.2.3 From 4cfe9157d64a76bf9913fe599d908497a18f5316 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Wed, 9 Aug 2023 10:45:53 +0700 Subject: google sign in --- src/lib/auth/components/LoginDesktop.jsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/lib') diff --git a/src/lib/auth/components/LoginDesktop.jsx b/src/lib/auth/components/LoginDesktop.jsx index 74d259a8..f5aa0018 100644 --- a/src/lib/auth/components/LoginDesktop.jsx +++ b/src/lib/auth/components/LoginDesktop.jsx @@ -9,8 +9,8 @@ const LoginDesktop = () => { const { handleSubmit, handleChangeInput, isLoading, isValid, alert, emailRef, passwordRef } = useLogin() - const {data : session } = useSession - console.log('ini google', session) + const { data } = useSession() + console.log('ini google', data) return ( @@ -66,10 +66,10 @@ const LoginDesktop = () => {
-- cgit v1.2.3 From 01e86fb4a54b801a9b8124455611c312e5de4af0 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Mon, 14 Aug 2023 15:04:45 +0700 Subject: google sign in --- src/lib/auth/components/LoginDesktop.jsx | 66 +++++++++++++++++++++++++++----- src/lib/auth/components/LoginMobile.jsx | 32 ++++++++++++++++ 2 files changed, 89 insertions(+), 9 deletions(-) (limited to 'src/lib') diff --git a/src/lib/auth/components/LoginDesktop.jsx b/src/lib/auth/components/LoginDesktop.jsx index f5aa0018..e3bff492 100644 --- a/src/lib/auth/components/LoginDesktop.jsx +++ b/src/lib/auth/components/LoginDesktop.jsx @@ -3,15 +3,50 @@ import useLogin from '../hooks/useLogin' import Link from '@/core/components/elements/Link/Link' import PageContent from '@/lib/content/components/PageContent' import Alert from '@/core/components/elements/Alert/Alert' -import {useSession, signIn, SignOut} from 'next-auth/react' +import { useSession, signIn, SignOut } from 'next-auth/react' +import Image from 'next/image' +import { useRouter } from 'next/router' +import { useEffect, useState } from 'react' +import Spinner from '@/core/components/elements/Spinner/Spinner' const LoginDesktop = () => { const { handleSubmit, handleChangeInput, isLoading, isValid, alert, emailRef, passwordRef } = useLogin() - const { data } = useSession() - console.log('ini google', data) + const router = useRouter() + const [query, setQuery] = useState(router?.query?.next || '/') + const { data: session } = useSession() + const [googleLoading, setGoogleloading] = useState(true) + useEffect(() => { + // Simulate loading for 2 seconds + const delay = setTimeout(() => { + setGoogleloading(false); + }, 3000); + + return () => { + clearTimeout(delay); // Clear the timeout if the component unmounts + }; + }, []); + + + const handleGoogle = async () => { + await signIn('google', { callbackUrl: '/login' }) + } + + useEffect(() => { + if (session) { + router.push(query) + } + }, [session, query]) + + if (googleLoading) { + return ( +
+ +
+ ) + } return (
@@ -64,13 +99,26 @@ const LoginDesktop = () => { {!isLoading ? 'Masuk' : 'Loading...'} +
+
+

ATAU

+
+
+ + type='submit' + className='border border-gray-500 p-2 rounded-md hover:bg-gray-100 w-full mt-2 flex items-center justify-center gap-x-2' + onClick={() => handleGoogle()} + > + google image +

Masuk dengan Google

+
Belum punya akun Indoteknik?{' '} diff --git a/src/lib/auth/components/LoginMobile.jsx b/src/lib/auth/components/LoginMobile.jsx index b365330b..c5177625 100644 --- a/src/lib/auth/components/LoginMobile.jsx +++ b/src/lib/auth/components/LoginMobile.jsx @@ -5,10 +5,22 @@ import Alert from '@/core/components/elements/Alert/Alert' import MobileView from '@/core/components/views/MobileView' import useLogin from '../hooks/useLogin' +import { useSession, signIn, SignOut } from 'next-auth/react' +import { useRouter } from 'next/router' +import { useState } from 'react' + const LoginMobile = () => { const { handleSubmit, handleChangeInput, isLoading, isValid, alert, emailRef, passwordRef } = useLogin() + const router = useRouter() + const [query, setQuery] = useState(router?.query?.next || '/') + const { data: session } = useSession() + + if (session) { + router.push(query) + } + return (
@@ -56,6 +68,26 @@ const LoginMobile = () => { {!isLoading ? 'Masuk' : 'Loading...'} +
+
+

ATAU

+
+
+ +
Belum punya akun Indoteknik?{' '} -- cgit v1.2.3 From 9a33f3a391a402807cc5e7913b1a97e430a7aaa2 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Tue, 15 Aug 2023 15:16:38 +0700 Subject: sign in --- src/lib/auth/components/LoginDesktop.jsx | 35 +++++++++----------------------- 1 file changed, 10 insertions(+), 25 deletions(-) (limited to 'src/lib') diff --git a/src/lib/auth/components/LoginDesktop.jsx b/src/lib/auth/components/LoginDesktop.jsx index e3bff492..06c90d45 100644 --- a/src/lib/auth/components/LoginDesktop.jsx +++ b/src/lib/auth/components/LoginDesktop.jsx @@ -6,8 +6,10 @@ import Alert from '@/core/components/elements/Alert/Alert' import { useSession, signIn, SignOut } from 'next-auth/react' import Image from 'next/image' import { useRouter } from 'next/router' -import { useEffect, useState } from 'react' +import { useContext, useEffect, useState } from 'react' import Spinner from '@/core/components/elements/Spinner/Spinner' +import { AuthContext } from '@/pages/_app' +import { getAuth, setAuth } from '@/core/utils/auth' const LoginDesktop = () => { const { handleSubmit, handleChangeInput, isLoading, isValid, alert, emailRef, passwordRef } = @@ -16,37 +18,20 @@ const LoginDesktop = () => { const router = useRouter() const [query, setQuery] = useState(router?.query?.next || '/') const { data: session } = useSession() - const [googleLoading, setGoogleloading] = useState(true) - - useEffect(() => { - // Simulate loading for 2 seconds - const delay = setTimeout(() => { - setGoogleloading(false); - }, 3000); - - return () => { - clearTimeout(delay); // Clear the timeout if the component unmounts - }; - }, []); - + const auth = getAuth() + const { setAuthenticated } = useContext(AuthContext) const handleGoogle = async () => { - await signIn('google', { callbackUrl: '/login' }) + const url = query != '/' ? '/login?next=' + query : '/login' + await signIn('google', { callbackUrl: url }) } useEffect(() => { - if (session) { - router.push(query) + if (session || auth) { + setAuthenticated(session ? session.odooUser : auth) } - }, [session, query]) + }, [session]) - if (googleLoading) { - return ( -
- -
- ) - } return (
-- cgit v1.2.3 From f01f28a7eac76c6da5bf857bfc80fd347586ce7f Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Wed, 16 Aug 2023 09:39:47 +0700 Subject: register google --- src/lib/auth/components/LoginDesktop.jsx | 11 ++++---- src/lib/auth/components/LoginMobile.jsx | 17 ++++++++++--- src/lib/auth/components/RegisterDesktop.jsx | 39 +++++++++++++++++++++++++++++ src/lib/auth/components/RegisterMobile.jsx | 39 +++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 10 deletions(-) (limited to 'src/lib') diff --git a/src/lib/auth/components/LoginDesktop.jsx b/src/lib/auth/components/LoginDesktop.jsx index 06c90d45..3a7477b9 100644 --- a/src/lib/auth/components/LoginDesktop.jsx +++ b/src/lib/auth/components/LoginDesktop.jsx @@ -7,9 +7,8 @@ import { useSession, signIn, SignOut } from 'next-auth/react' import Image from 'next/image' import { useRouter } from 'next/router' import { useContext, useEffect, useState } from 'react' -import Spinner from '@/core/components/elements/Spinner/Spinner' -import { AuthContext } from '@/pages/_app' import { getAuth, setAuth } from '@/core/utils/auth' +import { setCookie } from 'cookies-next' const LoginDesktop = () => { const { handleSubmit, handleChangeInput, isLoading, isValid, alert, emailRef, passwordRef } = @@ -19,7 +18,6 @@ const LoginDesktop = () => { const [query, setQuery] = useState(router?.query?.next || '/') const { data: session } = useSession() const auth = getAuth() - const { setAuthenticated } = useContext(AuthContext) const handleGoogle = async () => { const url = query != '/' ? '/login?next=' + query : '/login' @@ -27,10 +25,11 @@ const LoginDesktop = () => { } useEffect(() => { - if (session || auth) { - setAuthenticated(session ? session.odooUser : auth) + if(session){ + setCookie('auth', JSON.stringify(session?.odooUser)) + router.push(query) } - }, [session]) + },[session]) return ( diff --git a/src/lib/auth/components/LoginMobile.jsx b/src/lib/auth/components/LoginMobile.jsx index c5177625..68ceb769 100644 --- a/src/lib/auth/components/LoginMobile.jsx +++ b/src/lib/auth/components/LoginMobile.jsx @@ -7,7 +7,8 @@ import useLogin from '../hooks/useLogin' import { useSession, signIn, SignOut } from 'next-auth/react' import { useRouter } from 'next/router' -import { useState } from 'react' +import { useEffect, useState } from 'react' +import { setCookie } from 'cookies-next' const LoginMobile = () => { const { handleSubmit, handleChangeInput, isLoading, isValid, alert, emailRef, passwordRef } = @@ -17,9 +18,17 @@ const LoginMobile = () => { const [query, setQuery] = useState(router?.query?.next || '/') const { data: session } = useSession() - if (session) { - router.push(query) + const handleGoogle = async () => { + const url = query != '/' ? '/login?next=' + query : '/login' + await signIn('google', { callbackUrl: url }) + setCookie('auth', JSON.stringify(session?.odooUser)) } + useEffect(() => { + if (session) { + setCookie('auth', JSON.stringify(session?.odooUser)) + router.push(query) + } + }, [session]) return ( @@ -77,7 +86,7 @@ const LoginMobile = () => {
+
+
+

ATAU

+
+
+ +
Sudah punya akun Indoteknik?{' '} diff --git a/src/lib/auth/components/RegisterMobile.jsx b/src/lib/auth/components/RegisterMobile.jsx index da6efaf5..c21c9325 100644 --- a/src/lib/auth/components/RegisterMobile.jsx +++ b/src/lib/auth/components/RegisterMobile.jsx @@ -7,6 +7,10 @@ import MobileView from '@/core/components/views/MobileView' import BottomPopup from '@/core/components/elements/Popup/BottomPopup' import PageContent from '@/lib/content/components/PageContent' import ReCAPTCHA from 'react-google-recaptcha' +import { signIn, useSession } from 'next-auth/react' +import { useRouter } from 'next/router' +import { setCookie } from 'cookies-next' +import { useEffect } from 'react' const RegisterMobile = () => { const { @@ -24,6 +28,20 @@ const RegisterMobile = () => { setTnd } = useRegister() + const { data: session } = useSession() + const router = useRouter() + + const handleGoogle = async () => { + await signIn('google', { callbackUrl: '/register' }) + } + + useEffect(() => { + if(session){ + setCookie('auth', JSON.stringify(session?.odooUser)) + router.push('/') + } + },[session]) + return (
@@ -122,6 +140,27 @@ const RegisterMobile = () => {
+
+
+

ATAU

+
+
+ + +
Sudah punya akun Indoteknik?{' '} -- cgit v1.2.3 From b6f6bf23f90ff0dfadf9bf0af8866c2cfc17aa9c Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Fri, 18 Aug 2023 11:02:39 +0700 Subject: handling redirect login --- src/lib/auth/components/LoginDesktop.jsx | 28 ++++++++++++++++++++-------- src/lib/auth/components/LoginMobile.jsx | 24 +++++++++++++++++++----- src/lib/auth/components/RegisterDesktop.jsx | 14 +++++++++++++- src/lib/auth/components/RegisterMobile.jsx | 13 ++++++++++++- src/lib/auth/hooks/useLogin.js | 19 ++++++++++++++++++- 5 files changed, 82 insertions(+), 16 deletions(-) (limited to 'src/lib') diff --git a/src/lib/auth/components/LoginDesktop.jsx b/src/lib/auth/components/LoginDesktop.jsx index 3a7477b9..42fa8896 100644 --- a/src/lib/auth/components/LoginDesktop.jsx +++ b/src/lib/auth/components/LoginDesktop.jsx @@ -9,27 +9,39 @@ import { useRouter } from 'next/router' import { useContext, useEffect, useState } from 'react' import { getAuth, setAuth } from '@/core/utils/auth' import { setCookie } from 'cookies-next' +import BottomPopup from '@/core/components/elements/Popup/BottomPopup' +import Spinner from '@/core/components/elements/Spinner/Spinner' +import LogoSpinner from '@/core/components/elements/Spinner/LogoSpinner' +import odooApi from '@/core/api/odooApi' const LoginDesktop = () => { - const { handleSubmit, handleChangeInput, isLoading, isValid, alert, emailRef, passwordRef } = + const { handleSubmit, handleChangeInput, isLoading, isValid, alert, emailRef, passwordRef, handleGoogleSubmit } = useLogin() const router = useRouter() const [query, setQuery] = useState(router?.query?.next || '/') const { data: session } = useSession() - const auth = getAuth() const handleGoogle = async () => { - const url = query != '/' ? '/login?next=' + query : '/login' + const url = query != '/' ? '/login?source=google&next=' + query : '/login?source=google' await signIn('google', { callbackUrl: url }) } - useEffect(() => { - if(session){ - setCookie('auth', JSON.stringify(session?.odooUser)) - router.push(query) + if (session) { + handleGoogleSubmit(session) } - },[session]) + }, [session]) + + if (router.query.source) { + return ( + +
Mohon Tunggu
+
+ +
+
+ ) + } return ( diff --git a/src/lib/auth/components/LoginMobile.jsx b/src/lib/auth/components/LoginMobile.jsx index 68ceb769..095f4174 100644 --- a/src/lib/auth/components/LoginMobile.jsx +++ b/src/lib/auth/components/LoginMobile.jsx @@ -9,27 +9,41 @@ import { useSession, signIn, SignOut } from 'next-auth/react' import { useRouter } from 'next/router' import { useEffect, useState } from 'react' import { setCookie } from 'cookies-next' +import BottomPopup from '@/core/components/elements/Popup/BottomPopup' +import LogoSpinner from '@/core/components/elements/Spinner/LogoSpinner' +import odooApi from '@/core/api/odooApi' +import { getAuth } from '@/core/utils/auth' const LoginMobile = () => { - const { handleSubmit, handleChangeInput, isLoading, isValid, alert, emailRef, passwordRef } = + const { handleSubmit, handleChangeInput, isLoading, isValid, alert, emailRef, passwordRef, handleGoogleSubmit } = useLogin() const router = useRouter() const [query, setQuery] = useState(router?.query?.next || '/') const { data: session } = useSession() + const auth = getAuth() const handleGoogle = async () => { - const url = query != '/' ? '/login?next=' + query : '/login' + const url = query != '/' ? '/login?source=google&next=' + query : '/login?source=google' await signIn('google', { callbackUrl: url }) - setCookie('auth', JSON.stringify(session?.odooUser)) } useEffect(() => { if (session) { - setCookie('auth', JSON.stringify(session?.odooUser)) - router.push(query) + handleGoogleSubmit(session) } }, [session]) + if (router.query.source) { + return ( + +
Mohon Tunggu
+
+ +
+
+ ) + } + return (
diff --git a/src/lib/auth/components/RegisterDesktop.jsx b/src/lib/auth/components/RegisterDesktop.jsx index 86a5027d..a2bc98c2 100644 --- a/src/lib/auth/components/RegisterDesktop.jsx +++ b/src/lib/auth/components/RegisterDesktop.jsx @@ -10,6 +10,7 @@ import { useEffect } from 'react' import { setCookie } from 'cookies-next' import { signIn, useSession } from 'next-auth/react' import { useRouter } from 'next/router' +import LogoSpinner from '@/core/components/elements/Spinner/LogoSpinner' const RegisterDesktop = () => { const { @@ -31,7 +32,7 @@ const RegisterDesktop = () => { const router = useRouter() const handleGoogle = async () => { - await signIn('google', { callbackUrl: '/register' }) + await signIn('google', { callbackUrl: '/register?source=google' }) } useEffect(() => { @@ -41,6 +42,17 @@ const RegisterDesktop = () => { } },[session]) + if (router.query.source) { + return ( + +
Mohon Tunggu
+
+ +
+
+ ) + } + return (
diff --git a/src/lib/auth/components/RegisterMobile.jsx b/src/lib/auth/components/RegisterMobile.jsx index c21c9325..2e918a14 100644 --- a/src/lib/auth/components/RegisterMobile.jsx +++ b/src/lib/auth/components/RegisterMobile.jsx @@ -11,6 +11,7 @@ import { signIn, useSession } from 'next-auth/react' import { useRouter } from 'next/router' import { setCookie } from 'cookies-next' import { useEffect } from 'react' +import LogoSpinner from '@/core/components/elements/Spinner/LogoSpinner' const RegisterMobile = () => { const { @@ -32,7 +33,7 @@ const RegisterMobile = () => { const router = useRouter() const handleGoogle = async () => { - await signIn('google', { callbackUrl: '/register' }) + await signIn('google', { callbackUrl: '/register?source=google' }) } useEffect(() => { @@ -42,6 +43,16 @@ const RegisterMobile = () => { } },[session]) + if (router.query.source) { + return ( + +
Mohon Tunggu
+
+ +
+
+ ) + } return (
diff --git a/src/lib/auth/hooks/useLogin.js b/src/lib/auth/hooks/useLogin.js index 1d5ff43d..34605614 100644 --- a/src/lib/auth/hooks/useLogin.js +++ b/src/lib/auth/hooks/useLogin.js @@ -3,6 +3,9 @@ import { setAuth } from '@/core/utils/auth' import { useRouter } from 'next/router' import { useRef, useState } from 'react' import loginApi from '../api/loginApi' +import odooApi from '@/core/api/odooApi' +import { setCookie } from 'cookies-next' +import { useSession } from 'next-auth/react' const useLogin = () => { const router = useRouter() @@ -60,6 +63,19 @@ const useLogin = () => { } } + const handleGoogleSubmit = async (session) => { + const params = { + access_token: session.accessToken + } + const data = await odooApi('POST', '/api/v1/user/validate-sso', params) + if (data.isAuth) { + session.odooUser = data.user + setCookie('auth', JSON.stringify(session?.odooUser)) + router.push(router?.query?.next ?? '/') + return + } + } + return { handleChangeInput, handleSubmit, @@ -67,7 +83,8 @@ const useLogin = () => { isValid, alert, emailRef, - passwordRef + passwordRef, + handleGoogleSubmit } } -- cgit v1.2.3 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/auth/components/Menu.jsx | 3 + src/lib/shipment/api/listShipment.js | 9 ++ src/lib/shipment/components/Shipments.jsx | 219 +++++++++++++++++++++++++++++ src/lib/treckingAwb/api/getManifest.js | 0 src/lib/treckingAwb/component/Manifest.jsx | 72 ++++++++++ 5 files changed, 303 insertions(+) create mode 100644 src/lib/shipment/api/listShipment.js create mode 100644 src/lib/shipment/components/Shipments.jsx create mode 100644 src/lib/treckingAwb/api/getManifest.js create mode 100644 src/lib/treckingAwb/component/Manifest.jsx (limited to 'src/lib') diff --git a/src/lib/auth/components/Menu.jsx b/src/lib/auth/components/Menu.jsx index 386b817c..e54992be 100644 --- a/src/lib/auth/components/Menu.jsx +++ b/src/lib/auth/components/Menu.jsx @@ -15,6 +15,9 @@ const Menu = () => { Daftar Transaksi + + Daftar Pengiriman + Invoice & Faktur Pajak 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 diff --git a/src/lib/treckingAwb/api/getManifest.js b/src/lib/treckingAwb/api/getManifest.js new file mode 100644 index 00000000..e69de29b diff --git a/src/lib/treckingAwb/component/Manifest.jsx b/src/lib/treckingAwb/component/Manifest.jsx new file mode 100644 index 00000000..b8ad78c4 --- /dev/null +++ b/src/lib/treckingAwb/component/Manifest.jsx @@ -0,0 +1,72 @@ +import BottomPopup from '@/core/components/elements/Popup/BottomPopup' +import { useState } from 'react' + +const Manifest = ({ idAWB, closePopup }) => { + console.log('ini adalah', idAWB) + const airway = { + waybillNumber: '1234', + deliveryOrder: { + name: 'name', + carrier: 'carrier' + }, + manifests: [ + { + datetime: '12/12/2023', + description: 'ini descripsi' + } + ] + } + return ( + <> + +
+
+
No Pengiriman
+
{airway?.deliveryOrder?.name}
+
+
+
Kurir
+
{airway?.deliveryOrder?.carrier}
+
+
+
No Resi
+
{airway?.waybillNumber}
+
+
+ +
+
Status Pengiriman
+
    + {airway?.manifests?.map((manifest, index) => ( +
  1. +
    + +

    + {manifest.description} +

    +
  2. + ))} + {(!airway?.manifests || airway?.manifests?.length == 0) && ( +
    Belum ada pengiriman
    + )} +
+
+
+ + ) +} + +export default Manifest -- 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/auth/components/Menu.jsx | 49 +++++-- src/lib/shipment/components/Shipments.jsx | 122 ++++++++++++++-- src/lib/treckingAwb/api/getManifest.js | 9 ++ src/lib/treckingAwb/component/Manifest.jsx | 217 +++++++++++++++++++++-------- 4 files changed, 318 insertions(+), 79 deletions(-) (limited to 'src/lib') diff --git a/src/lib/auth/components/Menu.jsx b/src/lib/auth/components/Menu.jsx index e54992be..939a0d5f 100644 --- a/src/lib/auth/components/Menu.jsx +++ b/src/lib/auth/components/Menu.jsx @@ -1,5 +1,6 @@ import Link from '@/core/components/elements/Link/Link' import { useRouter } from 'next/router' +import ImageNext from 'next/image' const Menu = () => { const router = useRouter() @@ -10,33 +11,61 @@ const Menu = () => {
Menu
- Daftar Quotation +
+ +

Daftar Quotation

+
- Daftar Transaksi +
+ +

Daftar Transaksi

+
- Daftar Pengiriman +
+ +

Daftar Pengiriman

+
- Invoice & Faktur Pajak +
+ +

Invoice & Faktur Pajak

+
- Wishlist +
+ +

Wishlist

+
-
Pusat Bantuan
- Layanan Pelanggan + +
+ +

Layanan Pelanggan

+
+
Pengaturan Akun
- Daftar Alamat +
+ +

Daftar Alamat

+
- Profil Saya +
+ +

Profil Saya

+
) 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 = () => { ))} +
- + ) diff --git a/src/lib/treckingAwb/api/getManifest.js b/src/lib/treckingAwb/api/getManifest.js index e69de29b..7d78a5f2 100644 --- a/src/lib/treckingAwb/api/getManifest.js +++ b/src/lib/treckingAwb/api/getManifest.js @@ -0,0 +1,9 @@ +const { default: odooApi } = require("@/core/api/odooApi") +const { getAuth } = require("@/core/utils/auth") + +export const getManifest = async ({id}) => { + const auth = getAuth() + const manifest = await odooApi('GET', `/api/v1/partner/${auth.partnerId}/stock-picking/${id}/tracking`) + + return manifest +} \ No newline at end of file diff --git a/src/lib/treckingAwb/component/Manifest.jsx b/src/lib/treckingAwb/component/Manifest.jsx index b8ad78c4..185a9d55 100644 --- a/src/lib/treckingAwb/component/Manifest.jsx +++ b/src/lib/treckingAwb/component/Manifest.jsx @@ -1,70 +1,175 @@ +import odooApi from '@/core/api/odooApi' import BottomPopup from '@/core/components/elements/Popup/BottomPopup' -import { useState } from 'react' +import LogoSpinner from '@/core/components/elements/Spinner/LogoSpinner' +import { getAuth } from '@/core/utils/auth' +import { useEffect, useState } from 'react' +import { toast } from 'react-hot-toast' +import ImageNext from 'next/image' const Manifest = ({ idAWB, closePopup }) => { - console.log('ini adalah', idAWB) - const airway = { - waybillNumber: '1234', - deliveryOrder: { - name: 'name', - carrier: 'carrier' - }, - manifests: [ - { - datetime: '12/12/2023', - description: 'ini descripsi' - } + const [manifests, setManifests] = useState(null) + const [isLoading, setIsLoading] = useState(false) + + const formatCustomDate = (date) => { + const months = [ + 'Jan', + 'Feb', + 'Mar', + 'Apr', + 'May', + 'Jun', + 'Jul', + 'Aug', + 'Sep', + 'Oct', + 'Nov', + 'Dec' ] + + const parts = date.split(' ') // Pisahkan tanggal dan waktu + const [datePart, timePart] = parts + const [yyyy, mm, dd] = datePart.split('-') + const [hh, min] = timePart.split(':') + + const monthAbbreviation = months[parseInt(mm, 10) - 1] + + return `${dd} ${monthAbbreviation} ${hh}:${min}` + } + + const getManifest = async () => { + setIsLoading(true) + const auth = getAuth() + const list = await odooApi( + 'GET', + `/api/v1/partner/${auth.partnerId}/stock-picking/${idAWB}/tracking` + ) + setManifests(list) + setIsLoading(false) + } + + useEffect(() => { + if (idAWB) { + getManifest() + } else { + setManifests(null) + } + }, [idAWB]) + + const [copied, setCopied] = useState(false) + + const handleCopyClick = () => { + const textToCopy = manifests?.waybillNumber + navigator.clipboard.writeText(textToCopy) + setCopied(true) + toast.success('No Resi Berhasil di Copy') + setTimeout(() => setCopied(false), 2000) // Reset copied state after 2 seconds } + return ( <> - -
-
-
No Pengiriman
-
{airway?.deliveryOrder?.name}
+ {isLoading && ( + +
Mohon Tunggu
+
+
-
-
Kurir
-
{airway?.deliveryOrder?.carrier}
+ + )} + {!isLoading && ( + +
+

Status Pesanan

+ {manifests?.delivered && ( +
+

Pesanan Tiba

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

Sedang Dikirim

+
+ )}
-
-
No Resi
-
{airway?.waybillNumber}
+
+

+ Estimasi tiba pada ({manifests?.eta}) +

+

+ Dikirim Menggunakan{' '} + {manifests?.deliveryOrder.carrier} +

+ {manifests?.waybillNumber && ( +
+

No. Resi

+
+

{manifests?.waybillNumber}

+ +
+
+ )}
-
+
+
+
    + {manifests?.manifests?.map((manifest, index) => ( + <> +
  1. + {manifests.delivered == true && index == 0 ? ( +
    + +
    + ) : ( +
    + )} + {manifests.delivered != true && ( +
    + )} -
    -
    Status Pengiriman
    -
      - {airway?.manifests?.map((manifest, index) => ( -
    1. -
      - -

      - {manifest.description} -

      -
    2. - ))} - {(!airway?.manifests || airway?.manifests?.length == 0) && ( -
      Belum ada pengiriman
      - )} -
    -
    - + + {manifests.delivered == true && index == 0 && ( +

    Sudah Sampai

    + )} +

    {manifest.description}

    +
  2. + + ))} +
+
+
+ )} ) } -- 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/checkout/components/Checkout.jsx | 18 ++++++++++++++++++ src/lib/shipment/components/Shipments.jsx | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'src/lib') diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index afb94c10..0eb05345 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -297,10 +297,12 @@ const Checkout = () => { order_line: JSON.stringify(productOrder), delivery_amount: biayaKirim, carrier_id: selectedCarrierId, + estimated_arrival_days: splitDuration(etd), delivery_service_type: selectedExpedisiService, voucher: activeVoucher, type: 'sale_order' } + if (query) { data.source = 'buy' } @@ -1444,6 +1446,22 @@ function calculateEstimatedArrival(duration) { return '' } +function splitDuration(duration){ + if (duration) { + let estimationDate = null + if (duration.includes('-')){ + estimationDate = duration.split('-') + estimationDate = parseInt(estimationDate[1]) + }else{ + estimationDate = parseInt(duration) + } + + return estimationDate + } + + return '' +} + const extractDuration = (text) => { const matches = text.match(/\d+(?:-\d+)?/g) 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 From a08c6f9a773732c959e440dbcc653a6e80045e81 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Wed, 30 Aug 2023 15:29:52 +0700 Subject: change popup tracking history di page daftart transaksi dan quotation --- src/lib/transaction/components/Transaction.jsx | 53 ++++++++++++++++---------- 1 file changed, 32 insertions(+), 21 deletions(-) (limited to 'src/lib') diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index 74f3dbd5..82eb1775 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -21,6 +21,7 @@ import Image from '@/core/components/elements/Image/Image' import { createSlug } from '@/core/utils/slug' import toTitleCase from '@/core/utils/toTitleCase' import useAirwayBill from '../hooks/useAirwayBill' +import Manifest from '@/lib/treckingAwb/component/Manifest' const Transaction = ({ id }) => { const { transaction } = useTransaction({ id }) @@ -31,6 +32,7 @@ const Transaction = ({ id }) => { const poNumber = useRef(null) const poFile = useRef(null) const [uploadPo, setUploadPo] = useState(false) + const [idAWB, setIdAWB] = useState(null) const openUploadPo = () => setUploadPo(true) const closeUploadPo = () => setUploadPo(false) const submitUploadPo = async () => { @@ -110,6 +112,10 @@ const Transaction = ({ id }) => { ) } + const closePopup = () => { + setIdAWB(null) + } + return ( transaction.data?.name && ( <> @@ -158,6 +164,7 @@ const Transaction = ({ id }) => {
+
@@ -179,26 +186,28 @@ const Transaction = ({ id }) => {
Pengiriman
- {queryAirwayBill.data?.airways?.map((airway) => ( + {transaction?.data?.pickings?.map((airway) => ( ))}
- {!queryAirwayBill?.data?.airways && ( + {transaction?.data?.pickings == 0 && (
Belum ada pengiriman
)}
@@ -368,27 +377,29 @@ const Transaction = ({ id }) => {
Pengiriman
-
- {queryAirwayBill.data?.airways?.map((airway) => ( +
+ {transaction?.data?.pickings?.map((airway) => ( ))}
- {!queryAirwayBill.data?.airways && ( + {transaction?.data?.pickings.length == 0 && (
Belum ada pengiriman
)} @@ -514,7 +525,7 @@ const Transaction = ({ id }) => {
- {queryAirwayBill.data?.airways?.map((airway) => ( + {/* {queryAirwayBill.data?.airways?.map((airway) => ( {
- ))} + ))} */} ) ) -- cgit v1.2.3 From 6155dd4ea416de8cbd3be3c9409e2246ad61d60c Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Fri, 1 Sep 2023 13:48:07 +0700 Subject: hide button google sign up & shipmet page --- src/lib/auth/components/LoginDesktop.jsx | 8 ++++---- src/lib/auth/components/LoginMobile.jsx | 8 ++++---- src/lib/shipment/components/Shipments.jsx | 4 +--- 3 files changed, 9 insertions(+), 11 deletions(-) (limited to 'src/lib') diff --git a/src/lib/auth/components/LoginDesktop.jsx b/src/lib/auth/components/LoginDesktop.jsx index 42fa8896..838054cd 100644 --- a/src/lib/auth/components/LoginDesktop.jsx +++ b/src/lib/auth/components/LoginDesktop.jsx @@ -95,13 +95,13 @@ const LoginDesktop = () => { {!isLoading ? 'Masuk' : 'Loading...'} -
+ {/*

ATAU


-
+
*/} - + */}
Belum punya akun Indoteknik?{' '} diff --git a/src/lib/auth/components/LoginMobile.jsx b/src/lib/auth/components/LoginMobile.jsx index 095f4174..2d6501cd 100644 --- a/src/lib/auth/components/LoginMobile.jsx +++ b/src/lib/auth/components/LoginMobile.jsx @@ -91,13 +91,13 @@ const LoginMobile = () => { {!isLoading ? 'Masuk' : 'Loading...'} -
+ {/*

ATAU


-
+
*/} - + */}
Belum punya akun Indoteknik?{' '} diff --git a/src/lib/shipment/components/Shipments.jsx b/src/lib/shipment/components/Shipments.jsx index c9d3e627..8b369a11 100644 --- a/src/lib/shipment/components/Shipments.jsx +++ b/src/lib/shipment/components/Shipments.jsx @@ -26,7 +26,6 @@ const Shipments = () => { offset: (page - 1) * limit, limit } - console.log('ini query', query) const [inputQuery, setInputQuery] = useState(q) const queryString = _.toQuery(query) @@ -184,8 +183,7 @@ const Shipments = () => {
- Warning alert! Change a few things up and try - submitting again. + Lacak pengiriman untuk setiap transaksi anda semakin mudah di Indoteknik.com
-- cgit v1.2.3 From 6b1083de2c5ad57953c6653d00a42b2da3fea108 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Fri, 1 Sep 2023 17:09:16 +0700 Subject: hide google sign up button --- src/lib/auth/components/RegisterDesktop.jsx | 4 ++-- src/lib/auth/components/RegisterMobile.jsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/lib') diff --git a/src/lib/auth/components/RegisterDesktop.jsx b/src/lib/auth/components/RegisterDesktop.jsx index a2bc98c2..6072bfb9 100644 --- a/src/lib/auth/components/RegisterDesktop.jsx +++ b/src/lib/auth/components/RegisterDesktop.jsx @@ -152,7 +152,7 @@ const RegisterDesktop = () => {
-
+ {/*

ATAU


@@ -171,7 +171,7 @@ const RegisterDesktop = () => { height={10} />

Daftar dengan Google

- + */}
Sudah punya akun Indoteknik?{' '} diff --git a/src/lib/auth/components/RegisterMobile.jsx b/src/lib/auth/components/RegisterMobile.jsx index 2e918a14..1b0d2adf 100644 --- a/src/lib/auth/components/RegisterMobile.jsx +++ b/src/lib/auth/components/RegisterMobile.jsx @@ -151,7 +151,7 @@ const RegisterMobile = () => {
-
+ {/*

ATAU


@@ -170,7 +170,7 @@ const RegisterMobile = () => { height={10} />

Daftar dengan Google

- + */}
Sudah punya akun Indoteknik?{' '} -- cgit v1.2.3