summaryrefslogtreecommitdiff
path: root/src2/pages/shop/checkout/finish.js
blob: df284f8a66b84dc7a9a9957dc2ce9d90a372c7ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import WithAuth from "@/components/auth/WithAuth";
import Link from "@/components/elements/Link";
import AppBar from "@/components/layouts/AppBar";
import Header from "@/components/layouts/Header";
import Layout from "@/components/layouts/Layout";
import apiOdoo from "@/core/utils/apiOdoo";
import { useAuth } from "@/core/utils/auth";
import { EnvelopeIcon } from "@heroicons/react/24/outline";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";

export default function FinishCheckout() {
  const router = useRouter();
  const { id } = router.query;
  const [ auth ] = useAuth();
  const [ transaction, setTransactions ] = useState(null);

  useEffect(() => {
    const loadTransaction = async () => {
      if (auth && id) {
        const dataTransaction = await apiOdoo('GET', `/api/v1/partner/${auth.partner_id}/sale_order/${id}`);
        setTransactions(dataTransaction);
      }
    };
    loadTransaction();
  });

  return (
    <WithAuth>
      <Layout>
        <AppBar title="Pembelian Berhasil" />

        <div className="m-4 rounded-xl bg-yellow_r-4 text-center border border-yellow_r-7">
          <div className="px-4 py-6 text-yellow_r-12">
            <p className="h2 mb-2">Terima Kasih atas Pembelian Anda</p>
            <p className="text-yellow_r-11 mb-4 leading-6">Rincian belanja sudah kami kirimkan ke email anda. Mohon dicek kembali. jika tidak menerima email, anda dapat menghubungi kami disini.</p>
            <p className="mb-2 font-medium">{ transaction?.name }</p>
            <p className="text-caption-2 text-yellow_r-11">No. Transaksi</p>
          </div>
          <Link href={transaction?.id ? `/my/transaction/${transaction.id}` : '/'} className="bg-yellow_r-6 text-yellow_r-12 rounded-b-xl py-4 block">
            Lihat detail pembelian Anda disini
          </Link>
        </div>
      </Layout>
    </WithAuth>
  );
}