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

[SP2] 최근 출시된 프로젝트 추가 #310

Merged
merged 7 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
Binary file not shown.
Binary file not shown.
41 changes: 40 additions & 1 deletion src/lib/constants/project.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { ProjectCategoryType, ProjectPlatformType } from '@src/lib/types/project';
import { default as ImgProjectLogo1 } from '@src/assets/images/recent-release-project/img_project_logo1.avif';
import { default as ImgProjectLogo2 } from '@src/assets/images/recent-release-project/img_project_logo2.avif';
import {
LinkType,
ProjectCategoryType,
ProjectPlatformType,
StaticProjectType,
} from '@src/lib/types/project';
import { PageType } from '@src/lib/types/universal';

export const activeProjectCategoryList: ProjectCategoryType[] = [
Expand Down Expand Up @@ -41,3 +48,35 @@ export const pageBreakPoint: Record<PageType, string> = {
[PageType.BLOG]: '767px',
[PageType.PROJECT]: '899px',
};

export const StaticReleaseProjectList: StaticProjectType[] = [
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요것은 변수인 것 같아서, 소문자로 시작하면 좋을 것 같습니다..!!

name: '엄빠도 어렸다',
summary: '긍정적인 소비 습관을 만드는 절약 SNS',
generation: 32,
link: [
{
title: LinkType['앱 스토어'],
url: 'https://apps.apple.com/kr/app/%EC%9C%84%EB%8B%88-%EC%89%BD%EA%B3%A0-%EC%9E%AC%EB%B0%8C%EB%8A%94-%EA%B8%8D%EC%A0%95%EC%A0%81-%EC%86%8C%EB%B9%84%EC%8A%B5%EA%B4%80-%ED%98%95%EC%84%B1/id6463294662',
},
{
title: LinkType['구글 플레이스토어'],
url: 'https://play.google.com/store/apps/details?id=org.go.sopt.winey&hl=ko',
},

],
logoImage: ImgProjectLogo1.src,
},
{
name: '위니',
summary: '긍정적인 소비 습관을 만드는 절약 SNS',
generation: 32,
link: [
{
title: LinkType['앱 스토어'],
url: 'https://apps.apple.com/kr/app/%EC%9C%84%EB%8B%88-%EC%89%BD%EA%B3%A0-%EC%9E%AC%EB%B0%8C%EB%8A%94-%EA%B8%8D%EC%A0%95%EC%A0%81-%EC%86%8C%EB%B9%84%EC%8A%B5%EA%B4%80-%ED%98%95%EC%84%B1/id6463294662',
},
],
logoImage: ImgProjectLogo2.src,
},
];
8 changes: 8 additions & 0 deletions src/lib/types/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ export interface ProjectType {
uploadedAt: string;
}

export interface StaticProjectType {
generation: number;
link: ProjectLinkType[];
logoImage: string;
name: string;
summary: string;
}

export interface GetProjectDetailResponse {
project: ProjectType;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import Carousel from '@src/components/common/Carousel';
import { useDeviceType, useIsDesktop, useIsMobile } from '@src/hooks/useDevice';
import { StaticReleaseProjectList } from '@src/lib/constants/project';
import { ProjectCategoryType, ProjectPlatformType, ProjectType } from '@src/lib/types/project';
import RecentProjectListItem from '@src/views/ProjectPage/components/RecentProjectList/Item';
import { useGetProjectList } from '@src/views/ProjectPage/hooks/queries';

export default function RecentProjectListCarousel() {
const { data } = useGetProjectList(ProjectCategoryType.ALL, ProjectPlatformType.ALL);
const recentProjectList = data as ProjectType[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요거 받은 프로젝트만 띄우고, useGetProjectList에서 받은 data는 쓰지 않도록 하면 어떨까요..?!?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

헣 이 부분은 PM이랑 PD 의견이 지금 다른 것 같아서 답변 기다리고 있는 상태입니다..!!
https://sopt-makers.slack.com/archives/C042T8GEA0Y/p1701614764413939

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

신청하는 프로젝트들만 상단 노출하는 걸로 결론이 나서 useQuery 사용 코드는 지웠습니다!!

const recentProjectList = [...StaticReleaseProjectList, ...(data as ProjectType[]).slice(0, 4)];

const isDesktopSize = useIsDesktop('1280px');
const isMobileSize = useIsMobile('899px');
Expand All @@ -21,8 +22,8 @@ export default function RecentProjectListCarousel() {
gapWidth={isMobileSize ? 14 : 24}
isDesktop={isDesktop}
>
{recentProjectList.slice(0, 6).map((project) => (
<RecentProjectListItem key={project.id} {...project} />
{recentProjectList.map((project, index) => (
<RecentProjectListItem key={index} {...project} />
))}
</Carousel>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useDeviceType } from '@src/hooks/useDevice';
import { LinkType, ProjectLinkType, ProjectType } from '@src/lib/types/project';
import { LinkType, ProjectLinkType, ProjectType, StaticProjectType } from '@src/lib/types/project';
import { S } from './style';

type RecentProjectListItemProps = ProjectType;
type RecentProjectListItemProps = ProjectType | StaticProjectType;

const linkToRecord = (links: ProjectLinkType[]): Record<LinkType, string | undefined> => {
const record: Record<LinkType, string | undefined> = {
Expand All @@ -26,14 +26,18 @@ const getTryLink = (
link: ProjectLinkType[],
deviceType?: 'desktop' | 'iOS' | 'Android',
): string | undefined => {
if (link.length === 0) return;
if (link.length === 1) return link[0].url;

const linkRecord = linkToRecord(link);
if (deviceType === 'iOS' && linkRecord['appStore']) {
return linkRecord['appStore'];
}
if (deviceType === 'Android' && linkRecord['googlePlay']) {
} else if (deviceType === 'Android' && linkRecord['googlePlay']) {
return linkRecord['googlePlay'];
} else if (deviceType === 'desktop' && linkRecord['website']) {
return linkRecord['website'];
}
return linkRecord['website'];
return linkRecord.appStore || link[0].url;
};

export default function RecentProjectListItem(props: RecentProjectListItemProps) {
Expand Down
7 changes: 6 additions & 1 deletion src/views/ProjectPage/hooks/queries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ export const useGetProjectList = (
) => {
const queryKey = ['getProjectList', category, platform];
return useQuery(queryKey, () => api.projectAPI.getProjectList(category, platform), {
select: (data) => (sortType ? sortBy<ProjectType>(data, 'updatedAt') : data),
select: (data) => {
const filteredData = data.filter(({ link }) =>
link.some(({ title }) => ['website', 'appStore', 'googlePlay'].includes(title)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이미 요런 처리를 해주셨군여.. 그럼 이대로 가도 좋을 것 같습니다!!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

호옥시 요런 필터 처리가 전체 프로젝트 목록에 영향을 주는지 한번만 봐주심 감사하겠습니다..!!! 제 기억으로는 ProjectPage에서도 사용하는 훅이여서요!!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

으아 이런 실수를... 수정하겠습니다..!!! 감사해요

);
return sortType ? sortBy<ProjectType>(filteredData, 'updatedAt') : filteredData;
},
staleTime: 30000,
suspense: true,
});
Expand Down
Loading