Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy #31

Merged
merged 2 commits into from
Nov 2, 2024
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
9 changes: 5 additions & 4 deletions src/components/common/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ const Button: React.FC<ButtonProps> = ({
const navigate = useNavigate();
const handleClick = () => {
if (onClick) {
onClick(); // onClick이 존재하면 호출
}
if (link) {
navigate(link);
onClick();
} else {
if (link) {
navigate(link);
}
}
};

Expand Down
10 changes: 4 additions & 6 deletions src/pages/create/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ 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";
import { useNavigate } from "react-router-dom";

const Container = styled.div`
height: calc(100vh - 80px);
Expand All @@ -19,12 +20,14 @@ const ButtonLayout = styled.div`
`;

const Create: React.FC = () => {
const navigate = useNavigate();
const postData = async () => {
try {
const response = await instance.post("/teams/", {
member_count: localStorage.getItem("member_count"),
});
localStorage.setItem("team_id", response.data.team_id);
navigate("/login");
} catch (err) {
console.log(err);
}
Expand All @@ -41,12 +44,7 @@ const Create: React.FC = () => {
</Container>

<ButtonLayout>
<Button
onClick={postData}
type="submit"
link="/login"
name="팀 동기화 시작하기"
/>
<Button onClick={postData} type="submit" name="팀 동기화 시작하기" />
</ButtonLayout>
</>
);
Expand Down
5 changes: 4 additions & 1 deletion src/pages/login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import React from "react";
import styled from "styled-components";
import Button from "@components/common/button/Button";
import { instance } from "@apis/instance";
import { useNavigate } from "react-router-dom";

const Container = styled.div`
height: calc(100vh - 80px);
Expand All @@ -28,6 +29,7 @@ const ButtonLayout = styled.div`
`;

const Login: React.FC = () => {
const navigate = useNavigate();
const handleNameChange = (data: string) => {
localStorage.setItem("name", data);
};
Expand All @@ -45,6 +47,7 @@ const Login: React.FC = () => {
}
);
localStorage.setItem("profile_id", response.data.profile_id);
navigate(`/invite/${teamID}/${localStorage.getItem("member_count")}`);
} catch (err) {
console.log(err);
}
Expand Down Expand Up @@ -73,7 +76,7 @@ const Login: React.FC = () => {
<Button
onClick={postData}
type="submit"
link={`/invite/${teamID}/${localStorage.getItem("member_count")}`}
// link={}
name="팀 참가하기"
/>
</ButtonLayout>
Expand Down