From a5321d82f4b5e8404f575f1d62e92d0322d78db9 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 22 Nov 2023 11:33:52 +0700 Subject: Update socials icon on footer --- .../components/elements/Footer/BasicFooter.jsx | 280 ++++++++++++++++----- 1 file changed, 215 insertions(+), 65 deletions(-) (limited to 'src/core') diff --git a/src/core/components/elements/Footer/BasicFooter.jsx b/src/core/components/elements/Footer/BasicFooter.jsx index 23bca677..28a3764c 100644 --- a/src/core/components/elements/Footer/BasicFooter.jsx +++ b/src/core/components/elements/Footer/BasicFooter.jsx @@ -1,14 +1,14 @@ -import NextImage from 'next/image' -import IndoteknikLogo from '@/images/logo.png' +import NextImage from 'next/image'; +import IndoteknikLogo from '@/images/logo.png'; import { DevicePhoneMobileIcon, EnvelopeIcon, - PhoneArrowUpRightIcon -} from '@heroicons/react/24/outline' -import Link from '../Link/Link' -import MobileView from '../../views/MobileView' -import DesktopView from '../../views/DesktopView' -import whatsappUrl from '@/core/utils/whatsappUrl' + PhoneArrowUpRightIcon, +} from '@heroicons/react/24/outline'; +import Link from '../Link/Link'; +import MobileView from '../../views/MobileView'; +import DesktopView from '../../views/DesktopView'; +import whatsappUrl from '@/core/utils/whatsappUrl'; const BasicFooter = () => { return ( @@ -17,9 +17,16 @@ const BasicFooter = () => { @@ -46,8 +54,15 @@ const BasicFooter = () => { - ) -} + ); +}; -const headerClassName = 'font-semibold mb-4' +const headerClassName = 'font-semibold mb-4'; const OfficeLocation = () => (
Kantor Pusat
- - Jl. Bandengan Utara 85A No. 8-9 RT.3/RW.16, Penjaringan, Kec. Penjaringan, Jakarta Utara + + Jl. Bandengan Utara 85A No. 8-9 RT.3/RW.16, Penjaringan, Kec. + Penjaringan, Jakarta Utara +
-) +); const WarehouseLocation = () => (
Gudang Indoteknik
- Jl. Bandengan Utara Komp. 85 A dan B, Penjaringan, Kec. Penjaringan, Jakarta Utara + Jl. Bandengan Utara Komp. 85 A dan B, Penjaringan, Kec. Penjaringan, + Jakarta Utara
-) +); const AboutUs = () => (
Tentang Kami
-) +); const CustomerGuide = () => (
Bantuan & Panduan
-) +); const Form = () => (
Formulir
-) +); const InformationCenter = () => (
@@ -187,11 +243,15 @@ const InformationCenter = () => (
-) +); const OpenHours = () => (
@@ -217,44 +277,124 @@ const OpenHours = () => (
-) +); const SocialMedias = () => (
Temukan Kami
-
+
+ + + + + + - + - - + + - + - - + + - - + +
-) +); const Payments = () => (
Pembayaran
- - - - + + + + ( width={48} height={24} /> - +
-) +); const InternalItemLink = ({ href, children }) => ( - + {children} -) +); -export default BasicFooter +export default BasicFooter; -- cgit v1.2.3 From ddfdcfdc47e8c44fbf7abd0ee69acb959ab79387 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 29 Nov 2023 15:31:55 +0700 Subject: Update odooApi to logout when reach max conn attempt and redirect to login --- src/core/api/odooApi.js | 71 ++++++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 30 deletions(-) (limited to 'src/core') diff --git a/src/core/api/odooApi.js b/src/core/api/odooApi.js index fe9fcdd2..3349ff4b 100644 --- a/src/core/api/odooApi.js +++ b/src/core/api/odooApi.js @@ -1,22 +1,24 @@ -import axios from 'axios' -import camelcaseObjectDeep from 'camelcase-object-deep' -import { getCookie, setCookie } from 'cookies-next' -import { getAuth } from '../utils/auth' +import axios from 'axios'; +import camelcaseObjectDeep from 'camelcase-object-deep'; +import { getCookie, setCookie } from 'cookies-next'; +import { deleteAuth, getAuth } from '../utils/auth'; const renewToken = async () => { - let token = await axios.get(process.env.NEXT_PUBLIC_ODOO_API_HOST + '/api/token') - setCookie('token', token.data.result) - return token.data.result -} + let token = await axios.get( + process.env.NEXT_PUBLIC_ODOO_API_HOST + '/api/token' + ); + setCookie('token', token.data.result); + return token.data.result; +}; const getToken = async () => { - let token = getCookie('token') - if (token == undefined) token = await renewToken() - return token -} + let token = getCookie('token'); + if (token == undefined) token = await renewToken(); + return token; +}; -const maxConnectionAttempt = 15 -let connectionAttempt = 0 +const maxConnectionAttempt = 15; +let connectionAttempt = 0; /** * The `odooApi` function is used to make API requests to an Odoo backend with customizable parameters such as `method`, `url`, `data`, and `headers`. @@ -30,31 +32,40 @@ let connectionAttempt = 0 * @returns {Promise} - A Promise that resolves to the API response data or an empty array. */ const odooApi = async (method, url, data = {}, headers = {}) => { - connectionAttempt++ + connectionAttempt++; try { - let token = await getToken() - const auth = getAuth() + let token = await getToken(); + const auth = getAuth(); let axiosParameter = { method, url: process.env.NEXT_PUBLIC_ODOO_API_HOST + url, - headers: { Authorization: token, ...headers } - } - if (auth) axiosParameter.headers['Token'] = auth.token + headers: { Authorization: token, ...headers }, + }; + if (auth) axiosParameter.headers['Token'] = auth.token; if (method.toUpperCase() == 'POST') - axiosParameter.headers['Content-Type'] = 'application/x-www-form-urlencoded' + axiosParameter.headers['Content-Type'] = + 'application/x-www-form-urlencoded'; if (Object.keys(data).length > 0) - axiosParameter.data = new URLSearchParams(Object.entries(data)).toString() + axiosParameter.data = new URLSearchParams( + Object.entries(data) + ).toString(); - let res = await axios(axiosParameter) - if (res.data.status.code == 401 && connectionAttempt < maxConnectionAttempt) { - await renewToken() - return odooApi(method, url, data, headers) + let res = await axios(axiosParameter); + if (res.data.status.code == 401) { + if (connectionAttempt < maxConnectionAttempt) { + await renewToken(); + return odooApi(method, url, data, headers); + } else { + await deleteAuth(); + window.location.href = '/login'; + return false; + } } - return camelcaseObjectDeep(res.data.result) || [] + return camelcaseObjectDeep(res.data.result) || []; } catch (error) { - console.log(error) + console.log(error); } -} +}; -export default odooApi +export default odooApi; -- cgit v1.2.3