feature/research-di #1
@ -66,4 +66,4 @@ const ButtonUi = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|||||||
)
|
)
|
||||||
ButtonUi.displayName = "Button"
|
ButtonUi.displayName = "Button"
|
||||||
|
|
||||||
export { Button, buttonVariants }
|
export { buttonVariants }
|
@ -0,0 +1,13 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import Button from "@/app/components/button/button"
|
||||||
|
import CreateRandomInvoiceButtonVM from "@/app/dashboard/vm/create-random-invoice-button-vm"
|
||||||
|
import { useDI } from "@/bootstrap/di/di-context"
|
||||||
|
import { useRef } from "react"
|
||||||
|
|
||||||
|
export default function CreateRandomInvoiceContainer() {
|
||||||
|
const di = useDI()
|
||||||
|
const vm = useRef(di.resolve(CreateRandomInvoiceButtonVM))
|
||||||
|
|
||||||
|
return <Button vm={vm.current}/>
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
import CreateRandomInvoiceContainer from '@/app/dashboard/components/client/create-random-invoice/create-random-invoice';
|
||||||
import latestInvoicesController from '@/app/dashboard/components/server/latest-invoices/latest-invoices-controller';
|
import latestInvoicesController from '@/app/dashboard/components/server/latest-invoices/latest-invoices-controller';
|
||||||
import { ArrowPathIcon } from '@heroicons/react/24/outline';
|
import { ArrowPathIcon } from '@heroicons/react/24/outline';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
@ -52,10 +53,11 @@ export default async function LatestInvoices() {
|
|||||||
<div className="bg-white px-6">
|
<div className="bg-white px-6">
|
||||||
{invoices}
|
{invoices}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center pb-2 pt-6">
|
<div className="flex items-end mt-auto pb-2 pt-6">
|
||||||
<ArrowPathIcon className="h-5 w-5 text-gray-500" />
|
<ArrowPathIcon className="h-5 w-5 text-gray-500" />
|
||||||
<h3 className="ml-2 text-sm text-gray-500 ">Updated just now</h3>
|
<h3 className="ml-2 text-sm text-gray-500 ">Updated just now</h3>
|
||||||
</div>
|
</div>
|
||||||
|
<CreateRandomInvoiceContainer />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
|
"use client"
|
||||||
import SideNav from "@/app/dashboard/components/server/sidenav";
|
import SideNav from "@/app/dashboard/components/server/sidenav";
|
||||||
|
import dashboardAppModule from "@/app/dashboard/module/dashboard-app-module";
|
||||||
|
import { DiContext } from "@/bootstrap/di/di-context";
|
||||||
|
import { useRef } from "react";
|
||||||
|
|
||||||
|
|
||||||
export default function Layout({ children }: { children: React.ReactNode }) {
|
export default function Layout({ children }: { children: React.ReactNode }) {
|
||||||
|
const di = useRef(dashboardAppModule())
|
||||||
return (
|
return (
|
||||||
|
<DiContext.Provider value={di.current}>
|
||||||
<div className="flex h-screen flex-col md:flex-row md:overflow-hidden">
|
<div className="flex h-screen flex-col md:flex-row md:overflow-hidden">
|
||||||
<div className="w-full flex-none md:w-64">
|
<div className="w-full flex-none md:w-64">
|
||||||
<SideNav />
|
<SideNav />
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-grow p-6 md:overflow-y-auto md:p-12">{children}</div>
|
<div className="flex-grow p-6 md:overflow-y-auto md:p-12">{children}</div>
|
||||||
</div>
|
</div>
|
||||||
|
</DiContext.Provider>
|
||||||
);
|
);
|
||||||
}
|
}
|
@ -1,27 +1,9 @@
|
|||||||
|
import CreateRandomInvoiceButtonVM from "@/app/dashboard/vm/create-random-invoice-button-vm";
|
||||||
import di from "@/bootstrap/di/init-di"
|
import di from "@/bootstrap/di/init-di"
|
||||||
import fetchCustomerInvoicesUsecase from "@/feature/core/customer-invoice/domain/usecase/fetch-customer-invoices-usecase";
|
|
||||||
import fetchCustomersUsecase from "@/feature/core/customer/domain/usecase/fetch-customers-usecase";
|
|
||||||
import fetchAllInvoicesAmountUsecase from "@/feature/core/invoice/domain/usecase/fetch-all-invoices-amount-usecase";
|
|
||||||
import fetchRevenuesUsecase from "@/feature/core/revenue/domain/usecase/fetch-revenues-usecase";
|
|
||||||
|
|
||||||
export default function dashboardAppModule() {
|
export default function dashboardAppModule() {
|
||||||
const dashboardDi = di.createChildContainer()
|
const dashboardDi = di.createChildContainer()
|
||||||
|
|
||||||
dashboardDi.register(fetchCustomersUsecase.name, {
|
dashboardDi.register(CreateRandomInvoiceButtonVM, CreateRandomInvoiceButtonVM)
|
||||||
useValue: fetchCustomersUsecase
|
|
||||||
})
|
|
||||||
|
|
||||||
dashboardDi.register(fetchAllInvoicesAmountUsecase.name, {
|
|
||||||
useValue: fetchAllInvoicesAmountUsecase
|
|
||||||
})
|
|
||||||
dashboardDi.register(fetchAllInvoicesAmountUsecase.name, {
|
|
||||||
useValue: fetchAllInvoicesAmountUsecase
|
|
||||||
})
|
|
||||||
dashboardDi.register(fetchCustomerInvoicesUsecase.name, {
|
|
||||||
useValue: fetchCustomerInvoicesUsecase
|
|
||||||
})
|
|
||||||
dashboardDi.register(fetchRevenuesUsecase.name, {
|
|
||||||
useValue: fetchRevenuesUsecase
|
|
||||||
})
|
|
||||||
return dashboardDi
|
return dashboardDi
|
||||||
}
|
}
|
||||||
|
15
src/app/dashboard/vm/create-random-invoice-button-vm.ts
Normal file
15
src/app/dashboard/vm/create-random-invoice-button-vm.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import ButtonVm from "@/app/components/button/button-vm";
|
||||||
|
import BaseVM from "@/bootstrap/helpers/vm/base-vm";
|
||||||
|
|
||||||
|
export default class CreateRandomInvoiceButtonVM extends BaseVM<ButtonVm> {
|
||||||
|
useVM(): ButtonVm {
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
title: "Button Title"
|
||||||
|
},
|
||||||
|
onClick: () => {
|
||||||
|
console.log('clicked');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user