Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 플랜 성공/실패시 refresh 오류, 플랜복구 날짜 오류 수정 외 #72

Merged
merged 12 commits into from
Jan 3, 2024
Binary file removed public/blacklogo.png
Binary file not shown.
21 changes: 11 additions & 10 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,27 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=5, viewport-fit=cover, user-scalable=no"
content="width=device-width, initial-scale=1, minimum-scale=0.5, maximum-scale=5, viewport-fit=cover, user-scalable=no"
/>
<link rel="icon" href="%PUBLIC_URL%/blacklogo.png" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/blacklogo.png" />
<link rel="shortcut icon" href="%PUBLIC_URL%/blacklogo.png" />
<link rel="icon" sizes="512x512" href="%PUBLIC_URL%/readbird.png" />
<link rel="apple-touch-icon" sizes="512x512" href="%PUBLIC_URL%/readbird.png" />
<link rel="shortcut icon" sizes="512x512" href="%PUBLIC_URL%/readbird.png" />
<meta name="apple-mobile-web-app-title" content="Readbird" />
<meta name="theme-color" content="#000000" />
<meta name="theme-color" content="#E3CCF2" />
<meta name="background-color" content="#E3CCF2" />
<meta name="Keywords" content="읽어보새" />
<meta name="Keywords" content="Readbird" />
<meta name="Keywords" content="Readbird, readbird" />
<meta name="Keywords" content="책 읽고, 키우고, 날아보자!" />
<meta name="description" content="책 읽고, 키우고, 날아보자!" />
<meta name="description" content="Reading Book, Catching Birds" />
<meta name="og:site_name" content="읽어보새(Readbird)" />
<meta name="og:title" content="읽어보새(Readbird)" />
<meta name="og:site_name" content="읽어보새 | Readbird" />
<meta name="og:title" content="읽어보새 | Readbird" />
<meta name="og:description" content="책 읽고, 키우고, 날아보자!" />
<meta name="og:type" content="website" />
<meta name="og:url" content="https://readbird.swygbro.com" />
<meta name="og:image" content="/blacklogo.png" />
<meta name="og:image" content="/readbird.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>읽어보새(Readbird)</title>
<title>읽어보새 | Readbird</title>
<script defer src="https://cdn.swygbro.com/public/widget/swyg-widget.js"></script>
</head>
<body>
Expand Down
10 changes: 5 additions & 5 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "ReadBird",
"short_name": "ReadBird",
"name": "Readbird",
"short_name": "Readbird",
"description": "Reading Book, Catching Birds",
"icons": [
{
"src": "blacklogo.png",
"sizes": "64x64 32x32 24x24 16x16",
"src": "readbird.png",
"sizes": "512x512",
"type": "image/png"
}
],
"start_url": "/",
"display": "standalone",
"theme_color": "#000000",
"theme_color": "#E3CCF2",
"background_color": "#ffffff",
"orientation": "portrait",
"filename": "manifest.json"
Expand Down
Binary file added public/readbird.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/whitelogo.png
Binary file not shown.
38 changes: 22 additions & 16 deletions src/assets/images/Images.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import noImage from '@assets/images/noImage.jpeg';
import NOT_IMAGE from '@assets/images/noImage.jpeg';
import { SyntheticEvent, memo, useCallback } from 'react';
import styled, { CSSObject } from 'styled-components';

Expand All @@ -8,24 +8,30 @@ type TProps = {
imgWidth?: number;
imgHeight?: number;
imgStyle?: CSSObject;
noImage?: string;
};

export const Images = memo(({ imgUrl, imgAlt, imgWidth, imgHeight, imgStyle }: TProps) => {
const handleError = useCallback((e: SyntheticEvent<HTMLImageElement, Event>) => {
e.currentTarget.src = noImage;
}, []);
export const Images = memo(
({ imgUrl, imgAlt, imgWidth, imgHeight, imgStyle, noImage = NOT_IMAGE }: TProps) => {
const handleError = useCallback(
(e: SyntheticEvent<HTMLImageElement, Event>) => {
e.currentTarget.src = noImage;
},
[noImage]
);

return (
<ImageStyle
$imgStyle={imgStyle}
src={imgUrl ?? noImage}
alt={imgAlt}
width={imgWidth}
height={imgHeight}
onError={handleError}
/>
);
});
return (
<ImageStyle
$imgStyle={imgStyle}
src={imgUrl ?? noImage}
alt={imgAlt}
width={imgWidth}
height={imgHeight}
onError={handleError}
/>
);
}
);

type TImageProps = {
$imgStyle?: CSSObject;
Expand Down
File renamed without changes
3 changes: 3 additions & 0 deletions src/components/templates/HomeTemplate/Plan/Stamp/Stamp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export const Stamp = ({
setRecordStatus({
planId,
recordStatus: ERecordStatus.success,
planStatus: ERecordStatus.inProgress,
currentPage: maxPage
})
);
Expand Down Expand Up @@ -164,6 +165,7 @@ export const Stamp = ({
setRecordStatus({
planId,
recordStatus: ERecordStatus.failed,
planStatus: ERecordStatus.failed,
currentPage: page
})
);
Expand All @@ -173,6 +175,7 @@ export const Stamp = ({
setRecordStatus({
planId,
recordStatus: ERecordStatus.failed,
planStatus: ERecordStatus.inProgress,
currentPage: page
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export const MyEncyclopediaTemplate = () => {
const Wrap = styled.div`
width: 100%;
padding: 0 13px;
overflow: hidden;
`;

const StyledUl = styled.ul`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ export const MyRestoreTemplate = () => {
methods.setValue('endDate', dayjs().format('YYYY-MM-DD'));
methods.setValue('publisher', restoreData.publisher);
methods.setValue('title', restoreData.title);
methods.setValue('endDate', restoreData.endDate);
methods.setValue('startDate', restoreData.startDate);
methods.setValue('totalPage', restoreData.totalPage);
methods.setValue('currentPage', restoreData.currentPage);
methods.setValue('coverImage', restoreData.coverImage);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { TRootState } from '@/store/state';
import { Images } from '@assets/images';
import NOT_IMAGE from '@assets/images/purplelogo.png';
import { useSelector } from 'react-redux';
import styled from 'styled-components';

Expand All @@ -14,6 +15,7 @@ export const MyUserInfo = () => {
imgAlt={`${userInfo?.nickname}의 이미지`}
imgWidth={45}
imgHeight={45}
noImage={NOT_IMAGE}
/>
</div>
<div className="user-info">
Expand All @@ -35,8 +37,8 @@ const StyledUserWrap = styled.div`
width: 45px;
height: 45px;
border-radius: 16px;
background: #fff;
overflow: hidden;

img {
width: 100%;
height: 100%;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { addPlanData, setPlanData } from '@/store/reducers';
import { Alert, convertError, debounce, go, lastDayMonth } from '@/utils';
import { Alert, convertError, debounce, go, isPastDate, lastDayMonth } from '@/utils';
import { axiosFetch } from '@api/axios';
import {
EAchievementStatus,
Expand Down Expand Up @@ -130,7 +130,7 @@ export const RegisterModal = ({ setIsOpen, planId, isRestore }: TProps) => {
const props = getValues();
if (!planId) {
// 시작일이 오늘보다 이전날짜
if (dayjs(props.startDate).format('YYYY-MM-DD') < dayjs().format('YYYY-MM-DD')) {
if (isPastDate(props.startDate, new Date())) {
setError('startDate', {
message: '* 오늘보다 이전 날짜를 설정할 수 없습니다.'
});
Expand All @@ -139,18 +139,15 @@ export const RegisterModal = ({ setIsOpen, planId, isRestore }: TProps) => {
}

// 종료일이 시작일보다 이전날짜
if (dayjs(props.endDate).format('YYYY-MM-DD') < dayjs(props.startDate).format('YYYY-MM-DD')) {
if (isPastDate(props.endDate, props.startDate)) {
setError('endDate', {
message: '* 시작일보다 이전 날짜를 설정할 수 없습니다.'
});
return;
}

// 종료일이 1년초과
if (
dayjs(props.startDate).add(1, 'year').format('YYYY-MM-DD') <
dayjs(props.endDate).format('YYYY-MM-DD')
) {
if (isPastDate(dayjs(props.startDate).add(1, 'year').format('YYYY-MM-DD'), props.endDate)) {
setError('endDate', {
message: '* 시작일에서 1년이 초과하는 날짜를 설정할 수 없습니다.'
});
Expand Down
1 change: 1 addition & 0 deletions src/declare.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
declare module '*.jpg';
declare module '*.jpeg';
declare module '*.png';
declare module '*.svg';
10 changes: 8 additions & 2 deletions src/store/reducers/userPlan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ const planSlice = createSlice({
...data,
currentPage: data.totalPage,
target: 0,
recordStatus: ERecordStatus.success
recordStatus: ERecordStatus.success,
planStatus: ERecordStatus.success
};
}
return data;
Expand All @@ -85,7 +86,12 @@ const planSlice = createSlice({
},
setRecordStatus: (
state,
action: PayloadAction<{ planId: number; recordStatus: ERecordStatus; currentPage: number }>
action: PayloadAction<{
planId: number;
recordStatus: ERecordStatus;
currentPage: number;
planStatus: ERecordStatus;
}>
) => {
state.planData = state.planData.map((plan) => {
if (plan.planId === action.payload.planId) {
Expand Down
25 changes: 25 additions & 0 deletions src/utils/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,28 @@ export const isSameDate = (currentDate: string, compareDate: string) => {

return true;
};

export const isPastDate = (currentDate: string, compareDate: string | Date) => {
const current = new Date(currentDate);
const compare = new Date(compareDate);

if (current.getFullYear() < compare.getFullYear()) {
return true;
} else if (current.getFullYear() > compare.getFullYear()) {
return false;
}

if (current.getMonth() < compare.getMonth()) {
return true;
} else if (current.getMonth() > compare.getMonth()) {
return false;
}

if (current.getDate() < compare.getDate()) {
return true;
} else if (current.getDate() > compare.getDate()) {
return false;
}

return false;
};
Loading