-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
1,113 additions
and
322 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
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
46 changes: 46 additions & 0 deletions
46
apps/admin/app/studies/[studyId]/@modal/(.)announcement-delete/page.tsx
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,46 @@ | ||
"use client"; | ||
|
||
import { Flex } from "@styled-system/jsx"; | ||
import { Modal, Space, Text } from "@wow-class/ui"; | ||
import { useModalRoute } from "@wow-class/ui/hooks"; | ||
import { studyApi } from "apis/study/studyApi"; | ||
import { tags } from "constants/tags"; | ||
import { useSearchParams } from "next/navigation"; | ||
import { revalidateTagByName } from "utils/revalidateTagByName"; | ||
import Button from "wowds-ui/Button"; | ||
|
||
const AnnouncementDeleteModal = () => { | ||
const searchParams = useSearchParams(); | ||
|
||
const studyAnnouncementId = searchParams.get("studyAnnouncementId"); | ||
|
||
const { closeModal } = useModalRoute(); | ||
|
||
const handleClickDeleteButton = async () => { | ||
const result = await studyApi.deleteStudyAnnouncement( | ||
Number(studyAnnouncementId) | ||
); | ||
if (result.success) { | ||
await revalidateTagByName(tags.announcements); | ||
closeModal(); | ||
} | ||
}; | ||
|
||
return ( | ||
<Modal> | ||
<Flex direction="column" textAlign="center" width="21rem"> | ||
<Text typo="h1">공지를 삭제하시겠어요?</Text> | ||
<Space height={33} /> | ||
|
||
<Flex gap="sm"> | ||
<Button variant="outline" onClick={closeModal}> | ||
취소 | ||
</Button> | ||
<Button onClick={handleClickDeleteButton}>삭제하기</Button> | ||
</Flex> | ||
</Flex> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default AnnouncementDeleteModal; |
71 changes: 71 additions & 0 deletions
71
apps/admin/app/studies/[studyId]/@modal/(.)announcement-modify/page.tsx
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,71 @@ | ||
"use client"; | ||
|
||
import { Flex } from "@styled-system/jsx"; | ||
import { Modal, Space, Text } from "@wow-class/ui"; | ||
import { useModalRoute } from "@wow-class/ui/hooks"; | ||
import { studyApi } from "apis/study/studyApi"; | ||
import { tags } from "constants/tags"; | ||
import { useSearchParams } from "next/navigation"; | ||
import { useState } from "react"; | ||
import type { StudyAnnouncementType } from "types/entities/study"; | ||
import { revalidateTagByName } from "utils/revalidateTagByName"; | ||
import Button from "wowds-ui/Button"; | ||
import TextField from "wowds-ui/TextField"; | ||
|
||
const AnnouncementModifyModal = () => { | ||
const searchParams = useSearchParams(); | ||
const [studyAnnouncement, setStudyAnnouncement] = | ||
useState<StudyAnnouncementType>({ | ||
title: "", | ||
link: "", | ||
}); | ||
|
||
const studyAnnouncementId = searchParams.get("studyAnnouncementId"); | ||
|
||
const { closeModal } = useModalRoute(); | ||
|
||
const handleClickModifyButton = async () => { | ||
const result = await studyApi.modifyStudyAnnouncement( | ||
Number(studyAnnouncementId), | ||
studyAnnouncement | ||
); | ||
if (result.success) { | ||
await revalidateTagByName(tags.announcements); | ||
closeModal(); | ||
} | ||
}; | ||
|
||
return ( | ||
<Modal> | ||
<Flex direction="column" textAlign="center" width="21rem"> | ||
<Text typo="h1">공지를 수정해주세요</Text> | ||
<Space height={29} /> | ||
<Flex direction="column" gap="1.125rem"> | ||
<TextField | ||
label="공지 제목" | ||
placeholder="입력해주세요" | ||
onChange={(value) => { | ||
setStudyAnnouncement({ ...studyAnnouncement, title: value }); | ||
}} | ||
/> | ||
<TextField | ||
label="공지 링크" | ||
placeholder="http://example.com" | ||
onChange={(value) => { | ||
setStudyAnnouncement({ ...studyAnnouncement, link: value }); | ||
}} | ||
/> | ||
</Flex> | ||
<Space height={28} /> | ||
<Flex gap="sm"> | ||
<Button variant="outline" onClick={closeModal}> | ||
취소 | ||
</Button> | ||
<Button onClick={handleClickModifyButton}>수정하기</Button> | ||
</Flex> | ||
</Flex> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default AnnouncementModifyModal; |
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 Default = () => { | ||
return null; | ||
}; | ||
|
||
export default Default; |
87 changes: 87 additions & 0 deletions
87
apps/admin/app/studies/[studyId]/_components/announcement/CreateStudyAnnouncement.tsx
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,87 @@ | ||
"use client"; | ||
|
||
import { css } from "@styled-system/css"; | ||
import { Flex } from "@styled-system/jsx"; | ||
import { Text } from "@wow-class/ui"; | ||
import { studyApi } from "apis/study/studyApi"; | ||
import { tags } from "constants/tags"; | ||
import { useState } from "react"; | ||
import type { StudyAnnouncementType } from "types/entities/study"; | ||
import { revalidateTagByName } from "utils/revalidateTagByName"; | ||
import Button from "wowds-ui/Button"; | ||
import TextField from "wowds-ui/TextField"; | ||
|
||
const CreateStudyAnnouncement = ({ studyId }: { studyId: string }) => { | ||
const [studyAnnouncement, setStudyAnnouncement] = | ||
useState<StudyAnnouncementType>({ | ||
title: "", | ||
link: "", | ||
}); | ||
|
||
const handlePublishAnnouncement = async (studyId: string) => { | ||
const { success } = await studyApi.publishStudyAnnouncement( | ||
parseInt(studyId, 10), | ||
studyAnnouncement | ||
); | ||
if (success) { | ||
revalidateTagByName(tags.announcements); | ||
setStudyAnnouncement({ | ||
title: "", | ||
link: "", | ||
}); | ||
} else { | ||
console.log("공지 생성 실패"); | ||
} | ||
}; | ||
return ( | ||
<div className={StudyAnnouncementBoxStyle}> | ||
<Text typo="h2">공지를 작성해주세요.</Text> | ||
<Flex gap="xl" justify="space-between" width="100%"> | ||
<Flex gap="sm" justifyContent="stretch" width="100%"> | ||
<TextField | ||
label="공지 제목" | ||
placeholder="입력해주세요" | ||
style={{ width: "100%" }} | ||
value={studyAnnouncement.title} | ||
onChange={(value) => { | ||
setStudyAnnouncement({ ...studyAnnouncement, title: value }); | ||
}} | ||
/> | ||
<TextField | ||
label="공지 링크" | ||
placeholder="http://example.com" | ||
style={{ width: "100%" }} | ||
value={studyAnnouncement.link} | ||
onChange={(value) => { | ||
setStudyAnnouncement({ ...studyAnnouncement, link: value }); | ||
}} | ||
/> | ||
</Flex> | ||
<Button | ||
size="sm" | ||
style={{ minWidth: "92px", maxHeight: "38px", marginTop: "23px" }} | ||
variant="solid" | ||
disabled={ | ||
studyAnnouncement.link === "" || studyAnnouncement.title === "" | ||
} | ||
onClick={() => handlePublishAnnouncement(studyId)} | ||
> | ||
공지 발행 | ||
</Button> | ||
</Flex> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CreateStudyAnnouncement; | ||
|
||
const StudyAnnouncementBoxStyle = css({ | ||
width: "100%", | ||
height: "171px", | ||
backgroundColor: "backgroundAlternative", | ||
borderRadius: "md", | ||
display: "flex", | ||
flexDirection: "column", | ||
gap: "24px", | ||
padding: "30px", | ||
}); |
Oops, something went wrong.