1 import { useParams } from "react-router-dom"
2 import { LayoutComposer } from "@medusajs/dashboard/components"
3 import { useStoreCreditAccount } from "../../../hooks/api/store-credit-accounts"
4 import StoreCreditAccountBalanceSection from "./components/store-credit-account-balance-section"
5 import StoreCreditAccountDetailsSection from "./components/store-credit-account-details-section"
6 import StoreCreditAccountCustomerSection from "./components/store-credit-account-customer-section"
7 import { TransactionsTable } from "./components/transactions-table/table"
8 import StoreCreditAccountCodeSection from "./components/store-credit-account-code"
9
10 const StoreCreditAccountPage = () => {
11 const { id } = useParams()
12
13 const { store_credit_account: storeCreditAccount } = useStoreCreditAccount(
14 id!
15 )
16
17 if (!storeCreditAccount) {
18 return
19 }
20
21 return (
22 <LayoutComposer
23 widgetsZonePrefix="store_credit_account.details"
24 preferredLayoutId="core:two-column"
25 data={storeCreditAccount}
26 sections={{
27 main: (
28 <>
29 <LayoutComposer.Entry id="StoreCreditAccountDetailsSection">
30 <StoreCreditAccountDetailsSection
31 storeCreditAccount={storeCreditAccount}
32 />
33 </LayoutComposer.Entry>
34
35 <LayoutComposer.Entry id="TransactionsTable">
36 <TransactionsTable id={storeCreditAccount.id} />
37 </LayoutComposer.Entry>
38 </>
39 ),
40 side: (
41 <>
42 <LayoutComposer.Entry id="StoreCreditAccountBalanceSection">
43 <StoreCreditAccountBalanceSection
44 storeCreditAccount={storeCreditAccount}
45 />
46 </LayoutComposer.Entry>
47 <LayoutComposer.Entry id="StoreCreditAccountCodeSection">
48 <StoreCreditAccountCodeSection code={storeCreditAccount.code} />
49 </LayoutComposer.Entry>
50 <LayoutComposer.Entry id="StoreCreditAccountCustomerSection">
51 <StoreCreditAccountCustomerSection
52 customerId={storeCreditAccount.customer_id}
53 />
54 </LayoutComposer.Entry>
55 </>
56 ),
57 }}
58 />
59 )
60 }
61
62 export default StoreCreditAccountPage