Skip to content

Commit

Permalink
Merge pull request #466 from connect-foundation/develop
Browse files Browse the repository at this point in the history
Release 0.6.0
  • Loading branch information
FullOfOrange authored Dec 19, 2019
2 parents 33b24a4 + 0898571 commit 3727bf7
Show file tree
Hide file tree
Showing 21 changed files with 202 additions and 71 deletions.
1 change: 1 addition & 0 deletions client/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"SharedArrayBuffer": "readonly"
},
"rules": {
"@typescript-eslint/no-unused-vars": "error",
"jest/no-disabled-tests": "warn",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
Expand Down
2 changes: 1 addition & 1 deletion client/cypress/integration/eventjoin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,6 @@ context('์ด๋ฒคํŠธ ์˜ˆ์•ฝ ํŽ˜์ด์ง€', () => {
expect(alertStub.getCall(0)).to.be.calledWith(RESERVE_COMPLETE);
});

cy.location('pathname').should('eq', '/');
cy.location('pathname').should('eq', '/my/tickets');
});
});
27 changes: 22 additions & 5 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import GlobalStoreProvider from 'stores';
import { UserAccountState, UserAccountAction } from 'stores/accountStore';
import { defaultAccountState } from 'stores/accountStore/reducer';
import { AfterLoginAction } from 'stores/afterLoginStore';
import { useIsMount } from 'hooks';
const { REACT_APP_TEST_UID_TOKEN } = process.env;

Expand All @@ -36,11 +37,11 @@ const App: React.FC = () => {
<GlobalStyles />
<Router>
<Switch>
<Route exact path="/" component={Main} />
<Route path="/login" component={Login} />
<Route path="/signup" component={SignUp} />
<PublicRoute exact path="/" component={Main} />
<PublicRoute path="/login" component={Login} />
<PublicRoute path="/signup" component={SignUp} />
<PrivateRoute exact path="/event/create" component={EventCreate} />
<Route
<PublicRoute
exact
path="/events/:eventId([0-9]+)"
component={EventDetail}
Expand All @@ -54,7 +55,7 @@ const App: React.FC = () => {
component={MyPage}
/>

<Route path="*" component={NotFound} />
<PublicRoute path="*" component={NotFound} />
</Switch>
</Router>
</ThemeProvider>
Expand All @@ -64,6 +65,16 @@ const App: React.FC = () => {

export default App;

function PublicRoute({ ...rest }: any): React.ReactElement {
const { setLoginCallback } = useContext(AfterLoginAction);

useEffect(() => {
setLoginCallback('/');
}, [setLoginCallback]);

return <Route {...rest} />;
}

function PrivateRoute({
component: TargetPage,
...rest
Expand All @@ -72,11 +83,17 @@ function PrivateRoute({
const accountState = useContext(UserAccountState);
const { setLoginState } = useContext(UserAccountAction);
const [isLoginCheck, setIsLoginCheck] = useState(false);
const { setLoginCallback } = useContext(AfterLoginAction);
const path = window.location.pathname;

useEffect(() => {
setLoginState(true);
}, [setLoginState]);

useEffect(() => {
if (isLoginCheck && !accountState.isLogin) setLoginCallback(path);
}, [rest, accountState.isLogin, setLoginCallback, isLoginCheck, path]);

useIsMount(() => {
if (defaultAccountState !== accountState) setIsLoginCheck(true);
}, accountState);
Expand Down
8 changes: 6 additions & 2 deletions client/src/commons/constants/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export const LOGIN_SOCIAL = '์†Œ์…œ ๊ณ„์ •์„ ์‚ฌ์šฉํ•ด์„œ ๋กœ๊ทธ์ธ';
export const BEFORE_LOGIN = '๊ฐ€์ž… ํ˜น์€ ๋กœ๊ทธ์ธ';
export const FOOTER_INFO =
'๋Œ€ํ‘œ ์ด๋ฉ”์ผ boostcamp@festa.io\n๋ถ์–ด์Šค(BookUs) | ๋Œ€ํ‘œ ๋ถ€์บ ์ด | ์„œ์šธํŠน๋ณ„์‹œ ์„œ์šธ๊ตฌ ์„œ์šธ๋™ ์„œ์šธ๋กœ 123-1234 | ํ†ต์‹ ํŒ๋งค์—… 12345678 | ๋Œ€ํ‘œ์ „ํ™” 123-1234-1234 (๋ฌธ์˜๋Š” ์ด๋ฉ”์ผ ๋ฐ”๋ž๋‹ˆ๋‹ค)';
export const INTERNAL_SERVER_ERROR =
'์„œ๋ฒ„ ์š”์ฒญ์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค. ์ž ์‹œ ํ›„์— ๋‹ค์‹œ ์‹œ๋„ํ•ด์ฃผ์„ธ์š”';

export const SIGNUP_EMAIL = '์ด๋ฉ”์ผ';
export const SIGNUP_LAST_NAME = '์„ฑ';
Expand Down Expand Up @@ -131,12 +133,15 @@ export const BOUGHT_TICKET_EVENT_TITLE_CAPTION = 'ํ˜„์žฌ ๊ตฌ๋งคํ•œ ํ‹ฐ์ผ“ ๋ชฉ๋ก
export const HISTORY_METHOD_PUSH = 'PUSH';
export const HISTORY_METHOD_REPLACE = 'REPLACE';


export const REFUND_TICKET_SUCCESS = 'ํ™˜๋ถˆ์ด ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.';
export const REFUND_TICKET_FAILURE = 'ํ™˜๋ถˆ์ด ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค.';
export const NOT_FOUND_BOUGHT_TICKET = '์•„์ง ๊ตฌ๋งคํ•œ ํ‹ฐ์ผ“์ด ์—†๋„ค์š”..๐Ÿ˜…';
export const NOT_FOUND_CREATED_EVENT = '์ฃผ์ตœํ•œ ์ด๋ฒคํŠธ๊ฐ€ ์—†๋„ค์š”..๐Ÿคฃ';

export const TICKET_REMAIN_DAYS = '์ผ ํ›„์— ํŒ๋งค๋งˆ๊ฐ';
export const TICKET_INVALID_DATE = 'ํŒ๋งค๊ธฐ๊ฐ„์ด ์ง€๋‚ฌ์Šต๋‹ˆ๋‹ค';
export const TICKET_COMMING_SOON = '์ผ ํ›„ ํŒ๋งค์‹œ์ž‘';

export const FORM_NAME: any = {
event: {
isPublic: '๊ณต๊ฐœ ์—ฌ๋ถ€',
Expand Down Expand Up @@ -164,4 +169,3 @@ export const FORM_NAME: any = {
refundEndAt: 'ํ‹ฐ์ผ“ ํ™˜๋ถˆ ๋งˆ๊ฐ ๋‚ ์งœ',
},
};

2 changes: 1 addition & 1 deletion client/src/components/molecules/IconBtn/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React from 'react';

import * as S from './style';
import { Props as BtnProps } from 'components/atoms/Btn';
Expand Down
9 changes: 5 additions & 4 deletions client/src/components/organisms/EventHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface Props {
endAt: string;
user: User;
ticketType: TicketType;
doneEvent?: boolean;
doneEventType?: number;
}

function EventHeader({
Expand All @@ -26,12 +26,13 @@ function EventHeader({
endAt,
user,
ticketType,
doneEvent,
doneEventType,
}: Props): React.ReactElement {
const ticketInfo = ticketType;
const { firstName, lastName } = user;
const profileImgUrl =
'https://kr.object.ncloudstorage.com/bookus/defaultProfileImg.png';
const doneTypes = ['๋“ฑ๋ก', '์ข…๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.', '๋งค์ง„๋˜์—ˆ์Šต๋‹ˆ๋‹ค.'];

return (
<S.HeaderContainer>
Expand Down Expand Up @@ -71,9 +72,9 @@ function EventHeader({
<S.ReservedPeople>{ticketInfo.leftCnt}๋ช…</S.ReservedPeople>
</S.ReservedPeopleContainer>
<S.SubmitBtn
children={doneEvent ? '์ด๋ฒคํŠธ ์ข…๋ฃŒ' : '๋“ฑ๋ก'}
children={!doneEventType ? doneTypes[0] : doneTypes[doneEventType]}
to={`/events/${eventId}/register/tickets`}
disabled={doneEvent}
disabled={doneEventType === 1 || doneEventType === 2}
/>
</S.SubmitContainer>
</S.HeaderContainer>
Expand Down
42 changes: 33 additions & 9 deletions client/src/components/organisms/Ticket/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import { IconLabel, Price } from 'components';
import { calculateDiffDaysOfDateRange } from 'utils/dateCalculator';

import { FaTicketAlt, FaCheck, FaRegCalendarAlt } from 'react-icons/fa';
import {
TICKET_INVALID_DATE,
TICKET_REMAIN_DAYS,
TICKET_COMMING_SOON,
} from 'commons/constants/string';

interface Prop extends TicketType {
count?: number;
Expand All @@ -29,6 +34,26 @@ function Ticket({
Date().toString(),
salesEndAt,
);

function makeLabelContent(remainDays: number, salesStartAt: string) {
if (!doneEvent) {
return `${remainDays}${TICKET_REMAIN_DAYS}`;
}

if (remainDays <= 0) {
return TICKET_INVALID_DATE;
}

const convertToUTCDate = new Date();
convertToUTCDate.setHours(-9);

const commingDays = calculateDiffDaysOfDateRange(
convertToUTCDate.toString(),
salesStartAt,
);
return `${commingDays}${TICKET_COMMING_SOON}`;
}

return (
<>
<S.TicketLabel>ํ‹ฐ์ผ“</S.TicketLabel>
Expand All @@ -39,21 +64,20 @@ function Ticket({
</S.TicketPriceWrapper>
<S.TicketName>{`${name} ${count ? `* ${count}` : ''}`}</S.TicketName>
<S.TicketDesc>{desc}</S.TicketDesc>
<IconLabel
icon={<FaTicketAlt size={'1.5rem'} />}
labelContent={`${remainCnt}๊ฐœ ๋‚จ์Œ`}
/>
{leftCnt !== -1 && (
<IconLabel
icon={<FaTicketAlt size={'1.5rem'} />}
labelContent={`${remainCnt}๊ฐœ ๋‚จ์Œ`}
/>
)}

<IconLabel
icon={<FaCheck size={'1.5rem'} />}
labelContent={`1์ธ๋‹น ${maxCntPerPerson}๊ฐœ ๊ตฌ์ž… ๊ฐ€๋Šฅ`}
/>
<IconLabel
icon={<FaRegCalendarAlt size={'1.5rem'} />}
labelContent={
remainDays <= 0
? 'ํŒ๋งค๊ธฐ๊ฐ„์ด ์ข…๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.'
: `${remainDays}์ผ ํ›„์— ํŒ๋งค๋งˆ๊ฐ`
}
labelContent={makeLabelContent(remainDays, salesStartAt)}
/>
</S.TicketContentWrapContainer>
</S.TicketContentContainer>
Expand Down
8 changes: 6 additions & 2 deletions client/src/components/organisms/Ticket/style.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from 'styled-components';
import { theme, palette } from 'styled-tools';
import { theme, palette, ifProp } from 'styled-tools';

export const TicketLabel = styled.div`
${theme('fontStyle.h6')};
Expand All @@ -22,7 +22,11 @@ interface TicketContentWrapContainerProps {
export const TicketContentWrapContainer = styled.div<
TicketContentWrapContainerProps
>`
color: ${palette('grayscale', 4)}
color: ${ifProp(
'disabled',
palette('grayscale', 4),
palette('grayscale', 1),
)};
padding-left: 2rem;
padding-top: 1rem;
padding-bottom: 1rem;
Expand Down
4 changes: 2 additions & 2 deletions client/src/hooks/useFetch.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('Hooks', () => {
return <></>;
}
// when
const wrapper = mount(<MockComponent />);
mount(<MockComponent />);

// then
await new Promise(resolve => {
Expand Down Expand Up @@ -80,7 +80,7 @@ describe('Hooks', () => {
return <></>;
}
// when
const wrapper = mount(<MockComponent />);
mount(<MockComponent />);

// then
await new Promise(resolve => {
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/EventCreate/store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const TicketFormDefaultState: TicketFormState = {
value: '',
},
isPublicLeftCnt: {
valid: false,
valid: true,
value: false,
},
maxCntPerPerson: {
Expand Down
32 changes: 24 additions & 8 deletions client/src/pages/EventDetail/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext, useEffect, useState } from 'react';
import React, { useContext, useEffect, useState, useRef } from 'react';
import { useHistory, useParams } from 'react-router-dom';
import { NOT_FOUND, INTERNAL_SERVER_ERROR } from 'http-status';

Expand Down Expand Up @@ -52,6 +52,7 @@ function EventDetailView(): React.ReactElement {
const [internalServerError, setInternalError] = useState(false);
const history = useHistory();
const isEventInState = checkIfEventIsInState(eventsState.events!, +eventId!);
const remainDays = useRef(0);

const events = isEventInState
? eventsState.events!.get(+eventId!)!
Expand All @@ -73,19 +74,33 @@ function EventDetailView(): React.ReactElement {
longitude,
} = events;

const remainDays = calculateDiffDaysOfDateRange(
Date().toString(),
ticketType.salesEndAt,
);
function doneEventType() {
remainDays.current = calculateDiffDaysOfDateRange(
Date().toString(),
ticketType.salesEndAt,
);

if (remainDays.current <= 0) return 1;

const remainTickets = ticketType.quantity - ticketType.leftCnt;
if (remainTickets <= 0) return 2;

return 0;
}

useEffect(() => {
if (!isEventInState)
if (!isEventInState) {
eventFetchDispatcher({
type: 'EVENT',
params: {
eventId: +eventId!,
},
});
remainDays.current = calculateDiffDaysOfDateRange(
Date().toString(),
ticketType.salesEndAt,
);
}

if (eventsState.status === NOT_FOUND) {
history.replace('/NOT_FOUND');
Expand All @@ -101,6 +116,7 @@ function EventDetailView(): React.ReactElement {
eventsState.status,
history,
isEventInState,
ticketType.salesEndAt,
]);

return (
Expand All @@ -117,11 +133,11 @@ function EventDetailView(): React.ReactElement {
place,
ticketType,
}}
doneEvent={remainDays <= 0}
doneEventType={doneEventType()}
/>
}
eventContent={<TuiViewer content={desc} />}
ticket={<Ticket {...ticketType} doneEvent={remainDays <= 0} />}
ticket={<Ticket {...ticketType} doneEvent={!!doneEventType()} />}
place={
<Place
{...{
Expand Down
Loading

0 comments on commit 3727bf7

Please sign in to comment.