From e1c3c3270a3d4b6ab128dff72b7c14dbb0a4e7f1 Mon Sep 17 00:00:00 2001 From: happppi <102276917+hhbb0081@users.noreply.github.com> Date: Mon, 27 May 2024 21:41:43 +0900 Subject: [PATCH 1/8] =?UTF-8?q?Feat:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EC=97=B0=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/Login/components/LoginBtn.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/Login/components/LoginBtn.tsx b/src/features/Login/components/LoginBtn.tsx index cd947b9..4961b7f 100644 --- a/src/features/Login/components/LoginBtn.tsx +++ b/src/features/Login/components/LoginBtn.tsx @@ -5,7 +5,7 @@ import "./Login.css"; export default function LoginBtn() { const handleLogin = () => { - window.location.href = `https://kauth.kakao.com/oauth/authorize?client_id=${process.env.NEXT_PUBLIC_API_KEY}&redirect_url=${process.env.NEXT_PUBLIC_REDIRECT_URL}&response_type=code` + window.location.href = `${process.env.NEXT_PUBLIC_KAKAO_URL}`; } return ( kakao login From 885bab2ed33063d866382ed55dcd2e9c648ea882 Mon Sep 17 00:00:00 2001 From: happppi <102276917+hhbb0081@users.noreply.github.com> Date: Mon, 27 May 2024 21:44:55 +0900 Subject: [PATCH 2/8] =?UTF-8?q?Feat:=20withCredentials=20=EC=98=B5?= =?UTF-8?q?=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/http.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/apis/http.tsx b/src/apis/http.tsx index bc7de52..b17aa8c 100644 --- a/src/apis/http.tsx +++ b/src/apis/http.tsx @@ -3,7 +3,8 @@ import axios from "axios"; import { AxiosInstance, AxiosRequestConfig } from "axios"; const axiosInstance = axios.create({ - baseURL: process.env.NEXT_PUBLIC_LOCAL_URL + baseURL: process.env.NEXT_PUBLIC_LOCAL_URL, + withCredentials: true }); export interface HttpClient extends AxiosInstance { From 61d4ce28c7de3e399c84fcc2981b620cca255afa Mon Sep 17 00:00:00 2001 From: happppi <102276917+hhbb0081@users.noreply.github.com> Date: Mon, 27 May 2024 21:45:22 +0900 Subject: [PATCH 3/8] =?UTF-8?q?Fix:=20URL=20=EB=88=84=EB=9D=BD=EB=90=9C=20?= =?UTF-8?q?=EB=B6=80=EB=B6=84=20=EC=B6=94=EA=B0=80=20(/api)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.env b/.env index a58bccf..38cb3b8 100644 --- a/.env +++ b/.env @@ -1,4 +1,2 @@ NEXT_PUBLIC_API_URL=http://3.34.58.135:8080 -NEXT_PUBLIC_LOCAL_URL=http://localhost:8080 -NEXT_PUBLIC_API_KEY=bf46dcac98a9a9ce6a13a465fa86d0b2 -NEXT_PUBLIC_REDIRECT_URL=http://3.34.58.135:3000 \ No newline at end of file +NEXT_PUBLIC_LOCAL_URL=http://localhost:8080/api \ No newline at end of file From ec3602a546f1d75e1fcf533336eace3fdc448bfa Mon Sep 17 00:00:00 2001 From: happppi <102276917+hhbb0081@users.noreply.github.com> Date: Mon, 27 May 2024 21:46:31 +0900 Subject: [PATCH 4/8] =?UTF-8?q?Feat:=20react-hook-form=20register=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/atoms/button/Button.tsx | 5 +- .../atoms/fileUpload/FileUpload.tsx | 5 +- src/components/atoms/input/Input.tsx | 23 ++++--- src/components/atoms/textarea/Textarea.tsx | 5 +- src/components/atoms/toggle/Toggle.tsx | 11 ++- src/components/molecules/authBox/AuthBox.tsx | 29 +++++--- .../molecules/inputBox/InputBox.tsx | 68 +++++++++++++++---- 7 files changed, 103 insertions(+), 43 deletions(-) diff --git a/src/components/atoms/button/Button.tsx b/src/components/atoms/button/Button.tsx index 86e39f3..b3c1054 100644 --- a/src/components/atoms/button/Button.tsx +++ b/src/components/atoms/button/Button.tsx @@ -11,14 +11,15 @@ export interface ButtonProps { height?: string; fontSize?: string; fontWeight?: string; + type?: "button" | "submit" | "reset" | undefined; } -export function Button({ children, onClick, color = "#2b2b2b", backgroundColor = "#51F8C4", size = "lg", fontSize = "1rem", fontWeight = "700" }: ButtonProps) { +export function Button({ children, onClick, color = "#2b2b2b", backgroundColor = "#51F8C4", size = "lg", fontSize = "1rem", fontWeight = "700", type = "button" }: ButtonProps) { const style: React.CSSProperties = { color: color, backgroundColor: backgroundColor, fontSize: fontSize, fontWeight: fontWeight, }; - return
{children}
; + return ; } diff --git a/src/components/atoms/fileUpload/FileUpload.tsx b/src/components/atoms/fileUpload/FileUpload.tsx index 827e7a1..4b26e73 100644 --- a/src/components/atoms/fileUpload/FileUpload.tsx +++ b/src/components/atoms/fileUpload/FileUpload.tsx @@ -6,9 +6,11 @@ import "./FileUpload.css"; export interface FileUploadProps { children?: ReactNode; + name: string; + register: any; } -export function FileUpload({ children }: FileUploadProps) { +export function FileUpload({ children, name, register }: FileUploadProps) { interface imageState { url?: string; name?: string; @@ -53,6 +55,7 @@ export function FileUpload({ children }: FileUploadProps) { type="file" accept="image/*" onChange={handleImageChange} + {...register(name)} multiple /> diff --git a/src/components/atoms/input/Input.tsx b/src/components/atoms/input/Input.tsx index 85e87fe..6c499b9 100644 --- a/src/components/atoms/input/Input.tsx +++ b/src/components/atoms/input/Input.tsx @@ -1,38 +1,41 @@ "use client"; -import React, { forwardRef, useState } from "react"; -import { UseControllerProps, useController } from "react-hook-form"; +import { forwardRef, useState } from "react"; +import { UseControllerProps } from "react-hook-form"; import "./input.css"; export interface InputProps extends UseControllerProps{ placeholder?: string; size?: 'sm' | 'md' | 'lg'; maxCnt?: number; + register: any; + value?: string | number; } export const Input = forwardRef( - ({ control, size = "lg", placeholder = "", maxCnt = 0, name = '', ...props }, ref) => { + ({ register, size = "lg", placeholder = "", maxCnt = 0, name = '', value, ...props }, ref) => { const [textCnt, setTextCnt] = useState(0); - const { - field, - fieldState: { error } - } = useController({ name, control }); + // const { + // field, + // fieldState: { error } + // } = useController({ name, control }); const handleChangeInput = (e: React.ChangeEvent) => { setTextCnt(e.target.value.length); + // field.onChange(e); } return (
{maxCnt !== 0 && ( diff --git a/src/components/atoms/textarea/Textarea.tsx b/src/components/atoms/textarea/Textarea.tsx index d97d235..ac10627 100644 --- a/src/components/atoms/textarea/Textarea.tsx +++ b/src/components/atoms/textarea/Textarea.tsx @@ -10,9 +10,11 @@ export interface TextareaProps { height?: string; fontSize?: string; maxCnt?: number; + name: string; + register: any; } -export function Textarea({ backgroundColor = "#2B2B2B", color = "#fff", size = "big", height = "12rem", fontSize = "16px", content = "", maxCnt = 300 }: TextareaProps) { +export function Textarea({ backgroundColor = "#2B2B2B", color = "#fff", size = "big", height = "12rem", fontSize = "16px", content = "", maxCnt = 300, name, register }: TextareaProps) { const [isFocused, setIsFocused] = useState(false); const [textCnt, setTextCnt] = useState(0); const style: React.CSSProperties = { @@ -50,6 +52,7 @@ export function Textarea({ backgroundColor = "#2B2B2B", color = "#fff", size = " onBlur={handleBlur} onChange={handleTextCnt} maxLength={maxCnt} + {...register(name)} />

{textCnt} diff --git a/src/components/atoms/toggle/Toggle.tsx b/src/components/atoms/toggle/Toggle.tsx index c419494..a8b0e24 100644 --- a/src/components/atoms/toggle/Toggle.tsx +++ b/src/components/atoms/toggle/Toggle.tsx @@ -12,17 +12,15 @@ export interface ToggleProps { width?: string; fontSize?: string; content?: string; + name: string; + register: any; } export function Toggle({ - children, - color = "#2b2b2b", - backgroundColor = "#51F8C4", - size = "big", height = "2rem", width = "4rem", - fontSize = "16rem", - content = "", + name, + register }: ToggleProps) { const [on, setOn] = useState(false); const changeToggle = () => { @@ -65,6 +63,7 @@ export function Toggle({ checked={on} // onChange={noop} data-testid="toggle-input" + {...register(name)} /> { - const { control, handleSubmit, getValues } = useForm(); +export const AuthBox = ({register}: any) => { const [display, setDisplay] = useState(false); + const {mutate, isSuccess} = usePostCertification(); + const [authNum, setAuthNum] = useState({ + toNumber: "", + certificationNum: 0 + }); + const handleAuthnum = () => { setDisplay(true); - handleSubmit(onSubmit); - console.log(getValues()); + // mutate({ + // toNumber: + // }) + // handleSubmit(onSubmit); + // console.log(getValues()); } const onSubmit = () => { @@ -25,9 +33,14 @@ export const AuthBox = () => {

) => setAuthNum((prev) => ({ + // ...prev, + // toNumber: e.target.value + // }))} + register={register} />
) : diff --git a/src/components/molecules/inputBox/InputBox.tsx b/src/components/molecules/inputBox/InputBox.tsx index 7c6de49..afdca56 100644 --- a/src/components/molecules/inputBox/InputBox.tsx +++ b/src/components/molecules/inputBox/InputBox.tsx @@ -7,9 +7,9 @@ import { Toggle } from "@/components/atoms/toggle"; import { AuthBox } from "../authBox"; import { ChipBox } from "../chipBox/ChipBox"; -import { FieldValues, useForm } from "react-hook-form"; -import "./InputBox.css"; import { CodeInput } from "@/components/atoms/input/CodeInput"; +import { COLORS } from "@/styles"; +import "./InputBox.css"; export interface InputBoxProps { title?: string; @@ -17,7 +17,9 @@ export interface InputBoxProps { type?: string; subtitle?: string; essential?: boolean; - name?: string; + name: string; + register: any; + control?: any; } export function InputBox({ title, @@ -26,53 +28,89 @@ export function InputBox({ subtitle, essential, name, + register, + control, }: InputBoxProps) { - const { control } = useForm(); + // const { control } = useForm(); let inputComponent; switch (type) { case "input": - inputComponent = ; + inputComponent = + ; break; case "numInput": inputComponent = ( - + ); break; case "textarea": - inputComponent =