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

[FIX] 공홈과 어드민 연동 QA fix #437

Merged
merged 7 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
539 changes: 0 additions & 539 deletions src/lib/api/mock/admin.ts

This file was deleted.

6 changes: 6 additions & 0 deletions src/lib/types/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface GetHomepageResponse {
};
partIntroduction: PartIntroType[];
latestNews: LatestNewsType[];
recruitSchedule: RecruitScheduleType[];
}

export interface MemberType {
Expand Down Expand Up @@ -71,6 +72,11 @@ export interface GetAboutpageResponse {
coreValue: CoreValueType[];
partCurriculum: PartCurriculumType[];
member: MemberType[];
activitiesRecords: {
activitiesMemberCount: number;
projectCounts: number;
studyCounts: number;
};
}

export interface PartInfoType {
Expand Down
5 changes: 3 additions & 2 deletions src/views/AboutPage/components/Member/Section/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import * as St from './style';
type MemberSectionProps = {
generation: number;
members: MemberType[];
name: string;
};

const MemberSection = ({ generation, members }: MemberSectionProps) => {
const MemberSection = ({ generation, members, name: soptName }: MemberSectionProps) => {
return (
<Flex
dir="column"
Expand All @@ -20,7 +21,7 @@ const MemberSection = ({ generation, members }: MemberSectionProps) => {
<SectionTop
engTitle="Executives"
korTitle={`${generation}기 임원진`}
description="200명의 활동 회원들이 열정을 외칠 수 있도록, 35기 AND SOPT를 이끄는 임원진들이에요."
description={`200명의 활동 회원들이 열정을 외칠 수 있도록, ${generation}기 ${soptName}를 이끄는 임원진들이에요.`}
/>
<Flex
dir="column"
Expand Down
18 changes: 9 additions & 9 deletions src/views/AboutPage/components/Record/List/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@ import RecordItem from '../Item';
import * as St from './style';

const RecordList = ({
records,
activitiesRecords: { activitiesMemberCount, projectCounts, studyCounts },
}: {
records: {
memberCount: number;
projectCount: number;
studyCount: number;
activitiesRecords: {
activitiesMemberCount: number;
projectCounts: number;
studyCounts: number;
};
}) => {
return (
<St.Wrapper>
<RecordItem
type="block"
title="활동 멤버"
countNumber={records?.memberCount}
countNumber={activitiesMemberCount}
countString="명"
/>
<RecordItem
type="link"
title="프로젝트"
countNumber={records?.projectCount !== 0 ? records?.projectCount : undefined}
countString={records?.projectCount !== 0 ? '개' : '진행중'}
countNumber={projectCounts !== 0 ? projectCounts : undefined}
countString={projectCounts !== 0 ? '개' : '진행중'}
href="/project"
/>
<RecordItem type="block" title="스터디" countNumber={records?.studyCount} countString="개" />
<RecordItem type="block" title="스터디" countNumber={studyCounts} countString="개" />
</St.Wrapper>
);
};
Expand Down
8 changes: 4 additions & 4 deletions src/views/AboutPage/components/Record/Section/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { AboutInfoType } from '@src/lib/types/about';
import { GetAboutpageResponse } from '@src/lib/types/admin';
import SectionTop from '../../@common/SectionTop';
import RecordList from '../List';
import * as St from './style';

type RecordSectionProps = Pick<AboutInfoType, 'generation' | 'records'>;
type RecordSectionProps = Pick<GetAboutpageResponse, 'generation' | 'activitiesRecords'>;

const RecordSection = ({ generation, records }: RecordSectionProps) => {
const RecordSection = ({ generation, activitiesRecords }: RecordSectionProps) => {
return (
<St.Wrapper>
<SectionTop engTitle="Activity Records" korTitle={`${generation}기 활동 레코드`} />
<RecordList records={records} />
<RecordList activitiesRecords={activitiesRecords} />
</St.Wrapper>
);
};
Expand Down
11 changes: 9 additions & 2 deletions src/views/AboutPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,15 @@ const AboutPage = () => {
}))}
/>
<CurriculumSection curriculums={adminData.partCurriculum} />
<MemberSection members={adminData.member} generation={adminData.generation} />
{/* <RecordSection generation={adminData.generation} records={adminData.records} /> */}
<MemberSection
members={adminData.member}
generation={adminData.generation}
name={adminData.name}
/>
<RecordSection
generation={adminData.generation}
activitiesRecords={adminData.activitiesRecords}
/>
</Root>
</BrandingColorContext.Provider>
</PageLayout>
Expand Down
5 changes: 4 additions & 1 deletion src/views/MainPage/components/Banner/RecruitButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { PropsWithChildren, useState } from 'react';
import { BannerColor } from '..';
import * as S from './style';

interface BannerColor {
mainColor: string;
highColor: string;
}
export default function RecruitButton({
children,
mainColor,
Expand Down
12 changes: 5 additions & 7 deletions src/views/MainPage/components/Banner/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import imgMainPageBanner from '@src/assets/images/img_mainBanner.png';
import { checkIsTimeInRange } from '@src/lib/utils/date';
import RecruitButton from './RecruitButton';
import * as S from './style';

export interface BannerColor {
interface BannerProps {
mainColor: string;
highColor: string;
ctaText: string;
}
export default function Banner({ mainColor, highColor }: BannerColor) {
// TODO: API 필드 추가된 후에 RecruitPage처럼 바뀌어야 함
const isValid = checkIsTimeInRange('2024-09-08 10:00:00', '2024-09-13 18:00:00');

export default function Banner({ mainColor, highColor, ctaText }: BannerProps) {
const onScrollMoveDown = () => {
const element = document.getElementById('nextContainer');
if (element) element.scrollIntoView({ behavior: 'smooth', block: 'start' });
Expand All @@ -24,7 +21,8 @@ export default function Banner({ mainColor, highColor }: BannerColor) {
<S.Title>함께라서 외칠 수 있는 열정</S.Title>
<S.Title>오직 이곳 SOPT에서만.</S.Title>
<RecruitButton mainColor={mainColor} highColor={highColor}>
{isValid ? '36기 YB 지원하기 ' : '모집 알림 신청하기 '}&gt;{' '}
{ctaText}
&gt;
</RecruitButton>
</S.Content>
<S.DownScrollIcon onClick={onScrollMoveDown} />
Expand Down
18 changes: 16 additions & 2 deletions src/views/MainPage/components/BottomLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,21 @@ export type RefHandler = {
};

interface BottomLayoutProps {
generation: number;
partIntroduction: PartIntroType[];
latestNews: LatestNewsType[];
mainColor: string;
highColor: string;
ctaText: string;
}
function BottomLayout({ partIntroduction, latestNews, mainColor, highColor }: BottomLayoutProps) {
function BottomLayout({
generation,
partIntroduction,
latestNews,
mainColor,
highColor,
ctaText,
}: BottomLayoutProps) {
const activity = useInView();
const part = useInView();
const team = useInView();
Expand Down Expand Up @@ -71,7 +80,12 @@ function BottomLayout({ partIntroduction, latestNews, mainColor, highColor }: Bo
<div ref={targetRef} />
<motion.div style={{ backgroundColor: wrapperBackground }}>
<RecentNews latestNews={latestNews} />
<RecruitMessage mainColor={mainColor} highColor={highColor} />
<RecruitMessage
generation={generation}
mainColor={mainColor}
highColor={highColor}
ctaText={ctaText}
/>
</motion.div>
</>
);
Expand Down
20 changes: 13 additions & 7 deletions src/views/MainPage/components/RecruitMessage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
import { useIsMobile } from '@src/hooks/useDevice';
import { checkIsTimeInRange } from '@src/lib/utils/date';
import RecruitButton from '../Banner/RecruitButton';
import * as S from './style';

interface RecruitMessageProp {
generation: number;
mainColor: string;
highColor: string;
ctaText: string;
}
export default function RecruitMessage({ mainColor, highColor }: RecruitMessageProp) {
export default function RecruitMessage({
generation,
mainColor,
highColor,
ctaText,
}: RecruitMessageProp) {
const isMobileSize = useIsMobile('48rem');
// TODO: API 필드 추가된 후에 RecruitPage처럼 바뀌어야 함
const isValid = checkIsTimeInRange('2024-09-08 10:00:00', '2024-09-13 18:00:00'); // 모집 여부

return (
<S.Background>
<S.Title>솝트의 36번째{isMobileSize ? <br /> : ' '}열정이 되어주세요!</S.Title>
{!isValid && (
<S.Title>
솝트의 {generation}번째{isMobileSize ? <br /> : ' '}열정이 되어주세요!
</S.Title>
{ctaText === '모집 알림 신청하기 ' && (
<S.Description>
아직 모집기간이 아니예요.{isMobileSize && <br />}알림 신청을 하시면, 봄에 찾아갈게요!
</S.Description>
)}
<RecruitButton mainColor={mainColor} highColor={highColor}>
{isValid ? '36기 YB 지원하기 ' : '모집 알림 신청하기 '}&gt;{' '}
{ctaText}&gt;
</RecruitButton>
</S.Background>
);
Expand Down
11 changes: 8 additions & 3 deletions src/views/MainPage/components/TopBanner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ import { useIsMobile } from '@src/hooks/useDevice';
import useGetVisitor from '../../hooks/useGetVisitor';
import * as S from './style';

export default function TopBanner() {
const TARGET_DATE = new Date('2024-09-13 18:00:00');
interface TopBannerProps {
targetTime?: string;
generation: number;
}

export default function TopBanner({ targetTime, generation }: TopBannerProps) {
const TARGET_DATE = targetTime ? new Date(targetTime) : new Date();
const isMobile = useIsMobile();
const CHANGE_POSITION = isMobile ? 495 : 605;
const { data } = useGetVisitor(); // 방문자 조회
Expand All @@ -30,7 +35,7 @@ export default function TopBanner() {
<S.Container href="/recruit" isKeyColor={isKeyColor}>
<S.Wrapper>
<div>
<S.Title>솝트의 36번째 열정이 되어주세요!</S.Title>
<S.Title>솝트의 {generation}번째 열정이 되어주세요!</S.Title>
</div>
<S.Description>
<S.Timer>
Expand Down
47 changes: 37 additions & 10 deletions src/views/MainPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useQuery } from '@tanstack/react-query';
import { useEffect } from 'react';
import { useEffect, useMemo } from 'react';
import PageLayout from '@src/components/common/PageLayout';
import { remoteAdminAPI } from '@src/lib/api/remote/admin';
import { GetHomepageResponse } from '@src/lib/types/admin';
Expand All @@ -13,36 +13,63 @@ import Introduce from './components/Introduce';
import ScrollInteractiveLogo from './components/ScrollInteractiveLogo';

function MainPage() {
// TODO: API 필드 추가된 후에 RecruitPage처럼 바뀌어야 함
const isValid = checkIsTimeInRange('2024-09-08 10:00:00', '2024-09-13 18:00:00');
const { data: adminData } = useQuery<GetHomepageResponse>({
queryKey: ['homepage'],
queryFn: remoteAdminAPI.getHomepage,
});

const isOBRecruiting = checkIsTimeInRange(
adminData?.recruitSchedule[0].schedule.applicationStartTime ?? '',
adminData?.recruitSchedule[0].schedule.applicationEndTime ?? '',
);
const isYBRecruiting = checkIsTimeInRange(
adminData?.recruitSchedule[1].schedule.applicationStartTime ?? '',
adminData?.recruitSchedule[1].schedule.applicationEndTime ?? '',
);
const isRecruiting = isOBRecruiting || isYBRecruiting;

const ctaText = useMemo(() => {
if (adminData?.generation === undefined) return '모집 알림 신청하기 ';
if (isOBRecruiting) return `${adminData.generation}기 OB 지원하기 `;
if (isYBRecruiting) return `${adminData.generation}기 YB 지원하기 `;
return '모집 알림 신청하기 ';
}, [isOBRecruiting, isYBRecruiting, adminData]);

const postVisiter = usePostVisitor();

useEffect(() => {
if (!isRecruiting) return;
postVisiter();
}, [postVisiter]);

const { data: adminData } = useQuery<GetHomepageResponse>({
queryKey: ['homepage'],
queryFn: remoteAdminAPI.getHomepage,
});
}, [isRecruiting, postVisiter]);

return (
<PageLayout>
{!isValid && <TopBanner />}
{isRecruiting && (
<TopBanner
targetTime={
isYBRecruiting
? adminData?.recruitSchedule[1].schedule.applicationEndTime
: adminData?.recruitSchedule[0].schedule.applicationEndTime
}
generation={adminData?.generation ?? 0}
/>
)}
<Banner
mainColor={'#' + adminData?.brandingColor.main ?? ''}
highColor={'#' + adminData?.brandingColor.high ?? ''}
ctaText={ctaText}
/>
<Introduce />
<IntroSection />
<ScrollInteractiveLogo />
{adminData && (
<BottomLayout
generation={adminData?.generation ?? 0}
partIntroduction={adminData.partIntroduction}
latestNews={adminData.latestNews}
mainColor={'#' + adminData?.brandingColor.main ?? ''}
highColor={'#' + adminData?.brandingColor.high ?? ''}
ctaText={ctaText}
/>
)}
</PageLayout>
Expand Down
2 changes: 1 addition & 1 deletion src/views/RecruitPage/components/BottomLogo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Image from 'next/image';
import { logoAndSoptDark } from '@src/assets/mainLogo';

const BottomLogo = () => {
return <ScaledImage src={logoAndSoptDark} alt="35기 솝트 로고" />;
return <ScaledImage src={logoAndSoptDark} alt="솝트 로고" />;
};

const ScaledImage = styled(Image)`
Expand Down
6 changes: 3 additions & 3 deletions src/views/RecruitPage/components/ChapterInfo/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useContext, useState } from 'react';
import Flex from '@src/components/common/Flex';
import { PartInfoType, PartType } from '@src/lib/types/admin';
import { PartInfoType } from '@src/lib/types/admin';
import { Part } from '@src/lib/types/universal';
import { parsePartToKorean } from '@src/lib/utils/parsePartToKorean';
import { parseStringToPart } from '@src/lib/utils/parseStringToPart';
Expand All @@ -9,7 +9,7 @@ import TabBar from '../common/Tabs';
import { SectionTitle, SectionTitleTranslate, SectionTitleWrapper } from '../common/style';
import * as S from './style';

const ChapterInfo = ({ info }: { info: PartInfoType[] }) => {
const ChapterInfo = ({ info, generation }: { info: PartInfoType[]; generation: number }) => {
const { main, point } = useContext(BrandingColorContext);
const [selectedTab, setSelectedTab] = useState<Part>(Part.PLAN);
const parsedPart = parsePartToKorean(selectedTab);
Expand All @@ -24,7 +24,7 @@ const ChapterInfo = ({ info }: { info: PartInfoType[] }) => {
<SectionTitleWrapper>
<SectionTitleTranslate mainColor={'#' + main}>Positions</SectionTitleTranslate>
<S.SectionWrapper>
<SectionTitle>SOPT 35기는</SectionTitle>
<SectionTitle>SOPT {generation}기는</SectionTitle>
<SectionTitle>총 6개의 파트로 이루어져 있어요.</SectionTitle>
</S.SectionWrapper>
</SectionTitleWrapper>
Expand Down
2 changes: 1 addition & 1 deletion src/views/RecruitPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import styled from '@emotion/styled';
import { useQuery } from '@tanstack/react-query';
import { Suspense, createContext, lazy } from 'react';

Check warning on line 3 in src/views/RecruitPage/index.tsx

View workflow job for this annotation

GitHub Actions / continuous-integration

'lazy' is defined but never used
import PageLayout from '@src/components/common/PageLayout';
import { remoteAdminAPI } from '@src/lib/api/remote/admin';
import { GetRecruitpageResponse } from '@src/lib/types/admin';
import { checkIsTimeInRange } from '@src/lib/utils/date';
import ActivityReview from './components/ActivityReview';
import ApplySection from './components/ApplySection';
import BottomLogo from './components/BottomLogo';

Check warning on line 10 in src/views/RecruitPage/index.tsx

View workflow job for this annotation

GitHub Actions / continuous-integration

'BottomLogo' is defined but never used
import ChapterInfo from './components/ChapterInfo';
import Contact from './components/Contact';
import FaqInfo from './components/FAQ';
Expand Down Expand Up @@ -54,7 +54,7 @@
)}
<ContentWrapper>
<RecruiteeInfo />
<ChapterInfo info={adminData.recruitPartCurriculum} />
<ChapterInfo info={adminData.recruitPartCurriculum} generation={adminData.generation} />
<Schedule info={adminData.recruitSchedule[isOBRecruiting ? 0 : 1]} />
<Suspense>
<FaqInfo info={adminData.recruitQuestion} />
Expand Down
Loading