Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 2 additions & 22 deletions src/app/post-meetup/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use client';

import { useForm } from '@tanstack/react-form';
import { z } from 'zod';

import {
MeetupCapField,
Expand All @@ -19,14 +18,6 @@ import { CreateGroupPayload } from '@/types/service/group';
const PostMeetupPage = () => {
const { mutate } = useCreateGroup();

const CreateGroupSchema = {
title: z.string().min(2),
location: z.string().min(2),
startTime: z.string().min(2),
description: z.string().min(2),
maxParticipants: z.number().min(2),
};

const form = useForm({
defaultValues: {
title: '',
Expand All @@ -39,9 +30,6 @@ const PostMeetupPage = () => {
maxParticipants: 0,
images: [],
} as CreateGroupPayload,
validators: {
onChange: () => CreateGroupSchema,
},
onSubmit: ({ value }) => {
console.log(value);
const res = mutate(value);
Expand All @@ -51,12 +39,7 @@ const PostMeetupPage = () => {

return (
<div>
<form
onSubmit={(e) => {
e.preventDefault();
form.handleSubmit();
}}
>
<form>
<section className='px-4'>
<form.Field children={(field) => <MeetupTitleField field={field} />} name='title' />
<form.Field children={(field) => <MeetupLocationField field={field} />} name='location' />
Expand All @@ -73,10 +56,7 @@ const PostMeetupPage = () => {
<form.Field children={(field) => <MeetupTagsField field={field} />} name='tags' />
</section>

<form.Subscribe
children={(state) => <MeetupSubmitButton state={state} />}
selector={(state) => state}
/>
<MeetupSubmitButton onSubmitClick={() => form.handleSubmit()} />
</form>
</div>
);
Expand Down
8 changes: 3 additions & 5 deletions src/components/pages/post-meetup/post-button/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { AnyFormState } from '@tanstack/react-form';

import { Button } from '@/components/ui';

interface Props {
state: AnyFormState;
onSubmitClick: () => void;
}

export const MeetupSubmitButton = ({ state }: Props) => {
export const MeetupSubmitButton = ({ onSubmitClick }: Props) => {
return (
<div className='mt-6 border-t-1 border-gray-200 bg-white px-4 py-3'>
<Button disabled={!state.canSubmit} type='submit'>
<Button type='button' onClick={onSubmitClick}>
모임 생성
</Button>
</div>
Expand Down