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

Feature/#295 스터디 작물 이미지 추가 #296

Merged
merged 3 commits into from
Aug 28, 2024
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
Binary file added public/images/crops/growth/carrot/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/carrot/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/carrot/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/carrot/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/carrot/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/pea/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/pea/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/pea/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/pea/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/pea/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/rice/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/rice/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/rice/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/rice/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/rice/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/sweetPotato/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/sweetPotato/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/sweetPotato/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/sweetPotato/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/sweetPotato/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/tomato/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/tomato/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/tomato/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/tomato/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/crops/growth/tomato/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/images/curriculumCrops/carrot_5.png
Diff not rendered.
5 changes: 4 additions & 1 deletion src/app/team/[teamId]/study/[studyId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ const Page = ({ params }: { params: { teamId: number; studyId: number } }) => {
/>
<Grid gap="4" templateColumns={{ base: '', xl: '2fr 1fr' }} w="100%">
<Flex direction="column" rowGap={{ base: '6', '2xl': '12' }}>
<CurriculumCard />
{studyData && (
<CurriculumCard cropId={studyData.cropId} studyProgressRatio={studyData.studyProgressRatio} />
)}

<Flex align="right" direction="column" rowGap="3">
<Link
as={NextLink}
Expand Down
10 changes: 5 additions & 5 deletions src/constants/crop.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const CROP = [
{ id: 1, name: '토마토', imageUrl: '/images/crops/tomato.png' },
{ id: 2, name: '고구마', imageUrl: '/images/crops/sweet_potato.png' },
{ id: 3, name: '당근', imageUrl: '/images/crops/carrot.png' },
{ id: 4, name: '완두콩', imageUrl: '/images/crops/pea.png' },
{ id: 5, name: '벼', imageUrl: '/images/crops/rice.png' },
{ id: 1, name: '토마토', engName: 'tomato', imageUrl: '/images/crops/tomato.png' },
{ id: 2, name: '고구마', engName: 'sweetPotato', imageUrl: '/images/crops/sweet_potato.png' },
{ id: 3, name: '당근', engName: 'carrot', imageUrl: '/images/crops/carrot.png' },
{ id: 4, name: '완두콩', engName: 'pea', imageUrl: '/images/crops/pea.png' },
{ id: 5, name: '벼', engName: 'rice', imageUrl: '/images/crops/rice.png' },
];

export default CROP;
14 changes: 12 additions & 2 deletions src/containers/study/CurriculumCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,30 @@ import { useState } from 'react';
import { MdOutlineArrowForwardIos } from 'react-icons/md';

import { getCurriculum } from '@/app/api/study';
import CROP from '@/constants/crop';
import { useGetFetchWithToken } from '@/hooks/useFetchWithToken';
import { Curriculum } from '@/types';

import CurriculumItem from './CurriculumItem';
import { CurriculumCardProps } from './types';
import CurriculumModal from '../CurriculumModal';

const CurriculumCard = () => {
const CurriculumCard = ({ cropId, studyProgressRatio }: CurriculumCardProps) => {
const [isStudyLeader] = useState<boolean>(true); // NOTE 추후 스터디장 여부 props로 받아올 예정
const { studyId } = useParams<{ studyId: string }>();

const curriculumItems = useGetFetchWithToken(getCurriculum, [Number(studyId)]);

const { isOpen: isCurriculumModalOpen, onOpen: onActionModalOpen, onClose: onCurriculumModalClose } = useDisclosure();

const getCropImage = () => {
const engName = CROP.find((crop) => crop.id === cropId)?.engName;
const growthLevel = studyProgressRatio === 0 ? 1 : Math.ceil(studyProgressRatio / 20);
const cropImageURL = `/images/crops/growth/${engName}/${growthLevel}.png`;

return cropImageURL;
};

return (
<Flex direction="column" gap="3" w="100%">
{isStudyLeader && (
Expand All @@ -38,7 +48,7 @@ const CurriculumCard = () => {
borderBottomLeftRadius="2xl"
borderBottomRightRadius="0"
alt="curriculum card"
src="/images/curriculumCrops/carrot_5.png"
src={getCropImage()}
/>
<Card
direction="row"
Expand Down
4 changes: 4 additions & 0 deletions src/containers/study/CurriculumCard/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface CurriculumCardProps {
cropId: number;
studyProgressRatio: number;
}