Skip to content

Commit

Permalink
Merge pull request #31 from moyeothon/develop
Browse files Browse the repository at this point in the history
Deploy
  • Loading branch information
sayyyho authored Nov 2, 2024
2 parents b3e91db + 30cf8d5 commit a8e5b9e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
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

0 comments on commit a8e5b9e

Please sign in to comment.