From e78bcf0ae28c2a2212ce879d4d452e844ed27f92 Mon Sep 17 00:00:00 2001 From: sayyyho <323psh@naver.com> Date: Sun, 3 Nov 2024 04:24:17 +0900 Subject: [PATCH] =?UTF-8?q?[Feature]=20-=20login,=20create,=20invite=20API?= =?UTF-8?q?=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Router.tsx | 2 +- src/components/common/input/DateInput.tsx | 28 ++++++++++++--- src/components/create/TeamButton.tsx | 10 ++++-- src/components/invite/urlCopy/UrlCopy.tsx | 5 +-- src/components/invite/urlCopy/style.ts | 2 +- src/pages/create/Create.tsx | 18 +++++++++- src/pages/invite/Invite.tsx | 44 ++++++++++++++++------- src/pages/login/Login.tsx | 39 ++++++++++++++++++-- 8 files changed, 123 insertions(+), 25 deletions(-) diff --git a/src/Router.tsx b/src/Router.tsx index 841899b..be99820 100644 --- a/src/Router.tsx +++ b/src/Router.tsx @@ -18,7 +18,7 @@ const Router: React.FC = () => { } /> } /> } /> - } /> + } /> } /> } /> } /> diff --git a/src/components/common/input/DateInput.tsx b/src/components/common/input/DateInput.tsx index eebd0c2..55b614e 100644 --- a/src/components/common/input/DateInput.tsx +++ b/src/components/common/input/DateInput.tsx @@ -1,4 +1,3 @@ -// DateInput.tsx import React from "react"; import * as S from "./style"; @@ -12,13 +11,34 @@ const DateInput: React.FC = () => { - + { + localStorage.setItem("year", e.target.value); + }} + placeholder="YYYY" + /> - + { + localStorage.setItem("month", e.target.value); + }} + placeholder="MM" + /> - + { + localStorage.setItem("day", e.target.value); + }} + placeholder="DD" + /> diff --git a/src/components/create/TeamButton.tsx b/src/components/create/TeamButton.tsx index d5258bf..2b1b4ee 100644 --- a/src/components/create/TeamButton.tsx +++ b/src/components/create/TeamButton.tsx @@ -4,8 +4,14 @@ import * as S from "./style"; export default function TeamButton() { const [count, setCount] = useState(0); - const increment = () => setCount(count + 1); - const decrement = () => setCount(count > 0 ? count - 1 : 0); + const increment = () => { + localStorage.setItem("member_count", String(count + 1)); + setCount(count + 1); + }; + const decrement = () => { + localStorage.setItem("member_count", String(count - 1)); + setCount(count > 0 ? count - 1 : 0); + }; return ( diff --git a/src/components/invite/urlCopy/UrlCopy.tsx b/src/components/invite/urlCopy/UrlCopy.tsx index 7ebb42c..f9def8f 100644 --- a/src/components/invite/urlCopy/UrlCopy.tsx +++ b/src/components/invite/urlCopy/UrlCopy.tsx @@ -3,8 +3,9 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import * as S from "./style"; export default function UrlCopy() { - const url = "https://www.syncup.com/234asdf94al4"; - + const url = `https://f4-front.vercel.app/invite/${localStorage.getItem( + "team_id" + )}/${localStorage.getItem("member_count")}`; const handleCopy = async () => { try { await navigator.clipboard.writeText(url); diff --git a/src/components/invite/urlCopy/style.ts b/src/components/invite/urlCopy/style.ts index 1e6a841..7b2babe 100644 --- a/src/components/invite/urlCopy/style.ts +++ b/src/components/invite/urlCopy/style.ts @@ -6,7 +6,7 @@ export const Container = styled.div` justify-content: space-between; width: 350px; - height: 40px; + height: 60px; border-radius: 10px; border: 1px solid #ced4da; background: #e9ecef; diff --git a/src/pages/create/Create.tsx b/src/pages/create/Create.tsx index 1413def..ee693f9 100644 --- a/src/pages/create/Create.tsx +++ b/src/pages/create/Create.tsx @@ -2,6 +2,7 @@ import styled from "styled-components"; import Button from "@components/common/button/Button"; import HintText from "@components/common/hintText/HintText1"; import TeamButton from "@components/create/TeamButton"; +import { instance } from "@apis/instance"; const Container = styled.div` height: calc(100vh - 80px); @@ -18,6 +19,16 @@ const ButtonLayout = styled.div` `; const Create: React.FC = () => { + const postData = async () => { + try { + const response = await instance.post("/teams/", { + member_count: localStorage.getItem("member_count"), + }); + localStorage.setItem("team_id", response.data.team_id); + } catch (err) { + console.log(err); + } + }; return ( <> @@ -30,7 +41,12 @@ const Create: React.FC = () => { -