Skip to content

Commit

Permalink
Merge pull request #14 from Team-ComIT/#8MainPage_Api연결
Browse files Browse the repository at this point in the history
#8 main page api연결
  • Loading branch information
kimbuckgur authored Dec 5, 2022
2 parents 31c4fbc + 8e6f2c2 commit f7bce24
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
9 changes: 9 additions & 0 deletions apis/menu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// import { instance } from './instance';

// export const getMenu = (toDay: string) => {
// return instance.get('/menu', {
// params: {
// date: '',
// },
// });
// };
15 changes: 12 additions & 3 deletions assets/svgs/MealArrow.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
import React from 'react';
import React, { SetStateAction, Dispatch } from 'react';

interface MealArrowType {
direction: 'right' | 'left';
datePlusNumber: number;
setDatePlusNumber: Dispatch<SetStateAction<number>>;
}

const MealArrow = (props: MealArrowType) => {
const { direction, datePlusNumber, setDatePlusNumber } = props;

const changeDatePlusNumber = () => {
if (direction == 'right') setDatePlusNumber(datePlusNumber + 1);
else setDatePlusNumber(datePlusNumber - 1);
};

return (
<div style={{ cursor: 'pointer' }}>
<div onClick={changeDatePlusNumber} style={{ cursor: 'pointer' }}>
<svg
width="12"
height="18"
viewBox="0 0 12 18"
fill="none"
xmlns="http://www.w3.org/2000/svg">
{props.direction == 'right' ? (
{direction == 'right' ? (
<path
d="M0 15.885L7.417 9L0 2.115L2.2834 0L12 9L2.2834 18L0 15.885Z"
fill="#242424"
Expand Down
9 changes: 7 additions & 2 deletions components/MainPage/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,13 @@ const MainPage = () => {
direction="right"
/>
</_DateBox>
<_MenuText>dㅁㅇㅁㅇ</_MenuText>
<_MenuText>dㅁㅇㅁㅇ</_MenuText>
<_MenuLayout>
{menuMap.filter((element) => element !== undefined).length != 0 ? (
menuMap
) : (
<_MenuText>메뉴가 없습니다</_MenuText>
)}
</_MenuLayout>
</_MealLayout>
</_TextLayout>
<_ImgBox>
Expand Down
13 changes: 13 additions & 0 deletions hooks/useToDay.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const useToDay = (datePlusNumber: number) => {
var date = new Date();
date = new Date(date.setDate(date.getDate() + datePlusNumber));
var year = date.getFullYear();
var month = ('0' + (1 + date.getMonth())).slice(-2);
var day = ('0' + date.getDate()).slice(-2);
const toDay = year + '-' + month + '-' + day;
const numberDate = parseInt(day);

return { toDay, numberDate };
};

export default useToDay;

0 comments on commit f7bce24

Please sign in to comment.