-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
๊ด๋ฆฌ์ ๊ณต์ง์ฌํญ ์กฐํ, ์์ฑ, ์ญ์ , ์์ ๊ธฐ๋ฅ ์ถ๊ฐํ์ต๋๋ค.
- Loading branch information
Showing
6 changed files
with
445 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React, { useState } from 'react'; | ||
import { fetchAPI } from '../../global/utils/apiUtil'; | ||
import { showSuccessToast } from '../toast/toast'; | ||
|
||
interface NoticeCreateProps { | ||
onBack: () => void; | ||
} | ||
|
||
export default function NoticeCreate({ onBack }: NoticeCreateProps) { | ||
const [title, setTitle] = useState(''); | ||
const [content, setContent] = useState(''); | ||
|
||
const handleTitleChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
setTitle(e.target.value); | ||
}; | ||
|
||
const handleContentChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => { | ||
setContent(e.target.value); | ||
}; | ||
|
||
const handleSave = async () => { | ||
const body = { | ||
title, | ||
content, | ||
}; | ||
try { | ||
await fetchAPI('/api/notice/admin', 'POST', body); | ||
showSuccessToast('๊ณต์ง์ฌํญ์ด ์ฑ๊ณต์ ์ผ๋ก ์์ฑ๋์์ต๋๋ค.'); | ||
onBack(); | ||
} catch (error) { | ||
console.error('Error:', error); | ||
showSuccessToast('๊ณต์ง์ฌํญ ์์ฑ์ ์คํจํ์ต๋๋ค. ๋ค์ ์๋ํด ์ฃผ์ธ์.'); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="ad-notice-detail-container"> | ||
<div className="ad-notice-cnt notice-length">๊ณต์ง ์์ฑ</div> | ||
<input | ||
type="text" | ||
name="title" | ||
value={title} | ||
onChange={handleTitleChange} | ||
className='ad-notice-detail-title' | ||
placeholder="์ ๋ชฉ์ ์ ๋ ฅํ์ธ์" | ||
style={{backgroundColor:"white"}} | ||
/> | ||
<textarea | ||
name="content" | ||
value={content} | ||
onChange={handleContentChange} | ||
className='ad-notice-detail-content notice-textarea' | ||
placeholder="๋ด์ฉ์ ์ ๋ ฅํ์ธ์" | ||
/> | ||
<div className='notice-button-container'> | ||
<button className='orange-white-btn' onClick={handleSave}>์ ์ฅํ๊ธฐ</button> | ||
<button className='white-orange-btn' onClick={onBack}>์ทจ์</button> | ||
</div> | ||
</div> | ||
); | ||
} |
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,89 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { fetchAPI } from '../../global/utils/apiUtil'; | ||
import { showSuccessToast } from '../toast/toast'; | ||
interface Feedback { | ||
noticeId: number; | ||
noticeTitle: string; | ||
noticeContent: string; | ||
noticeViews: string; | ||
noticeStatus: boolean; | ||
createdAt: string; | ||
} | ||
|
||
interface NoticeDetailProps { | ||
feedback: Feedback; | ||
onBack: () => void; | ||
onSave: (updatedFeedback: Feedback) => void; | ||
} | ||
|
||
export default function NoticeDetail({ feedback, onBack, onSave }: NoticeDetailProps) { | ||
const [isEditing, setIsEditing] = useState(false); | ||
const [editedFeedback, setEditedFeedback] = useState<Feedback>(feedback); | ||
|
||
useEffect(() => { | ||
setEditedFeedback(feedback); | ||
}, [feedback]); | ||
|
||
const handleEditChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => { | ||
const { name, value } = e.target; | ||
setEditedFeedback(prev => ({ ...prev, [name]: value })); | ||
}; | ||
|
||
const handleSave = async () => { | ||
const body = { | ||
title: editedFeedback.noticeTitle, | ||
content: editedFeedback.noticeContent, | ||
noticeStatus: editedFeedback.noticeStatus, | ||
}; | ||
try { | ||
await fetchAPI(`/api/notice/admin/${editedFeedback.noticeId}`, 'PATCH', body); | ||
onSave(editedFeedback); | ||
setIsEditing(false); | ||
} catch (error) { | ||
console.error('Error:', error); | ||
showSuccessToast('์์ ์ ์คํจํ์ต๋๋ค. ๋ค์ ์๋ํด ์ฃผ์ธ์.'); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="ad-notice-detail-container"> | ||
<div className="ad-notice-cnt notice-length">๊ณต์ง ์์ธ</div> | ||
{isEditing ? ( | ||
<> | ||
|
||
<input className='ad-notice-detail-title' | ||
type="text" | ||
name="noticeTitle" | ||
value={editedFeedback.noticeTitle} | ||
onChange={handleEditChange} | ||
style={{backgroundColor:"white"}} | ||
/> | ||
|
||
<textarea | ||
name="noticeContent" | ||
value={editedFeedback.noticeContent} | ||
onChange={handleEditChange} | ||
className='ad-notice-detail-content notice-textarea' | ||
|
||
/> | ||
<div className='notice-button-container'> | ||
<button className='orange-white-btn' onClick={handleSave}>์ ์ฅํ๊ธฐ</button> | ||
<button className='white-orange-btn' onClick={() => setIsEditing(false)}>์ทจ์</button> | ||
</div> | ||
</> | ||
) : ( | ||
<> | ||
<div className='ad-notice-detail-title'> | ||
<div>{feedback.noticeTitle}</div> | ||
<div>{feedback.createdAt}</div> | ||
</div> | ||
<div className='ad-notice-detail-content'>{feedback.noticeContent}</div> | ||
<div className='notice-button-container'> | ||
<button className='orange-white-btn' onClick={onBack}>๋ค๋ก๊ฐ๊ธฐ</button> | ||
<button className='white-orange-btn' onClick={() => setIsEditing(true)}>์์ ํ๊ธฐ</button> | ||
</div> | ||
</> | ||
)} | ||
</div> | ||
); | ||
} |
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,129 @@ | ||
.ad-notice-detail-container{ | ||
width: 100%; | ||
height: 100%; | ||
margin-top: 27rem; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
.ad-notice-cnt { | ||
font-size : 2.5rem; | ||
letter-spacing: -1.5px; | ||
font-family: Pretendard-ExtraBold; | ||
color : #000000; | ||
} | ||
.notice-length{ | ||
width: 90%; | ||
margin: 2rem; | ||
} | ||
.notice-button-container{ | ||
width: 90%; | ||
display: flex; | ||
// flex-direction: column; | ||
justify-content: flex-end; | ||
} | ||
|
||
.ad-notice-button-container{ | ||
margin-top: 1rem; | ||
margin-right: 2rem; | ||
display: flex; | ||
align-items: center; | ||
justify-content: flex-end; | ||
} | ||
|
||
.ad-notice-cnt-num { | ||
color: #FF8D1D; | ||
} | ||
|
||
.ad-notice-result { | ||
border: 1px solid gray; | ||
|
||
height: fit-content; | ||
min-height: 73%; | ||
} | ||
|
||
.ad-notice-searchResult-header, | ||
.ad-notice-searchResult-item { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
padding: 8px; | ||
border-bottom: 1px solid #ccc; | ||
height: 4.76rem; | ||
span { | ||
flex: 1; | ||
text-align: center; | ||
font-size: 1.5rem; | ||
} | ||
} | ||
|
||
.ad-notice-detail-title{ | ||
padding: 2rem; | ||
width: 90%; | ||
min-height: 5rem; | ||
background-color: #F4F3F3; | ||
font-size: 2rem; | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
margin-bottom: 2rem; | ||
} | ||
.ad-notice-header{ | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
margin: 2rem; | ||
} | ||
|
||
.ad-notice-detail-content{ | ||
padding: 3rem 2rem; | ||
width: 90%; | ||
background-color: #F4F3F3; | ||
font-size: 2rem; | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
word-break: keep-all; | ||
white-space : pre-wrap; | ||
} | ||
|
||
.notice-textarea{ | ||
background-color: white; | ||
resize: none; | ||
height: 40% ; | ||
} | ||
|
||
.orange-white-btn{ | ||
width: 157px; | ||
height: 52px; | ||
border-radius: 0; | ||
background-color: #FF8D1D !important; | ||
font-size : 2rem; | ||
letter-spacing: -1.5px; | ||
font-family: Pretendard-ExtraBold; | ||
color : #FFFFFF; | ||
} | ||
|
||
.white-orange-btn{ | ||
width: 157px; | ||
height: 52px; | ||
border-radius: 0; | ||
background-color: #FFFFFF !important; | ||
font-size : 2rem; | ||
letter-spacing: -1.5px; | ||
font-family: Pretendard-ExtraBold; | ||
color :#FF8D1D !important; | ||
border : 1px solid #FF8D1D; | ||
} | ||
.white-orange-border-btn{ | ||
width: 157px; | ||
height: 52px; | ||
border-radius: 0; | ||
background-color: #FFFFFF !important; | ||
font-size : 2rem; | ||
letter-spacing: -1.5px; | ||
font-family: Pretendard-ExtraBold; | ||
color :#FF8D1D !important; | ||
border : 1px solid #FF8D1D; | ||
margin:0; | ||
} |
Oops, something went wrong.