-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/Skhuthon/Skhuthon_0th_TEAM0…
- Loading branch information
Showing
7 changed files
with
242 additions
and
11 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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 |
---|---|---|
@@ -0,0 +1,141 @@ | ||
import { ChangeEvent, useState, useRef, useEffect } from "react"; | ||
import { useLocation, useNavigate } from "react-router-dom"; | ||
import styled from "styled-components"; | ||
import Toast from "@/components/common/Toast"; | ||
import Input from "@/components/common/Input/Input"; | ||
import Button from "@/components/common/Button"; | ||
import TextArea from "@/components/common/Input/TextArea"; | ||
|
||
const Update = () => { | ||
const location = useLocation(); | ||
const navigate = useNavigate(); | ||
|
||
const [writeState, setWriteState] = useState<"create" | "update">("create"); | ||
const [title, setTitle] = useState(""); | ||
const [content, setContent] = useState(""); | ||
const [sing, setSing] = useState(""); | ||
const [date, setDate] = useState(""); | ||
|
||
const handleEditButton = () => { | ||
mutate({ | ||
title: "", | ||
content: "", | ||
sing: "", | ||
date: "", | ||
}); | ||
}; | ||
|
||
const handleCancelButton = () => { | ||
navigate(-1); | ||
}; | ||
|
||
const onChangeTitle = (e: ChangeEvent<HTMLInputElement>) => { | ||
setTitle(e.target.value); | ||
}; | ||
const onChangeContent = (e: ChangeEvent<HTMLTextAreaElement>) => { | ||
setContent(e.target.value); | ||
}; | ||
|
||
const onChangeSing = (e: ChangeEvent<HTMLInputElement>) => { | ||
setSing(e.target.value); | ||
}; | ||
const onChangeDate = (e: ChangeEvent<HTMLInputElement>) => { | ||
setDate(e.target.value); | ||
}; | ||
|
||
useEffect(() => { | ||
if (location && location.state?.update) { | ||
setWriteState("update"); | ||
// todo : 다이어리 글 상태관리 | ||
} else { | ||
setWriteState("create"); | ||
} | ||
}, [location]); | ||
|
||
return ( | ||
<> | ||
<CreateDiv> | ||
<StyledH1>일기 {writeState === "create" ? "작성" : "수정"}</StyledH1> | ||
<Input | ||
value={title} | ||
placeholder="제목을 입력해주세요" | ||
onChangeValue={onChangeTitle} | ||
/> | ||
<br /> | ||
<TextArea | ||
value={content} | ||
placeholder="내용을 입력해주세요" | ||
onChangeValue={onChangeContent} | ||
/> | ||
<br /> | ||
<Input | ||
value={sing} | ||
placeholder="노래를 입력해주세요(선택)" | ||
onChangeValue={onChangeSing} | ||
/> | ||
<br /> | ||
<Input | ||
value={date} | ||
type="date" | ||
placeholder="날짜를 입력해주세요" | ||
onChangeValue={onChangeDate} | ||
/> | ||
<br /> | ||
<ButtonWrapper> | ||
<Button | ||
buttonColor="point" | ||
buttonStyle="default" | ||
onClick={() => navigate(-1)} | ||
> | ||
취소 | ||
</Button> | ||
<Button | ||
buttonColor="main" | ||
buttonStyle="default" | ||
onClick={() => { | ||
navigate("/"); | ||
}} | ||
disabled={ | ||
!title || // 제목이 없거나 | ||
!content || // 내용이 없거나 | ||
!date // 날짜가 없을 경우 | ||
} | ||
> | ||
{writeState === "update" ? "취소하기" : "수정하기"} | ||
</Button> | ||
</ButtonWrapper> | ||
</CreateDiv> | ||
</> | ||
); | ||
}; | ||
|
||
export default Update; | ||
|
||
export const CreateDiv = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100%; | ||
width: 100%; | ||
`; | ||
|
||
function mutate(arg0: { | ||
title: string; | ||
content: string; | ||
sing: string; | ||
date: string; | ||
}) { | ||
throw new Error("Function not implemented."); | ||
} | ||
|
||
const StyledH1 = styled.div` | ||
padding: 50px; | ||
font-size: 60pt; | ||
`; | ||
|
||
const ButtonWrapper = styled.div` | ||
display: flex; | ||
gap: 10px; | ||
width: 100%; | ||
`; |
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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { useLocation, useNavigate } from "react-router-dom"; | ||
import { ChangeEvent, useState, useRef, useEffect } from "react"; | ||
import styled from "styled-components"; | ||
import HeartIcon from "@/assets/svg/Heart.svg"; | ||
|
||
const list = () => { | ||
const location = useLocation(); | ||
const navigate = useNavigate(); | ||
|
||
const [title, setTitle] = useState(""); | ||
const [date, setDate] = useState(""); | ||
|
||
const handleEditButton = () => { | ||
mutate({ | ||
title: "", | ||
date: "", | ||
}); | ||
}; | ||
|
||
return ( | ||
<> | ||
<ListDiv> | ||
<StyledH3>제목: {title}</StyledH3> | ||
<br /> | ||
<StyledH5>날짜: {date}</StyledH5> | ||
<div>🤍 6</div> | ||
<div>💬 5</div> | ||
</ListDiv> | ||
<ListDiv> | ||
<StyledH3>제목: {title}</StyledH3> | ||
<br /> | ||
<StyledH5>날짜: {date}</StyledH5> | ||
<div>🤍 6</div> | ||
<div>💬 5</div> | ||
</ListDiv> | ||
<ListDiv> | ||
<StyledH3>제목: {title}</StyledH3> | ||
<br /> | ||
<StyledH5>날짜: {date}</StyledH5> | ||
<div>🤍 6</div> | ||
<div>💬 5</div> | ||
</ListDiv> | ||
<ListDiv> | ||
<StyledH3>제목: {title}</StyledH3> | ||
<br /> | ||
<StyledH5>날짜: {date}</StyledH5> | ||
<div>🤍 6</div> | ||
<div>💬 5</div> | ||
</ListDiv> | ||
</> | ||
); | ||
}; | ||
|
||
export default list; | ||
|
||
function mutate(arg0: { title: string; date: string }) { | ||
throw new Error("Function not implemented."); | ||
} | ||
|
||
export const ListDiv = styled.div` | ||
width: 100%; | ||
height: 100px; | ||
margin-top: 100px; | ||
padding: 10px; | ||
border-bottom: ${({ theme }) => theme.boxBorder.bookBorder}; | ||
border-radius: 4px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
`; | ||
|
||
const StyledH3 = styled.div` | ||
margin-left: 20px; | ||
padding: 10px; | ||
font-size: 30pt; | ||
`; | ||
|
||
const StyledH5 = styled.div` | ||
margin-right: 300px; | ||
padding: 10px; | ||
font-size: 20pt; | ||
`; |