From 59cadfaddf9cc3fdea57800e6dfbd0c8cd93afc1 Mon Sep 17 00:00:00 2001 From: Shiyu Chen <42055092+s3713434@users.noreply.github.com> Date: Sat, 3 Aug 2024 12:04:19 +1000 Subject: [PATCH 1/7] create reusable btn --- package.json | 4 +- src/module/auth/login-form.tsx | 76 +++++++++++----------- src/module/common/button.tsx | 115 ++++++++++++++++++++++++++++----- tailwind.config.ts | 18 ++++-- yarn.lock | 81 +++++++++++++---------- 5 files changed, 195 insertions(+), 99 deletions(-) diff --git a/package.json b/package.json index a15f206..dafca41 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "scripts": { - "dev": "yarn dev-codegen & yarn dev-next", + "dev": "concurrently 'yarn:dev-*'", "dev-codegen": "graphql-codegen --watch", "dev-next": "next dev -p 3010", "build": "next build", @@ -38,7 +38,7 @@ "@types/node": "^20", "@types/react": "^18", "@types/react-dom": "^18", - "daisyui": "^4.12.10", + "concurrently": "^8.2.2", "eslint": "^8", "eslint-config-next": "14.2.5", "postcss": "^8", diff --git a/src/module/auth/login-form.tsx b/src/module/auth/login-form.tsx index d3f406d..0eae42c 100644 --- a/src/module/auth/login-form.tsx +++ b/src/module/auth/login-form.tsx @@ -1,19 +1,20 @@ -"use client"; -import { zodResolver } from "@hookform/resolvers/zod"; +'use client' +import { zodResolver } from '@hookform/resolvers/zod' import { + Button, ControlledPasswordInput, ControlledTextInput, Icon, -} from "@src/module/common"; -import Link from "next/link"; -import { useForm } from "react-hook-form"; -import { z } from "zod"; -import { login, LoginPayload } from "./auth-service"; +} from '@src/module/common' +import Link from 'next/link' +import { useForm } from 'react-hook-form' +import { z } from 'zod' +import { login, LoginPayload } from './auth-service' const formSchema = z.object({ email: z.string().email(), password: z.string().min(8), -}); +}) export function LoginForm() { const { @@ -23,73 +24,72 @@ export function LoginForm() { setError, } = useForm({ defaultValues: { - email: "", - password: "", + email: '', + password: '', }, resolver: zodResolver(formSchema), - }); + }) async function action(payload: LoginPayload) { - const res = await login(payload); + const res = await login(payload) if (res?.error) { - console.log(res.error); - setError("root", { message: res.error }); + console.log(res.error) + setError('root', { message: res.error }) } } const onSubmit = handleSubmit((data) => { - console.log("wtf", data); - action(data); - }); + console.log('wtf', data) + action(data) + }) return ( -