-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/#3
- Loading branch information
Showing
3 changed files
with
119 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,115 @@ | ||
const ToastNotice = () => { | ||
return <div>toast notice</div>; | ||
import { Button } from "@chakra-ui/react"; | ||
import { useNavigate } from "react-router-dom"; | ||
import styled from "styled-components"; | ||
import useFetch from "../../../hooks/useFetch"; | ||
|
||
const Toast = styled.div` | ||
border-radius: 16px; | ||
display: flex; | ||
justify-content: center; | ||
flex-direction: column; | ||
position: absolute; | ||
top: 2rem; | ||
left: 2rem; | ||
background: #cdcdcd; | ||
width: 400px; | ||
height: 150px; | ||
padding: 1.5rem; | ||
& > div:first-child { | ||
display: flex; | ||
} | ||
& > div:last-child { | ||
display: flex; | ||
} | ||
`; | ||
|
||
const Image = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
font-size: 3rem; | ||
`; | ||
|
||
const Title = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
flex-direction: column; | ||
& > div:first-child { | ||
font-weight: bold; | ||
} | ||
& > div:last-child { | ||
font-size: 0.8rem; | ||
} | ||
`; | ||
|
||
const ButtonWrap = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
`; | ||
|
||
interface Props { | ||
roomData: { | ||
id: string; | ||
name: string; | ||
host: string; | ||
bg: string; | ||
users: string[]; | ||
}; | ||
setToast: React.Dispatch<React.SetStateAction<boolean>>; | ||
} | ||
|
||
const ToastNotice: React.FC<Props> = ({ roomData, setToast }) => { | ||
const navigate = useNavigate(); | ||
|
||
const live = useFetch({ | ||
url: "https://fastcampus-chat.net/chat/leave", | ||
method: "PATCH", | ||
data: { | ||
chatId: roomData.id, | ||
}, | ||
start: false, | ||
}); | ||
|
||
return ( | ||
<Toast> | ||
<div> | ||
<Image>{roomData.bg}</Image> | ||
<Title> | ||
<div>{roomData.host} 님이 초대하였습니다.</div> | ||
<div>{roomData.name}</div> | ||
</Title> | ||
</div> | ||
<ButtonWrap> | ||
<Button | ||
marginRight="2rem" | ||
width="50%" | ||
onClick={() => { | ||
live.refresh(); | ||
setToast(false); | ||
}} | ||
> | ||
거절 | ||
</Button> | ||
<Button | ||
marginRight="2rem" | ||
width="50%" | ||
onClick={() => { | ||
navigate(`/game?gameId=${roomData.id}`); | ||
}} | ||
> | ||
수락 | ||
</Button> | ||
</ButtonWrap> | ||
</Toast> | ||
); | ||
}; | ||
|
||
export default ToastNotice; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters