Skip to content

Commit

Permalink
Merge pull request #1264 from academic-relations/dev
Browse files Browse the repository at this point in the history
활동보고서 작성 기능 & 대표자 변경 기능 배포
  • Loading branch information
babycroc authored Dec 21, 2024
2 parents 9358a60 + b2a884f commit c93386a
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
"use client";

import React from "react";
import React, { useEffect, useState } from "react";

import AsyncBoundary from "@sparcs-clubs/web/common/components/AsyncBoundary";
import LoginRequired from "@sparcs-clubs/web/common/frames/LoginRequired";
import NoManageClub from "@sparcs-clubs/web/common/frames/NoManageClub";
import { useAuth } from "@sparcs-clubs/web/common/providers/AuthContext";
import ActivityReportEditFrame from "@sparcs-clubs/web/features/manage-club/activity-report/frames/ActivityReportEditFrame";

const ActivityReport = ({ params }: { params: { id: string } }) => (
<ActivityReportEditFrame id={params.id} />
);
const ActivityReport = ({ params }: { params: { id: string } }) => {
const { isLoggedIn, login, profile } = useAuth();
const [loading, setLoading] = useState(true);

useEffect(() => {
if (isLoggedIn !== undefined || profile !== undefined) {
setLoading(false);
}
}, [isLoggedIn, profile]);

if (loading) {
return <AsyncBoundary isLoading={loading} isError />;
}

if (!isLoggedIn) {
return <LoginRequired login={login} />;
}

if (profile?.type !== "undergraduate") {
return <NoManageClub />;
}

return <ActivityReportEditFrame id={params.id} />;
};

export default ActivityReport;
31 changes: 29 additions & 2 deletions packages/web/src/app/manage-club/activity-report/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import React, { ReactNode } from "react";
import React, { ReactNode, useEffect, useState } from "react";

import { ActivityTypeEnum } from "@sparcs-clubs/interface/common/enum/activity.enum";

Expand All @@ -17,6 +17,8 @@ import ProgressStatus from "@sparcs-clubs/web/common/components/ProgressStatus";
import RejectReasonToast from "@sparcs-clubs/web/common/components/RejectReasonToast";
import Typography from "@sparcs-clubs/web/common/components/Typography";

import LoginRequired from "@sparcs-clubs/web/common/frames/LoginRequired";
import NoManageClub from "@sparcs-clubs/web/common/frames/NoManageClub";
import { useAuth } from "@sparcs-clubs/web/common/providers/AuthContext";
import { getActivityReportProgress } from "@sparcs-clubs/web/features/manage-club/activity-report/constants/activityReportProgress";
import { useGetActivityReport } from "@sparcs-clubs/web/features/manage-club/activity-report/services/useGetActivityReport";
Expand Down Expand Up @@ -93,7 +95,7 @@ const DeleteAndEditButtonContainer = styled.div`
gap: 10px;
`;

const ActivityReportDetail: React.FC = () => {
const ActivityReportDetailInner: React.FC = () => {
const router = useRouter();
const { id } = useParams<{ id: string }>();
const { profile } = useAuth();
Expand Down Expand Up @@ -246,4 +248,29 @@ const ActivityReportDetail: React.FC = () => {
);
};

const ActivityReportDetail = () => {
const { isLoggedIn, login, profile } = useAuth();
const [loading, setLoading] = useState(true);

useEffect(() => {
if (isLoggedIn !== undefined || profile !== undefined) {
setLoading(false);
}
}, [isLoggedIn, profile]);

if (loading) {
return <AsyncBoundary isLoading={loading} isError />;
}

if (!isLoggedIn) {
return <LoginRequired login={login} />;
}

if (profile?.type !== "undergraduate") {
return <NoManageClub />;
}

return <ActivityReportDetailInner />;
};

export default ActivityReportDetail;
31 changes: 29 additions & 2 deletions packages/web/src/app/manage-club/activity-report/create/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
"use client";

import React from "react";
import React, { useEffect, useState } from "react";

import AsyncBoundary from "@sparcs-clubs/web/common/components/AsyncBoundary";
import LoginRequired from "@sparcs-clubs/web/common/frames/LoginRequired";
import NoManageClub from "@sparcs-clubs/web/common/frames/NoManageClub";
import { useAuth } from "@sparcs-clubs/web/common/providers/AuthContext";
import ActivityReportCreateFrame from "@sparcs-clubs/web/features/manage-club/activity-report/frames/ActivityReportCreateFrame";

const ActivityReportCreate = () => <ActivityReportCreateFrame />;
const ActivityReportCreate = () => {
const { isLoggedIn, login, profile } = useAuth();
const [loading, setLoading] = useState(true);

useEffect(() => {
if (isLoggedIn !== undefined || profile !== undefined) {
setLoading(false);
}
}, [isLoggedIn, profile]);

if (loading) {
return <AsyncBoundary isLoading={loading} isError />;
}

if (!isLoggedIn) {
return <LoginRequired login={login} />;
}

if (profile?.type !== "undergraduate") {
return <NoManageClub />;
}

return <ActivityReportCreateFrame />;
};

export default ActivityReportCreate;
31 changes: 29 additions & 2 deletions packages/web/src/app/manage-club/activity-report/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
"use client";

import React from "react";
import React, { useEffect, useState } from "react";

import AsyncBoundary from "@sparcs-clubs/web/common/components/AsyncBoundary";
import LoginRequired from "@sparcs-clubs/web/common/frames/LoginRequired";
import NoManageClub from "@sparcs-clubs/web/common/frames/NoManageClub";
import { useAuth } from "@sparcs-clubs/web/common/providers/AuthContext";
import ActivityReportMainFrame from "@sparcs-clubs/web/features/manage-club/activity-report/frames/ActivityReportMainFrame";

const ActivityReport = () => <ActivityReportMainFrame />;
const ActivityReport = () => {
const { isLoggedIn, login, profile } = useAuth();
const [loading, setLoading] = useState(true);

useEffect(() => {
if (isLoggedIn !== undefined || profile !== undefined) {
setLoading(false);
}
}, [isLoggedIn, profile]);

if (loading) {
return <AsyncBoundary isLoading={loading} isError />;
}

if (!isLoggedIn) {
return <LoginRequired login={login} />;
}

if (profile?.type !== "undergraduate") {
return <NoManageClub />;
}

return <ActivityReportMainFrame />;
};

export default ActivityReport;
1 change: 1 addition & 0 deletions packages/web/src/constants/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const productionReadyPaths: {
// 마이페이지
"/my/clubs",
// 대표 동아리 관리
"/manage-club/activity-report",
"/manage-club/members",
// 동아리 / 회원 등록
"/register-club",
Expand Down

0 comments on commit c93386a

Please sign in to comment.