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 = () => {
-
+
>
);
diff --git a/src/pages/invite/Invite.tsx b/src/pages/invite/Invite.tsx
index 34c544a..8df7b51 100644
--- a/src/pages/invite/Invite.tsx
+++ b/src/pages/invite/Invite.tsx
@@ -1,9 +1,11 @@
import Button from "@components/common/button/Button";
import HintText2 from "@components/common/hintText/HintText2";
-import ActivatedProfile from "@components/invite/profile/ActivatedProfile";
import DeactivatedProfile from "@components/invite/profile/DeactivatedProfile";
import UrlCopy from "@components/invite/urlCopy/UrlCopy";
import styled from "styled-components";
+import { useParams } from "react-router-dom";
+import { instance } from "@apis/instance";
+import { useEffect } from "react";
export const Container = styled.div`
width: 350px;
@@ -32,6 +34,29 @@ export const ProfileList = styled.div`
`;
const Invite: React.FC = () => {
+ let { team, count } = useParams();
+ if (team === undefined) {
+ team = "";
+ }
+ if (count === undefined) {
+ count = "1";
+ }
+ localStorage.setItem("team_id", team);
+ localStorage.setItem("member_count", count);
+ useEffect(() => {
+ fetchData();
+ }, []);
+ const fetchData = async () => {
+ try {
+ const response = await instance.get(
+ `/teams/${localStorage.getItem("team_id")}/profiles/`
+ );
+ console.log(response);
+ } catch (err) {
+ console.log(err);
+ }
+ };
+
return (
@@ -49,17 +74,12 @@ const Invite: React.FC = () => {
프로필 등록을 하지 않으면 다음을 진행할 수 없어요."
/>
-
-
-
-
-
-
+ {Array.from(
+ { length: Number(localStorage.getItem("member_count")) },
+ (_, index) => (
+
+ )
+ )}
diff --git a/src/pages/login/Login.tsx b/src/pages/login/Login.tsx
index 8d4336e..5bdb9ea 100644
--- a/src/pages/login/Login.tsx
+++ b/src/pages/login/Login.tsx
@@ -5,6 +5,7 @@ import HintText from "@components/common/hintText/HintText1";
import React from "react";
import styled from "styled-components";
import Button from "@components/common/button/Button";
+import { instance } from "@apis/instance";
const Container = styled.div`
height: calc(100vh - 80px);
@@ -27,6 +28,27 @@ const ButtonLayout = styled.div`
`;
const Login: React.FC = () => {
+ const handleNameChange = (data: string) => {
+ localStorage.setItem("name", data);
+ };
+ const postData = async () => {
+ for (let i = 0; i < 2; i++) {
+ try {
+ const response = await instance.post(
+ `/teams/${localStorage.getItem("team_id")}/login/`,
+ {
+ user_name: localStorage.getItem("name"),
+ birth_date: `${localStorage.getItem("year")}-${localStorage.getItem(
+ "month"
+ )}-${localStorage.getItem("day")}`,
+ }
+ );
+ localStorage.setItem("profile_id", response.data.profile_id);
+ } catch (err) {
+ console.log(err);
+ }
+ }
+ };
return (
<>
@@ -36,12 +58,25 @@ const Login: React.FC = () => {
paragraph="팀을 참가할 때 간단한 정보를 입력받아요."
/>
-
+ {
+ handleNameChange(e.target.value);
+ }}
+ />
-
+
>
);