Skip to content

Commit

Permalink
Merge pull request #23 from team-Ollie/13-feature-Calendar-Modal
Browse files Browse the repository at this point in the history
13 feature calendar modal
  • Loading branch information
leejin-rho authored Jun 27, 2024
2 parents ea419d6 + 22a665a commit 38e3be2
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 18 deletions.
28 changes: 27 additions & 1 deletion apis/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,35 @@ export interface MonthCalendarProps {
};
}

type CalendarDate = {
year: number;
month: number;
day: number;
};

interface GetProgramDetailBody {
programIdx: number;
name: string;
openDate: CalendarDate;
dueDate: CalendarDate;
location: string;
host: string;
schedule: string;
description: string;
}

// 챌린지 월별 조회
export const getMonthCalendar = async (): Promise<GetMonthCalendarResponse> => {
const response = await client.get("/programs", {});
const response = await client.get("/programs");
// console.log("calenderData", response.data.result);
return response.data.result;
};

export const getProgramDetail = async (
programIdx: number,
): Promise<GetProgramDetailBody> => {
// const response = await client.get(`/programs/${programIdx}`);
const response = await client.get(`/programs/2`);
// console.log("calenderDetail", response.data.result);
return response.data.result;
};
14 changes: 13 additions & 1 deletion apis/hooks/calendar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query";
import { getMonthCalendar } from "../calendar";
import { getMonthCalendar, getProgramDetail } from "../calendar";

const useGetMonthCalendar = () => {
const { data } = useQuery({
Expand All @@ -12,3 +12,15 @@ const useGetMonthCalendar = () => {
};

export { useGetMonthCalendar };

// const useGetProgramDetail = () => {
// const { data } = useQuery({
// queryKey: ["getProgramDetail"],
// queryFn: getProgramDetail,
// });
// // console.log("isLoading", isLoading);
// console.log("Query Data", data);
// return { data };
// };

// export { useGetProgramDetail };
9 changes: 9 additions & 0 deletions components/calendar/CalendarModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const CalendarModal = ({ filterName }) => {
return (
<div className="w-fit h-[1.9rem] flex justify-center items-center bg-main-color rounded-3xl text-white py-[0.31rem] pl-[0.94rem] pr-[0.44rem] gap-0.5">
<div>{filterName}</div>
</div>
);
};

export default CalendarModal;
45 changes: 31 additions & 14 deletions components/calendar/InfoCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ export default function InfoCalendar() {
setClickedDate(clickedDate);
};

// API 관리
const { data } = useGetMonthCalendar();

const handleDayDataClick = (programIdx: number) => {
console.log("API 호출: ", programIdx);
};

const customTileContent = ({ date, view }: { date: Date; view: string }) => {
let isOpen = true;
if (data && view === "month") {
const dayData = data.find((dayData: MonthCalendarProps) => {
if (Array.isArray(data) && view === "month") {
const dayData = data.filter((dayData: MonthCalendarProps) => {
const openDate = new Date(
dayData.openDate.year,
dayData.openDate.month - 1,
Expand All @@ -38,24 +42,36 @@ export default function InfoCalendar() {
dayData.dueDate.day,
);

if (date.getTime() === openDate.getTime()) isOpen = true;
else isOpen = false;

return (
date.getTime() === openDate.getTime() ||
date.getTime() === dueDate.getTime()
);
});

if (dayData) {
if (dayData.length > 0) {
return (
<div className="custom-tile-content">
<div className=" flex flex-row justify-center items-center gap-1 ">
<Dot color={isOpen ? "#F06459" : "#8E8E93"} />
<div className="h6 custom-tile-text text-grey-900 whitespace-nowrap overflow-hidden text-ellipsis">
{dayData.name}
</div>
</div>
{dayData.map((day: MonthCalendarProps, index: number) => {
const isOpen =
date.getTime() ===
new Date(
day.openDate.year,
day.openDate.month - 1,
day.openDate.day,
).getTime();
console.log(day);
return (
<div key={index} className="flex flex-row items-center gap-1">
<Dot color={isOpen ? "#F06459" : "#8E8E93"} />
<div
className="h6 custom-tile-text text-grey-900 whitespace-nowrap overflow-hidden text-ellipsis"
onClick={() => handleDayDataClick(day.programIdx)}
>
{day.name}
</div>
</div>
);
})}
</div>
);
}
Expand Down Expand Up @@ -96,9 +112,10 @@ const StyledCalendarWrapper = styled.div`
.custom-tile-content {
/* position: absolute; */
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 1;
gap: 1px;
}
.custom-tile-text {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"@yarnpkg/pnpify": "^4.1.0",
"eslint": "8.54.0",
"eslint-config-next": "14.0.3",
"eslint-plugin-react": "^7.34.3",
"typescript": "5.4.5"
},
"packageManager": "[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion pages/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const Login: NextPage = () => {
);

const signInMutation = useMutation({
queryKey: ["SignIn"],
mutationKey: ["SignIn"],
mutationFn: SignIn,
onSuccess: async (data) => {
console.log(data);
Expand Down
3 changes: 2 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4029,7 +4029,7 @@ __metadata:
languageName: node
linkType: hard

"eslint-plugin-react@npm:^7.33.2":
"eslint-plugin-react@npm:^7.33.2, eslint-plugin-react@npm:^7.34.3":
version: 7.34.3
resolution: "eslint-plugin-react@npm:7.34.3"
dependencies:
Expand Down Expand Up @@ -7677,6 +7677,7 @@ __metadata:
embla-carousel-react: "npm:^8.1.3"
eslint: "npm:8.54.0"
eslint-config-next: "npm:14.0.3"
eslint-plugin-react: "npm:^7.34.3"
gh-pages: "npm:^6.1.1"
jotai: "npm:^2.8.3"
lottie-web: "npm:^5.12.2"
Expand Down

0 comments on commit 38e3be2

Please sign in to comment.