-
Notifications
You must be signed in to change notification settings - Fork 5
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
[FE] 생성한 행사 모아보기 페이지 #856
[FE] 생성한 행사 모아보기 페이지 #856
Changes from all commits
9698c32
79a497a
f366d8c
33506eb
95b2fae
5ae1110
74b2c24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {css} from '@emotion/react'; | ||
|
||
import {WithTheme} from '@components/Design/type/withTheme'; | ||
|
||
export const inProgressCheckStyle = ({inProgress, theme}: WithTheme<{inProgress: boolean}>) => | ||
css({ | ||
display: 'flex', | ||
alignItems: 'center', | ||
gap: '0.125rem', | ||
border: `1px solid ${inProgress ? theme.colors.primary : theme.colors.gray}`, | ||
borderRadius: '0.5rem', | ||
padding: '0.25rem 0.375rem', | ||
height: '1.25rem', | ||
|
||
'.in-progress-check-text': { | ||
color: inProgress ? theme.colors.primary : theme.colors.gray, | ||
paddingTop: '0.0625rem', | ||
}, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** @jsxImportSource @emotion/react */ | ||
import {useNavigate} from 'react-router-dom'; | ||
|
||
import Text from '@HDcomponents/Text/Text'; | ||
|
||
import {useTheme} from '@components/Design'; | ||
|
||
import Flex from '../Flex/Flex'; | ||
import Input from '../Input/Input'; | ||
|
||
import {CreatedEventItemProps, CreatedEventListProps} from './CreatedEvent.type'; | ||
import {inProgressCheckStyle} from './CreatedEvent.style'; | ||
|
||
function InProgressCheck({inProgress}: {inProgress: boolean}) { | ||
const {theme} = useTheme(); | ||
|
||
return ( | ||
<div css={inProgressCheckStyle({theme, inProgress})}> | ||
<Text size="tiny" className="in-progress-check-text"> | ||
{inProgress ? '진행' : '완료'} | ||
</Text> | ||
</div> | ||
); | ||
} | ||
|
||
function CreatedEventItem({createdEvent}: CreatedEventItemProps) { | ||
const navigate = useNavigate(); | ||
const onClick = () => { | ||
navigate(`/event/${createdEvent.eventId}/admin`); | ||
}; | ||
|
||
return ( | ||
<Flex | ||
justifyContent="spaceBetween" | ||
alignItems="center" | ||
height="2.5rem" | ||
padding="0.5rem 1rem" | ||
paddingInline="0.5rem" | ||
onClick={onClick} | ||
> | ||
<Flex gap="0.5rem" alignItems="center"> | ||
<InProgressCheck inProgress={createdEvent.isFinished} /> | ||
<Text size="bodyBold" color="onTertiary"> | ||
{createdEvent.eventName} | ||
</Text> | ||
</Flex> | ||
</Flex> | ||
); | ||
} | ||
|
||
function CreatedEventList({createdEvents, eventName, onSearch, placeholder}: CreatedEventListProps) { | ||
return ( | ||
<Flex | ||
flexDirection="column" | ||
width="100%" | ||
backgroundColor="white" | ||
padding="0.5rem 1rem" | ||
paddingInline="0.5rem" | ||
gap="0.5rem" | ||
height="100%" | ||
cssProp={{borderRadius: '1rem'}} | ||
> | ||
<Input inputType="search" value={eventName} onChange={onSearch} placeholder={placeholder} /> | ||
{createdEvents.length !== 0 && | ||
createdEvents.map(createdEvent => <CreatedEventItem key={createdEvent.eventId} createdEvent={createdEvent} />)} | ||
</Flex> | ||
); | ||
} | ||
|
||
export default CreatedEventList; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {CreatedEvent} from './../../../../types/serviceType'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
export interface CreatedEventItemProps { | ||
createdEvent: CreatedEvent; | ||
} | ||
|
||
export interface CreatedEventListProps { | ||
eventName: string; | ||
onSearch: ({target}: React.ChangeEvent<HTMLInputElement>) => void; | ||
placeholder: string; | ||
createdEvents: CreatedEvent[]; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {useQuery} from '@tanstack/react-query'; | ||
|
||
import {requestGetCreatedEvents} from '@apis/request/event'; | ||
|
||
import QUERY_KEYS from '@constants/queryKeys'; | ||
|
||
const useRequestGetCreatedEvents = () => { | ||
const {data, ...rest} = useQuery({ | ||
queryKey: [QUERY_KEYS.createdEvents], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 유저 로그아웃이 없으니깐 토다리가 작성해준 대로 이 부분은 queryKey 배열의 두 번째 인자 신경 쓰지 않아도 될 것 같아요! |
||
queryFn: () => requestGetCreatedEvents(), | ||
select: data => ({ | ||
...data, | ||
events: data.events.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. select 좋은 것 같아요! 이 시간 비교는 밀리초 단위로 비교되는 건가요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아뇨 10^-6 까지 비교합니다 ㅋㅋ |
||
}), | ||
}); | ||
|
||
return { | ||
events: data?.events, | ||
...rest, | ||
}; | ||
}; | ||
|
||
export default useRequestGetCreatedEvents; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ const useRequestGetEvent = ({...props}: WithErrorHandlingStrategy | null = {}) = | |
const eventId = getEventIdByUrl(); | ||
|
||
const {data, ...rest} = useSuspenseQuery({ | ||
queryKey: [QUERY_KEYS.event], | ||
queryKey: [QUERY_KEYS.event, eventId], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 원래는 이벤트 생성을 했을 때 removeQueries를 사용해서 캐시를 전부 날려주었기 때문에 문제가 없었는데, 이제는 생성 외에 다른 이벤트 접근이 가능해서 일어난 문제였네요.. 이것 외에 또 다른 부작용은 없었나요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 우선 손수 테스트 한 케이스에선 별도로 없었습니다~! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오호 좋아요~ |
||
queryFn: () => requestGetEvent({eventId, ...props}), | ||
}); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ const useRequestGetSteps = ({...props}: WithErrorHandlingStrategy | null = {}) = | |
const eventId = getEventIdByUrl(); | ||
|
||
const queryResult = useQuery({ | ||
queryKey: [QUERY_KEYS.steps], | ||
queryKey: [QUERY_KEYS.steps, eventId], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오우.. 다른 부분도 꼼꼼히 체크해서 eventId 넣어주셨군요! 쵝오 |
||
queryFn: () => requestGetSteps({eventId, ...props}), | ||
}); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import {css} from '@emotion/react'; | ||
import {useEffect, useState} from 'react'; | ||
|
||
import CreatedEventList from '@components/Design/components/CreatedEvent/CreatedEvent'; | ||
import useRequestGetCreatedEvents from '@hooks/queries/event/useRequestGetCreatedEvents'; | ||
|
||
import {MainLayout, Top, TopNav} from '@components/Design'; | ||
|
||
export default function CreatedEventsPage() { | ||
const [eventName, setEventName] = useState(''); | ||
const {events} = useRequestGetCreatedEvents(); | ||
const [matchedEvents, setMatchedEvents] = useState(events); | ||
|
||
useEffect(() => { | ||
setMatchedEvents(events?.filter(event => event.eventName.includes(eventName))); | ||
}, [eventName, events]); | ||
|
||
const onSearch = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
setEventName(e.target.value); | ||
}; | ||
|
||
return ( | ||
<MainLayout backgroundColor="white"> | ||
<TopNav> | ||
<TopNav.Item displayName="뒤로가기" noEmphasis routePath="-1" /> | ||
</TopNav> | ||
<div | ||
css={css` | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1rem; | ||
padding: 1rem; | ||
`} | ||
> | ||
<Top> | ||
<Top.Line text="지금까지 주최했던 행사를" emphasize={['주최했던 행사']} /> | ||
<Top.Line text="확인해 보세요" /> | ||
</Top> | ||
</div> | ||
<div | ||
css={css` | ||
display: flex; | ||
padding-inline: 0.5rem; | ||
`} | ||
> | ||
<CreatedEventList | ||
createdEvents={matchedEvents ?? []} | ||
eventName={eventName} | ||
onSearch={onSearch} | ||
placeholder="행사 이름 검색" | ||
/> | ||
</div> | ||
</MainLayout> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
원하는 행사 서칭까지 가능하도록 해주시다니~ 👍