Skip to content

Commit

Permalink
[WRFE-48](feat): 수정페이지 ing
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-hjh committed Nov 6, 2024
1 parent b1720c2 commit 7b6f33f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
13 changes: 11 additions & 2 deletions apps/front/wraffle-webview/app/products/[id]/edit/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
'use client';

import {Header} from '@/shared/ui';
import GenericForm from '@/shared/ui/form/GenericForm';
import {EditList} from '@/widgets/product-list/edit/ui';
import {Typography} from '@wraffle/ui';

Expand All @@ -22,12 +25,16 @@ const Edit = ({
etc: 'test ETC',
};

const onSubmit = data => {
console.log(data);
};

return (
<div>
<div className='py-5'>
<Header>
<Header.Left>
<Header.BackButton></Header.BackButton>
<Header.BackButton />
</Header.Left>
<Header.Middle>
<Typography className='text-sm font-semibold text-[#191F28]'>
Expand All @@ -38,7 +45,9 @@ const Edit = ({
<div className='h-px w-full bg-zinc-200'></div>
</div>

<EditList product={product} />
<GenericForm onSubmit={onSubmit} formOptions={{defaultValues: product}}>
<EditList product={product} />
</GenericForm>
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
'use client';

import {useEffect} from 'react';
import {useFormContext} from 'react-hook-form';
import {Divider} from '@/shared/ui';
import {Button, Icon, Input, Label, Tag} from '@wraffle/ui';

export const EditList = ({product}) => {
const {setValue} = useFormContext();

useEffect(() => {
setValue('title', product.title);
setValue('category', product.category);
setValue('tags', product.tags);
setValue('images', product.images);
setValue('price', product.price);
setValue('startDate', product.startDate);
setValue('endDate', product.endDate);
setValue('announceAt', product.announceAt);
setValue('winnerCount', product.winnerCount);
setValue('etc', product.etc);
}, []);
const {watch} = useFormContext();

const startDate = watch('startDate');
const endDate = watch('endDate');

const tags = ['tag1', 'tag2'];

return (
<div className='flex h-full flex-col gap-5 px-5 pb-24'>
Expand Down

0 comments on commit 7b6f33f

Please sign in to comment.