generated from Team-INSERT/Repository-generator-Frontend
-
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 pull request #84 from Team-INSERT/feat/calender
캘린더 페이지 완성
- Loading branch information
Showing
20 changed files
with
472 additions
and
41 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 |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import { XIcon } from "@/assets/icons"; | ||
import { Column } from "@/components/Flex"; | ||
import { Button, Input, Select } from "@/components/atoms"; | ||
import useModal from "@/hooks/useModal"; | ||
import useUser from "@/hooks/useUser"; | ||
import { useAddCalenderPlanMutation } from "@/page/calender/services/mutation.service"; | ||
import { color, flex, font } from "@/styles"; | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
|
||
interface IPlanAddModalProps { | ||
date: string; | ||
} | ||
|
||
const PlanAddModal = ({ date }: IPlanAddModalProps) => { | ||
const { closeModal } = useModal(); | ||
const { mutate } = useAddCalenderPlanMutation(); | ||
const { user } = useUser(); | ||
const [planType, setPlanType] = React.useState("CLASS"); | ||
const [title, setTitle] = React.useState(""); | ||
const textareaRef = React.useRef<HTMLTextAreaElement>(null); | ||
|
||
const handleAddButtonClick = () => { | ||
mutate({ | ||
title, | ||
priority: 0, | ||
date, | ||
color: "#000", | ||
type: planType, | ||
grade: user.grade, | ||
classNumber: user.classNum, | ||
}); | ||
}; | ||
|
||
React.useEffect(() => { | ||
if (textareaRef.current) textareaRef.current.focus(); | ||
}, []); | ||
|
||
return ( | ||
<Container> | ||
<Header> | ||
<BambooTitle /> | ||
<CloseButton> | ||
<XIcon onClick={closeModal} /> | ||
</CloseButton> | ||
</Header> | ||
<Body> | ||
<Input | ||
label="일정 내용" | ||
placeholder="간략한 일정 내용을 입력해주세요." | ||
onChange={(e) => setTitle(e.target.value)} | ||
value={title} | ||
/> | ||
<Column gap="6px"> | ||
<StyledTitle>일정 분류</StyledTitle> | ||
<Select | ||
label="" | ||
width="100px" | ||
options={["CLASS", "GRADE", "SCHOOL"]} | ||
defaultOption={planType} | ||
handler={setPlanType} | ||
/> | ||
</Column> | ||
</Body> | ||
<PlanButtonBox> | ||
<Button onClick={handleAddButtonClick} color={color.primary_blue}> | ||
추가하기 | ||
</Button> | ||
</PlanButtonBox> | ||
</Container> | ||
); | ||
}; | ||
|
||
const Container = styled.div` | ||
width: 40vw; | ||
height: fit-content; | ||
overflow-y: scroll; | ||
background-color: ${color.white}; | ||
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.2); | ||
border-radius: 8px; | ||
${flex.COLUMN}; | ||
`; | ||
|
||
const Header = styled.header` | ||
width: 100%; | ||
padding: 10px 0 10px 18px; | ||
display: flex; | ||
align-items: center; | ||
box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.15); | ||
`; | ||
|
||
const BambooTitle = styled.div` | ||
${font.p2}; | ||
font-weight: 500; | ||
&:after { | ||
content: "📆 일정 추가하기"; | ||
} | ||
`; | ||
|
||
const Body = styled.div` | ||
padding: 16px 28px; | ||
${flex.COLUMN}; | ||
gap: 12px; | ||
`; | ||
|
||
const CloseButton = styled.button` | ||
margin: 0 20px 0 auto; | ||
`; | ||
|
||
const PlanButtonBox = styled.div` | ||
width: fit-content; | ||
margin: 0 16px 16px auto; | ||
`; | ||
|
||
const StyledTitle = styled.span` | ||
${font.p3}; | ||
font-weight: 500; | ||
`; | ||
|
||
export default PlanAddModal; |
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,14 @@ | ||
const getClassName = (classname: string) => { | ||
switch (classname) { | ||
case "GRADE": | ||
return "학년"; | ||
case "CLASS": | ||
return "학급"; | ||
case "SCHOOL": | ||
return "학교"; | ||
default: | ||
return classname; | ||
} | ||
}; | ||
|
||
export default getClassName; |
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,5 @@ | ||
const getDay = (date: string) => { | ||
return date.split("-")[2]; | ||
}; | ||
|
||
export default getDay; |
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,9 @@ | ||
export default interface ICalender { | ||
title: string; | ||
priority: number; | ||
date: string; | ||
color: string; | ||
type: string; | ||
grade: number; | ||
classNumber: number; | ||
} |
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,6 @@ | ||
import IPlan from "./plan.interface"; | ||
|
||
export default interface ICalenderItem { | ||
date: string; | ||
plans: Array<IPlan>; | ||
} |
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,11 @@ | ||
import ICalender from "./calender.interface"; | ||
|
||
export default interface IPlan extends ICalender { | ||
id: number; | ||
type: string; | ||
user: { | ||
id: number; | ||
nickName: string; | ||
profileImage: string; | ||
}; | ||
} |
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
Oops, something went wrong.