Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/mypage: merge to dev #57

Merged
merged 21 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f73ae40
fix: Resolve missing @esbuild/darwin-arm64 module in vite.config.js
huisuu Sep 25, 2024
10d5624
fix: Resolve missing @esbuild/darwin-arm64 module in vite.config.js
huisuu Sep 25, 2024
c74fbb3
fix: Resolve missing @esbuild/darwin-arm64 module in vite.config.js
huisuu Sep 25, 2024
3045c11
feat: 내비바 AuthLinks 부분 구현, AuthContext 제작
huisuu Sep 25, 2024
5faec88
style: 로그인, 회원가입, 마이페이지 input 스타일 변경 & 정렬 문제 해결
huisuu Sep 27, 2024
0a64c5d
feat: scroll to section 구현 & .env 생성
huisuu Sep 28, 2024
161a605
chore: 코드 수정
huisuu Sep 29, 2024
7eb1842
feat: api.js 적용
huisuu Oct 6, 2024
82d856e
feat: Authorization 추가
huisuu Oct 6, 2024
8571742
chore: data field 수
huisuu Oct 6, 2024
26cf427
fix: 사용자 계정 삭제 프로세스 수정: AuthContext에서 로그아웃 처리
huisuu Oct 6, 2024
a60c84b
fix: alert -> useAlert 적용
huisuu Oct 7, 2024
527b645
feat: 로그인 및 회원가입 api 연동 로직 고치는 중
ArpaAP Oct 7, 2024
d07c342
Merge branch 'feat/mypage' of https://github.com/KERT-core/KERT_Intro…
ArpaAP Oct 7, 2024
85dafd9
fix: import 오류 수정
ArpaAP Oct 7, 2024
07d9b3f
Merge branch 'dev' of https://github.com/KERT-core/KERT_Introduction_…
whitedev7773 Oct 10, 2024
66d65d1
chore/APi 테스트를 위한 코드 일부 수정
whitedev7773 Oct 10, 2024
c8fc861
fix: description -> content로 속성 변경
ArpaAP Oct 10, 2024
b1e1df8
fix: HistoryPreview에 nullable 추가
ArpaAP Oct 10, 2024
00968cf
feat: 모든 GET/POST에 인증 토큰 포함
whitedev7773 Oct 11, 2024
f0d8594
fix: Components 소문자로 변경
whitedev7773 Oct 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .env.example

This file was deleted.

61 changes: 59 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"axios": "^1.7.4",
"prismjs": "^1.29.0",
"react": "^18.3.1",
"react-cookie": "^7.2.0",
"react-dom": "^18.3.1",
"react-hook-form": "^7.53.0",
"react-powerglitch": "^1.0.3",
Expand Down
70 changes: 41 additions & 29 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
// 내비바의 높이는 80px입니다.

import { Routes, Route, useLocation } from 'react-router-dom';
import { CookiesProvider } from 'react-cookie';

import { GlobalStyle } from './styles/global';
import { MainLayout } from './components/layouts/MainLayout';
import './styles/font.css';

import { AuthProvider } from './components/navigation/AuthContext';
import Navigator from './components/navigation/Navigation';

import MainPage from './pages/MainPage';
import NotFound from './pages/NotFound';

Expand All @@ -29,35 +33,43 @@ export default function App() {

return (
<>
<GlobalStyle />
<Routes>
<Route path="/" element={<MainLayout />}>
<Route index path="/" element={<MainPage />} />
<Route path="/developer" element={<DevDocument />} />
<Route path="/board">
<Route index path="/board" element={<Board />} />
<Route path="/board/new" element={<NewArticleEditor />} />
</Route>
<Route path="/articles/:id" element={<Article />} />
<Route path="/login" element={<Login />} />
<Route path="/signup" element={<SignUp />} />
<Route path="/mypage" element={<MyPage />} />
<Route path="*" element={<NotFound />} />

{/* 대시보드 페이지 */}
<Route element={<DashboardLayout location={location} />}>
<Route index path="/dashboard" element={<Dashboard.Home />} />
<Route path="/dashboard/history" element={<Dashboard.History />} />
<Route
path="/dashboard/executive"
element={<Dashboard.Executive />}
/>
<Route path="/dashboard/admin" element={<Dashboard.Admin />} />
<Route path="/dashboard/users" element={<Dashboard.Users />} />
<Route path="/dashboard/*" element={<NotFound />} />
</Route>
</Route>
</Routes>
<CookiesProvider>
<AuthProvider>
<GlobalStyle />
<Navigator />
<Routes>
<Route path="/" element={<MainLayout />}>
<Route index path="/" element={<MainPage />} />
<Route path="/developer" element={<DevDocument />} />
<Route path="/board">
<Route index path="/board" element={<Board />} />
<Route path="/board/new" element={<NewArticleEditor />} />
</Route>
<Route path="/articles/:id" element={<Article />} />
<Route path="/login" element={<Login />} />
<Route path="/signup" element={<SignUp />} />
<Route path="/mypage" element={<MyPage />} />
<Route path="*" element={<NotFound />} />

{/* 대시보드 페이지 */}
<Route element={<DashboardLayout location={location} />}>
<Route index path="/dashboard" element={<Dashboard.Home />} />
<Route
path="/dashboard/history"
element={<Dashboard.History />}
/>
<Route
path="/dashboard/executive"
element={<Dashboard.Executive />}
/>
<Route path="/dashboard/admin" element={<Dashboard.Admin />} />
<Route path="/dashboard/users" element={<Dashboard.Users />} />
<Route path="/dashboard/*" element={<NotFound />} />
</Route>
</Route>
</Routes>
</AuthProvider>
</CookiesProvider>
</>
);
}
6 changes: 3 additions & 3 deletions src/components/display/HistoryPreview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const HistoryElement = ({ history }) => {
{history.year}.{history.month}
</Text>
<Text size="m" color="white">
{history.description}
{history.content}
</Text>
</HistoryElementWrapper>
);
Expand All @@ -117,7 +117,7 @@ HistoryElement.propTypes = {
history: PropTypes.shape({
year: PropTypes.number.isRequired,
month: PropTypes.number.isRequired,
description: PropTypes.string.isRequired,
content: PropTypes.string.isRequired,
}).isRequired,
};

Expand Down Expand Up @@ -188,7 +188,7 @@ export const HistoryPreview = () => {
? sampleData[display_year]?.map((history, i) => (
<HistoryElement key={i} history={history} />
))
: data[display_year].map((history, i) => (
: data[display_year]?.map((history, i) => (
<HistoryElement key={i} history={history} />
))}
</HistoryListWrapper>
Expand Down
9 changes: 7 additions & 2 deletions src/components/display/dashboard/admin/AdminElement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export const AdminElement = ({ admin }) => {
const { openConfirm, closeConfirm } = useConfirm();

const { data, isLoading } = useQuery(`user-${admin.student_id}`, async () => {
const data = await API.GET(`/users/${admin.student_id}`);
const data = await API.GET(`/users/${admin.student_id}`, {
headers: { Authorization: localStorage.getItem('token') },
});
return { ...admin, ...data };
});

Expand Down Expand Up @@ -176,7 +178,10 @@ export const AdminElement = ({ admin }) => {
// 문제가 없다면 서버 요청 시작
showLoading({ message: '관리자 정보를 수정하는 중...' });

API.PUT(`/admin/${data.student_id}`, updated_admin)
API.PUT(`/admin/${data.student_id}`, {
body: updated_admin,
headers: { Authorization: localStorage.getItem('token') },
})
.then((api_res) => {
closeConfirm();
openAlert({
Expand Down
5 changes: 3 additions & 2 deletions src/components/display/dashboard/admin/EditAdmin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ export const EditAdmin = forwardRef(({ admin, ...props }, ref) => {
closeConfirm();
showLoading({ message: '관리자를 삭제하는 중...' });

API.DELETE(`/admin/${admin.student_id}`)
API.DELETE(`/admin/${admin.student_id}`, {
headers: { Authorization: localStorage.getItem('token') },
})
.then((api_res) => {
openAlert({
title: '관리자 삭제 완료',
Expand Down Expand Up @@ -164,7 +166,6 @@ export const EditAdmin = forwardRef(({ admin, ...props }, ref) => {
<div style={{ display: 'flex' }}>
<HintedInput
ref={ref.generation}
type="number"
label="가입 기수"
defaultValue={admin.generation}
onChange={(e) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/display/dashboard/history/AddHistory.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const AddHistory = forwardRef(({ ...props }, ref) => {
/>
</div>
<Input
ref={ref.description}
ref={ref.content}
label="내용"
placeholder="연혁 내용 입력"
defaultValue={history.description}
Expand Down
6 changes: 3 additions & 3 deletions src/components/display/dashboard/history/EditHistory.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const EditHistory = forwardRef(
return;
}

const [previewDesc, setPreviewDesc] = useState(history.description);
const [previewDesc, setPreviewDesc] = useState(history.content);

return (
<Wrapper>
Expand Down Expand Up @@ -79,9 +79,9 @@ export const EditHistory = forwardRef(
/>
</div>
<HintedInput
ref={ref.description}
ref={ref.content}
label="내용"
defaultValue={history.description}
defaultValue={history.content}
onChange={(e) => {
// 사용자가 내용을 변경하면 미리보기의 내용도 변경합니다.
setPreviewDesc(e.target.value);
Expand Down
17 changes: 11 additions & 6 deletions src/components/display/dashboard/history/HistoryElement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const HistoryElement = ({ history }) => {
const refs = {
year: useRef(),
month: useRef(),
description: useRef(),
content: useRef(),
};

// 연혁 요소를 눌렀을 때 이벤트
Expand All @@ -93,7 +93,7 @@ export const HistoryElement = ({ history }) => {
...history,
year: parseInt(refs.year.current.value),
month: parseInt(refs.month.current.value),
description: refs.description.current.value,
content: refs.content.current.value,
};

// 만약 변경된 내용 없이 기존과 같다면 중단
Expand All @@ -110,7 +110,7 @@ export const HistoryElement = ({ history }) => {
if (
!updated_history.year ||
!updated_history.month ||
!updated_history.description
!updated_history.content
) {
openAlert({
title: '정보 부족',
Expand All @@ -122,7 +122,10 @@ export const HistoryElement = ({ history }) => {
// 문제가 없다면 서버 요청 시작
showLoading({ message: '연혁을 수정하는 중...' });

API.PUT(`/histories/${history.id}`, updated_history)
API.PUT(`/histories/${history.history_id}`, {
body: updated_history,
headers: { Authorization: localStorage.getItem('token') },
})
.then((api_res) => {
closeConfirm();
openAlert({
Expand Down Expand Up @@ -154,7 +157,9 @@ export const HistoryElement = ({ history }) => {
closeConfirm();
showLoading({ message: '연혁을 삭제하는 중...' });

API.DELETE(`/histories/${history.id}`)
API.DELETE(`/histories/${history.history_id}`, {
headers: { Authorization: localStorage.getItem('token') },
})
.then((api_res) => {
openAlert({
title: '연혁 삭제됨',
Expand All @@ -177,7 +182,7 @@ export const HistoryElement = ({ history }) => {
return (
<CardWrapper onClick={() => onClick()}>
<Month>{history?.month}월</Month>
<Description>{history?.description}</Description>
<Description>{history?.content}</Description>
</CardWrapper>
);
};
6 changes: 3 additions & 3 deletions src/components/display/dashboard/history/UpdatedHistory.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ const Content = styled(Span).attrs({
export const UpdatedHistory = ({ current_history, updated_history }) => {
return (
<>
<ID>History ID {updated_history.id}</ID>
<ID>History ID {updated_history.history_id}</ID>
<Description>연혁이 다음과 같이 수정되었습니다.</Description>
{/* 기존 연혁 */}
<Display style={{ opacity: '0.5' }}>
<Date>
{current_history.year}년 {current_history.month}월
</Date>
<Content>{current_history.description}</Content>
<Content>{current_history.content}</Content>
</Display>
{/* 화살표 */}
<div style={{ margin: '10px 0', width: '100%', textAlign: 'center' }}>
Expand All @@ -61,7 +61,7 @@ export const UpdatedHistory = ({ current_history, updated_history }) => {
<Date>
{updated_history.year}년 {updated_history.month}월
</Date>
<Content>{updated_history.description}</Content>
<Content>{updated_history.content}</Content>
</Display>
</>
);
Expand Down
Loading