Skip to content

Commit

Permalink
fix: 프로젝트카드 클릭 핸들러 추가 (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
hynseok authored Nov 18, 2024
1 parent 789eb23 commit eaa9b55
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 17 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@types/js-cookie": "^3.0.6",
"axios": "^1.7.3",
"classnames": "^2.5.1",
"dayjs": "^1.11.13",
"embla-carousel-react": "^7.1.0",
"js-cookie": "^3.0.5",
"jwt-decode": "^4.0.0",
Expand Down
17 changes: 15 additions & 2 deletions src/components/common/ProjectCard/ProjectCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,17 @@ export interface ProjectCardProps {
data: ProjectCardDataType;
width?: string;
height?: string;
onClickLike: () => void;
onClickBookmark: () => void;
}

export function ProjectCard({ data, width, height }: ProjectCardProps) {
export function ProjectCard({
data,
width,
height,
onClickLike,
onClickBookmark,
}: ProjectCardProps) {
const ParticipantsString = data.participants.join(", ");
return (
<Card className={classes.card} w={width} h={height}>
Expand Down Expand Up @@ -70,7 +78,12 @@ export function ProjectCard({ data, width, height }: ProjectCardProps) {
</Group>
</Stack>
</CardSection>
<ProjectCardLikeSection likes={data.likes} isMarked={data.isMarked} />
<ProjectCardLikeSection
likes={data.likes}
isMarked={data.isMarked}
onClickLike={onClickLike}
onClickBookmark={onClickBookmark}
/>
</Card>
);
}
15 changes: 12 additions & 3 deletions src/components/common/ProjectCard/ProjectCardLikeSection.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
"use client";

import { CardSection, Group, UnstyledButton } from "@mantine/core";
import { IconBookmark, IconBookmarkFilled, IconThumbUp } from "@tabler/icons-react";
import classes from "./ProjectCard.module.css";

export interface ProjectCardLikeSectionProps {
likes: number;
isMarked: boolean;
onClickLike: () => void;
onClickBookmark: () => void;
}

export function ProjectCardLikeSection({ likes, isMarked }: ProjectCardLikeSectionProps) {
export function ProjectCardLikeSection({
likes,
isMarked,
onClickLike,
onClickBookmark,
}: ProjectCardLikeSectionProps) {
return (
<CardSection className={classes["like-section"]}>
<Group align="center" justify="space-between" w={500} p={16}>
<UnstyledButton>
<UnstyledButton onClick={onClickLike}>
<Group gap={0}>
<IconThumbUp color="var(--color-primary)" />
<div className={classes["likes-wrapper"]}>{likes}</div>
</Group>
</UnstyledButton>
<UnstyledButton>
<UnstyledButton onClick={onClickBookmark}>
{isMarked ? (
<IconBookmarkFilled color="var(--color-primary)" />
) : (
Expand Down
10 changes: 9 additions & 1 deletion src/components/common/TextInput/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ export function TextInput({
}: InputProps & TextInputPropsType) {
return (
<InputWrapper classNames={wrapperClasses} label={label} description={description} error={error}>
<Input placeholder={placeholder} onChange={onChange} {...props} value={initialValue} />
<Input
classNames={{
input: styles.input,
}}
placeholder={placeholder}
onChange={onChange}
{...props}
value={initialValue}
/>
</InputWrapper>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import { PrimaryButton } from "@/components/common/Buttons";
import { isNotEmpty, useForm } from "@mantine/form";
import { getYears } from "@/utils/getYears";
import { AwardStatus, ProjectCategory, ProjectType } from "@/types/project";
import { ProjectsCategoryLookupTable, ProjectsTypeLookupTable } from "@/constants/LookupTables";
import {
ProjectsCategoryLookupTable,
ProjectsTypeLookupTable,
} from "@/constants/LookupTables/index";
import { useRouter } from "next/navigation";
import { useFiles } from "@/hooks/useFiles/useFiles";
import { CommonAxios } from "@/utils/CommonAxios";
Expand Down Expand Up @@ -79,15 +82,12 @@ export function ProjectCreateSection({ projectId }: { projectId?: number }) {
const handleSubmit = async (values: ProjectEditFormInputs) => {
try {
const fileIds = { thumbnailId: values.thumbnailId, posterId: values.posterId };
// TODO: 파일 업로드 로직 수정
const uploadedThumbnail = await uploadFiles([{ id: "0", file: thumbnail }]);
fileIds.thumbnailId = Number(uploadedThumbnail[0]);

if (thumbnail?.arrayBuffer.length !== 0) {
const uploadedThumbnail = await uploadFiles([{ id: "0", file: thumbnail }]);
fileIds.thumbnailId = Number(uploadedThumbnail[0]);
}
if (poster?.arrayBuffer.length !== 0) {
const uploadedPoster = await uploadFiles([{ id: "0", file: poster }]);
fileIds.posterId = Number(uploadedPoster[0]);
}
const uploadedPoster = await uploadFiles([{ id: "0", file: poster }]);
fileIds.posterId = Number(uploadedPoster[0]);

const professorsArr = professors?.split(",").map((professor) => ({
name: professor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { PrimaryButton } from "@/components/common/Buttons";
import { DataTableData } from "@/components/common/DataTable/elements/DataTableData";
import { DataTableRow } from "@/components/common/DataTable/elements/DataTableRow";
import { ProjectsCategoryLookupTable } from "@/constants/LookupTables";
import { ProjectsCategoryLookupTable } from "@/constants/LookupTables/index";
import { IProjectContent } from "@/types/project";
import { getFileUrlById } from "@/utils/handleDownloadFile";
import { Checkbox } from "@mantine/core";
Expand Down
1 change: 1 addition & 0 deletions src/constants/DataTableHeaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const INTERVIEW_TABLE_HEADERS: DataTableHeaderProps[] = [
{ label: "소속", widthPercentage: 20, sort: true, selector: "talkerBelonging" },
{ label: "이름", widthPercentage: 20, sort: true, selector: "talkerName" },
{ label: "작성일", widthPercentage: 10, sort: true, selector: "createdAt" },
];

export const PROJECT_TABLE_HEADERS: DataTableHeaderProps[] = [
{ label: "순번", widthPercentage: 7, sort: true, selector: "id" },
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useFiles/useFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function useFiles() {
fileIds.push(id);
continue;
}

filesToUpload.append("files", file);
}
}
Expand Down

0 comments on commit eaa9b55

Please sign in to comment.