diff --git a/package-lock.json b/package-lock.json index 32768cf..447c385 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,6 +31,7 @@ "@types/react-beautiful-dnd": "^13.1.8", "@types/react-dom": "^18.3.0", "craco-alias": "^3.0.1", + "date-fns": "^4.1.0", "react-scripts": "5.0.1", "typescript": "^4.9.5", "web-vitals": "^2.1.4" @@ -7380,6 +7381,17 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/date-fns": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-4.1.0.tgz", + "integrity": "sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/kossnocorp" + } + }, "node_modules/debug": { "version": "4.3.7", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", diff --git a/package.json b/package.json index 56e258d..3b871b8 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "@types/react-beautiful-dnd": "^13.1.8", "@types/react-dom": "^18.3.0", "craco-alias": "^3.0.1", + "date-fns": "^4.1.0", "react-scripts": "5.0.1", "typescript": "^4.9.5", "web-vitals": "^2.1.4" diff --git a/public/EmptyImage.png b/public/EmptyImage.png new file mode 100644 index 0000000..ad00b2e Binary files /dev/null and b/public/EmptyImage.png differ diff --git a/src/component/template/component/PreviewTemplate.tsx b/src/component/template/component/PreviewTemplate.tsx index 27cf564..ec53bd4 100644 --- a/src/component/template/component/PreviewTemplate.tsx +++ b/src/component/template/component/PreviewTemplate.tsx @@ -1,14 +1,16 @@ -import React, {useRef, useState} from 'react'; +import React, {HTMLProps, useRef, useState} from 'react'; import Text from "@designsystem/component/text"; import {Column, Row} from "@designsystem/component/flexLayout"; import Icon, {IconType} from "@designsystem/foundation/icon"; import colors from "@designsystem/foundation/colors"; -import styled, {CSSProperties} from "styled-components"; +import styled from "styled-components"; import WeddingSchedule from "@remote/value/WeddingSchedule"; import WeddingPlace from "@remote/value/WeddingPlace"; import BaseInfo from "@remote/value/BaseInfo"; import Template from "@remote/value/Template"; import Spacer from "@designsystem/component/spacer"; +import {format, parse} from "date-fns"; +import {ko} from "date-fns/locale"; interface PreviewTemplateProps { template: Template; @@ -27,20 +29,25 @@ function PreviewTemplate( imgList }: PreviewTemplateProps ) { + const dateString = `${weddingSchedule.weddingDate} ${weddingSchedule.weddingTime}`; + console.log(dateString) + const date = parse(dateString, 'yyyy-MM-dd HH:mm', new Date()); + console.log(date) + const isValidDate = !isNaN(date.getTime()); + switch (template.templateName) { case '템플릿1': return ( - {/**/} - {/**/} - {weddingSchedule.weddingDate} + {isValidDate && format(date, 'yyyy년 M월 d일 EEEE a h시', {locale: ko})} {weddingPlace.placeName}({weddingPlace.floorHall}) - + 신랑 {baseInfo.groomName} @@ -53,10 +60,10 @@ function PreviewTemplate( return ( - {weddingSchedule.weddingDate} + {isValidDate && format(date, 'yyyy/MM/dd', {locale: ko})} {weddingPlace.placeName}({weddingPlace.floorHall}) - + {baseInfo.groomName} & @@ -69,8 +76,9 @@ function PreviewTemplate( - {weddingSchedule.weddingDate} + + {isValidDate && format(date, 'yyyy.MM.dd EEE')} + 신랑 {baseInfo.groomName} @@ -78,7 +86,7 @@ function PreviewTemplate( 신부 {baseInfo.brideName} - + ); case '템플릿4': @@ -88,20 +96,20 @@ function PreviewTemplate( {baseInfo.groomName} & {baseInfo.brideName} {weddingSchedule.weddingDate} {weddingSchedule.weddingTime} + weight={300}>{isValidDate && format(date, 'yyyy.MM.dd a h시', {locale: ko})} {weddingPlace.placeName} - + ); case '템플릿5': return ( - + {baseInfo.groomName} and @@ -113,14 +121,14 @@ function PreviewTemplate( return ( - {weddingSchedule.weddingDate} + {isValidDate && format(date, 'MM / dd')} {baseInfo.groomName} 그리고 {baseInfo.brideName} - + ); } @@ -161,8 +169,8 @@ const S3 = { `, Img: styled.img` display: flex; - object-fit: cover; width: 100%; + object-fit: cover; ` }; const S4 = { @@ -175,7 +183,6 @@ const S4 = { const S5 = { Img: styled.img` display: flex; - width: 100%; object-fit: cover; margin: 48px 28px; `