feature/storybook #2
@ -45,7 +45,7 @@ export const recursiveNestedProps = (
|
|||||||
const preview = {
|
const preview = {
|
||||||
decorators: [
|
decorators: [
|
||||||
(Story, data) => {
|
(Story, data) => {
|
||||||
const [isDark, setDark] = React.useState(false);
|
const [isDark, setDark] = React.useState(true);
|
||||||
|
|
||||||
const parsedProps = {} as Record<string, unknown>;
|
const parsedProps = {} as Record<string, unknown>;
|
||||||
const props = data.allArgs;
|
const props = data.allArgs;
|
||||||
|
@ -11,7 +11,6 @@ import { cn } from "@/bootstrap/helpers/lib/ui-utils";
|
|||||||
export default class Button extends BaseView<ButtonVm> {
|
export default class Button extends BaseView<ButtonVm> {
|
||||||
protected Build(props: BuildProps<ButtonVm>): ReactNode {
|
protected Build(props: BuildProps<ButtonVm>): ReactNode {
|
||||||
const { vm } = props;
|
const { vm } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ButtonUi disabled={vm.props.isDisable} onClick={vm.onClick}>
|
<ButtonUi disabled={vm.props.isDisable} onClick={vm.onClick}>
|
||||||
{vm.props.title}
|
{vm.props.title}
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
|
import dashboardAppModule from "@/app/[lang]/dashboard/module/dashboard-app-module";
|
||||||
|
import CreateRandomInvoiceButtonVM from "@/app/[lang]/dashboard/vm/create-random-invoice-button-vm";
|
||||||
import Button from "@/app/components/button/button";
|
import Button from "@/app/components/button/button";
|
||||||
|
import { DiContext, useDI } from "@/bootstrap/di/di-context";
|
||||||
import Story from "@/bootstrap/helpers/view/storybook-base-template-type";
|
import Story from "@/bootstrap/helpers/view/storybook-base-template-type";
|
||||||
import getArgVM from "@/bootstrap/helpers/view/storybook-with-arg-vm";
|
import getArgVM from "@/bootstrap/helpers/view/storybook-with-arg-vm";
|
||||||
|
import createInvoiceUsecase from "@/feature/core/invoice/domain/usecase/create-invoice-usecase";
|
||||||
import type { Meta } from "@storybook/react";
|
import type { Meta } from "@storybook/react";
|
||||||
|
import { useRef } from "react";
|
||||||
|
|
||||||
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
||||||
const meta: Meta = {
|
const meta: Meta = {
|
||||||
@ -29,3 +34,19 @@ export const Primary: Story = {
|
|||||||
return <Button vm={vm} memoizedByVM={false} />
|
return <Button vm={vm} memoizedByVM={false} />
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const WithVM: Story = {
|
||||||
|
decorators: [
|
||||||
|
(Story) => {
|
||||||
|
return <Story />
|
||||||
|
}
|
||||||
|
],
|
||||||
|
render: () => {
|
||||||
|
const Child = () => {
|
||||||
|
const di = useDI();
|
||||||
|
const vm = useRef(di.resolve(CreateRandomInvoiceButtonVM));
|
||||||
|
return <Button vm={vm.current} memoizedByVM={false} />
|
||||||
|
}
|
||||||
|
return (<DiContext.Provider value={dashboardAppModule()}> <Child /> </ DiContext.Provider>)
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { ApiEither } from "@/feature/common/data/api-task";
|
import { ApiEither } from "@/feature/common/data/api-task";
|
||||||
import ParamsFailure from "@/feature/common/failures/params-failure";
|
import ParamsFailure from "@/feature/common/failures/params-failure";
|
||||||
import serverDi from "@/feature/common/server-di";
|
// import serverDi from "@/feature/common/server-di";
|
||||||
import InvoiceRepo, {
|
import InvoiceRepo, {
|
||||||
invoiceRepoKey,
|
invoiceRepoKey,
|
||||||
} from "@/feature/core/invoice/domain/i-repo/invoice-repo";
|
} from "@/feature/core/invoice/domain/i-repo/invoice-repo";
|
||||||
@ -17,16 +17,17 @@ import { chain, fromNullable, left, map, right } from "fp-ts/lib/TaskEither";
|
|||||||
export default async function createInvoiceUsecase(
|
export default async function createInvoiceUsecase(
|
||||||
params: InvoiceParam,
|
params: InvoiceParam,
|
||||||
): Promise<ApiEither<string>> {
|
): Promise<ApiEither<string>> {
|
||||||
const repo = serverDi(invoiceModuleKey).resolve<InvoiceRepo>(invoiceRepoKey);
|
return right("fixed")()
|
||||||
|
// const repo = serverDi(invoiceModuleKey).resolve<InvoiceRepo>(invoiceRepoKey);
|
||||||
|
|
||||||
return pipe(
|
// return pipe(
|
||||||
fromNullable(new ParamsFailure())(params),
|
// fromNullable(new ParamsFailure())(params),
|
||||||
map((params) => invoiceSchema.safeParse(params)),
|
// map((params) => invoiceSchema.safeParse(params)),
|
||||||
chain((params) => {
|
// chain((params) => {
|
||||||
const isParamsValid = invoiceSchema.safeParse(params);
|
// const isParamsValid = invoiceSchema.safeParse(params);
|
||||||
if (!isParamsValid.success) left(new ParamsFailure());
|
// if (!isParamsValid.success) left(new ParamsFailure());
|
||||||
return right(params.data as InvoiceParam);
|
// return right(params.data as InvoiceParam);
|
||||||
}),
|
// }),
|
||||||
chain((params) => repo.createInvoice(params)),
|
// chain((params) => repo.createInvoice(params)),
|
||||||
)();
|
// )();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user