From f99e0aba70efad0deb907d8e27f09fc9f527c8a4 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 17 Feb 2023 17:07:50 +0700 Subject: Refactor --- src/pages/my/address/index.js | 84 ------------------------------------------- 1 file changed, 84 deletions(-) delete mode 100644 src/pages/my/address/index.js (limited to 'src/pages/my/address/index.js') diff --git a/src/pages/my/address/index.js b/src/pages/my/address/index.js deleted file mode 100644 index 5cad4410..00000000 --- a/src/pages/my/address/index.js +++ /dev/null @@ -1,84 +0,0 @@ -import { useEffect, useState } from "react"; -import { useRouter } from "next/router"; - -import AppBar from "@/components/layouts/AppBar"; -import Layout from "@/components/layouts/Layout"; -import Link from "@/components/elements/Link"; -import WithAuth from "@/components/auth/WithAuth"; - -import apiOdoo from "@/core/utils/apiOdoo"; -import { useAuth } from "@/core/utils/auth"; -import { createOrUpdateItemAddress, getItemAddress } from "@/core/utils/address"; -import { toast } from "react-hot-toast"; - -export default function Address() { - const router = useRouter(); - const { select } = router.query; - const [ auth ] = useAuth(); - const [ addresses, setAddresses ] = useState(null); - const [ selectedAdress, setSelectedAdress ] = useState(null); - - useEffect(() => { - const getAddress = async () => { - if (auth) { - const dataAddress = await apiOdoo('GET', `/api/v1/user/${auth.id}/address`); - setAddresses(dataAddress); - } - }; - getAddress(); - }, [auth]); - - useEffect(() => { - if (select) { - setSelectedAdress(getItemAddress(select)); - } - }, [select]); - - const changeSelectedAddress = (id) => { - if (select) { - createOrUpdateItemAddress(select, id); - router.back(); - } - }; - - return ( - - - - -
- Tambah Alamat -
- -
- { auth && addresses && addresses.map((address, index) => { - let type = address.type.charAt(0).toUpperCase() + address.type.slice(1) + ' Address'; - return ( -
-
changeSelectedAddress(address.id)}> -
-
{ type }
- { auth?.partner_id == address.id && ( -
Utama
- ) } -
-

{ address.name }

- { address.mobile && ( -

{ address.mobile }

- ) } -

- { address.street } -

-
- Ubah Alamat -
- ); - }) } -
-
-
- ) -} \ No newline at end of file -- cgit v1.2.3