Skip to content

Commit

Permalink
style: 시간 drop down 구현 (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
SujinKim1127 authored Nov 23, 2023
1 parent 82aa102 commit fda535f
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 2 deletions.
3 changes: 3 additions & 0 deletions assets/svg/SmallDropDown.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/svg/SmallDropTop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 68 additions & 2 deletions components/StoreInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import styled from "@emotion/styled";
import EditIcon from "@/assets/svg/Edit.svg";
import { useEffect, useState } from "react";
import { getStoreInfo } from "@/pages/api/StoreAPI";
import { StoreDetailInfo } from "@/@types/Store";
import { StoreDetailInfo, businessHour } from "@/@types/Store";
import SmallDropDown from "@/assets/svg/SmallDropDown.svg";
import SmallDropTop from "@/assets/svg/SmallDropTop.svg";

interface SInfo {
storeId: number;
}

const StoreInfo = ({ storeId }: SInfo) => {
const [isdrop, setIsDrop] = useState<boolean>(false);
const [data, setData] = useState<StoreDetailInfo>({
address: "",
businessHours: [],
Expand All @@ -31,11 +34,56 @@ const StoreInfo = ({ storeId }: SInfo) => {
});
}, []);

function getTodayBusinessHours(today: string): businessHour | undefined {
return data.businessHours.find((hours) => hours.dayOfWeek === today);
}

// 현재 날짜를 기반으로 요일을 얻어온다. (예: 일요일 → '일')
const today: string = new Date().toLocaleDateString("ko-KR", {
weekday: "short",
});

// 오늘 요일에 해당하는 운영 시간을 얻어온다.
const todayBusinessHours: businessHour | undefined =
getTodayBusinessHours(today);

const handleOnClickDropDown = () => {
setIsDrop(!isdrop);
};

return (
<Container>
<InfoListBox>
<InfoTypeBox>영업 시간</InfoTypeBox>
<InfoDescriptionBox>09:00</InfoDescriptionBox>
<TimeContainer>
<TodayContainer>
{data.businessHours.length !== 0 && (
<InfoDescriptionBox>
오늘
{" " +
todayBusinessHours?.openingTime +
" ~ " +
todayBusinessHours?.closingTime}
</InfoDescriptionBox>
)}
{data.businessHours.length === 0 ? (
""
) : (
<DropdownBox onClick={handleOnClickDropDown}>
{isdrop ? <SmallDropTop /> : <SmallDropDown />}
</DropdownBox>
)}
</TodayContainer>
{isdrop &&
data.businessHours.map((el: businessHour, idx: number) => {
return (
<InfoDescriptionBox key={idx}>
{el.dayOfWeek + " " + el.openingTime + " ~ " + el.closingTime}
</InfoDescriptionBox>
);
})}
{}
</TimeContainer>
</InfoListBox>
<InfoListBox>
<InfoTypeBox>가게 번호</InfoTypeBox>
Expand Down Expand Up @@ -91,6 +139,7 @@ const InfoTypeBox = styled.div`
align-items: center;
gap: 10px;
width: 80px;
height: 22px;
`;

const InfoDescriptionBox = styled.div`
Expand All @@ -101,6 +150,8 @@ const InfoDescriptionBox = styled.div`
font-weight: 400;
line-height: 19.264px; /* 137.598% */
letter-spacing: -0.84px;
display: flex;
align-items: center;
`;

const ContactBox = styled.div`
Expand Down Expand Up @@ -156,4 +207,19 @@ const EditTxt = styled.div`
margin-right: 5px;
`;

const TimeContainer = styled.div`
display: flex;
flex-direction: column;
`;

const TodayContainer = styled.div`
display: flex;
`;

const DropdownBox = styled.div`
display: flex;
align-items: center;
margin-left: 10px;
`;

export default StoreInfo;

0 comments on commit fda535f

Please sign in to comment.