-
Notifications
You must be signed in to change notification settings - Fork 1
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
refac: 공연 상세는 레이지 로딩 하지 않으며 레이웃은 라우터에서 주입 #219
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,7 +99,6 @@ const ShowCastInfoFormDialogContent = ({ onDelete, prevShowCastInfo, onSave }: P | |
<Styled.Row key={field._id}> | ||
<Controller | ||
control={control} | ||
defaultValue={field.userCode} | ||
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. 요 수정 사항은 콘솔에서 에러 발생해서 controlled input에서 defalutValue를 주입하는 곳은 제거 |
||
render={({ field: { onChange, onBlur } }) => { | ||
const value = field.userCode; | ||
const isError = Boolean( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
import { useMyHostInfo, useShowLastSettlementEvent, useShowSettlementInfo } from '@boolti/api'; | ||
import { | ||
useMyHostInfo, | ||
useShowDetail, | ||
useShowLastSettlementEvent, | ||
useShowSettlementInfo, | ||
} from '@boolti/api'; | ||
import { ArrowLeftIcon } from '@boolti/icon'; | ||
import { Setting } from '@boolti/icon/src/components/Setting.tsx'; | ||
import { useDialog } from '@boolti/ui'; | ||
import { palette, useDialog } from '@boolti/ui'; | ||
import { useTheme } from '@emotion/react'; | ||
import { useInView } from 'react-intersection-observer'; | ||
import { useMatch, useNavigate, useParams } from 'react-router-dom'; | ||
|
@@ -14,7 +19,7 @@ import Layout from '../Layout/index.tsx'; | |
import Styled from './ShowDetailLayout.styles.ts'; | ||
import AuthoritySettingDialogContent from '../AuthoritySettingDialogContent'; | ||
import { HostListItem, HostType } from '@boolti/api/src/types/host.ts'; | ||
import { atom, useAtom } from 'jotai'; | ||
import { atom, useAtom, useAtomValue } from 'jotai'; | ||
import { useEffect } from 'react'; | ||
import { useDeviceWidth } from '~/hooks/useDeviceWidth.ts'; | ||
import ProfileDropdown from '../ProfileDropdown/index.tsx'; | ||
|
@@ -27,51 +32,64 @@ const settlementTooltipText = { | |
}; | ||
|
||
interface ShowDetailLayoutProps { | ||
showName: string; | ||
children?: React.ReactNode; | ||
onClickMiddleware?: () => Promise<boolean>; | ||
} | ||
|
||
export const myHostInfoAtom = atom<HostListItem | null>(null); | ||
|
||
const ShowDetailLayout = ({ showName, children, onClickMiddleware }: ShowDetailLayoutProps) => { | ||
const { ref: topObserverRef, inView: topInView } = useInView({ | ||
threshold: 1, | ||
initialInView: true, | ||
}); | ||
const { ref: headerObserverRef, inView: headerInView } = useInView({ | ||
threshold: 0.01, | ||
initialInView: true, | ||
}); | ||
const theme = useTheme(); | ||
const navigate = useNavigate(); | ||
export const middlewareAtom = atom<(() => Promise<boolean>) | undefined>(undefined); | ||
|
||
interface TabItemProps { | ||
type: 'INFO' | 'TICKET' | 'RESERVATION' | 'ENTRANCE' | 'SETTLEMENT'; | ||
} | ||
|
||
const matchTargets: Record<TabItemProps['type'], string> = { | ||
INFO: PATH.SHOW_INFO, | ||
TICKET: PATH.SHOW_TICKET, | ||
RESERVATION: PATH.SHOW_RESERVATION, | ||
ENTRANCE: PATH.SHOW_ENTRANCE, | ||
SETTLEMENT: PATH.SHOW_SETTLEMENT, | ||
}; | ||
|
||
const toTargets = { | ||
INFO: HREF.SHOW_INFO, | ||
TICKET: HREF.SHOW_TICKET, | ||
RESERVATION: HREF.SHOW_RESERVATION, | ||
ENTRANCE: HREF.SHOW_ENTRANCE, | ||
SETTLEMENT: HREF.SHOW_SETTLEMENT, | ||
} as const; | ||
|
||
const label = { | ||
INFO: '공연 기본 정보', | ||
TICKET: '티켓 관리', | ||
RESERVATION: '방문자 관리', | ||
ENTRANCE: '입장 관리', | ||
SETTLEMENT: '정산 관리', | ||
}; | ||
|
||
const tooltipStyle = { | ||
color: palette.grey.w, | ||
padding: '6px 8px', | ||
backgroundColor: palette.grey.g90, | ||
borderRadius: '4px', | ||
boxShadow: `0px 4px 10px 0px ${palette.shadow}`, | ||
fontWeight: '400', | ||
fontStyle: 'normal', | ||
lineHeight: '18px', | ||
fontDisplay: 'auto', | ||
fontSize: '12px', | ||
}; | ||
|
||
const TabItem = ({ type }: TabItemProps) => { | ||
const params = useParams<{ showId: string }>(); | ||
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. 파일을 따로 빼기는 애매해서 한 파일안에 넣어둠 |
||
const matchInfoTab = useMatch(PATH.SHOW_INFO); | ||
const matchTicketTab = useMatch(PATH.SHOW_TICKET); | ||
const matchReservationTab = useMatch(PATH.SHOW_RESERVATION); | ||
const matchEntryTab = useMatch(PATH.SHOW_ENTRANCE); | ||
const matchSettlementTab = useMatch(PATH.SHOW_SETTLEMENT); | ||
const authoritySettingDialog = useDialog(); | ||
const showId = Number(params!.showId); | ||
const [, setMyHostInfo] = useAtom(myHostInfoAtom); | ||
const deviceWidth = useDeviceWidth(); | ||
const isMobile = deviceWidth < parseInt(theme.breakpoint.mobile, 10); | ||
const { data: myHostInfoData } = useMyHostInfo(showId); | ||
const { data: lastSettlementEvent } = useShowLastSettlementEvent(showId); | ||
|
||
const { data: settlementInfo } = useShowSettlementInfo(showId); | ||
const { data: lastSettlementEvent } = useShowLastSettlementEvent(showId); | ||
|
||
const tooltipStyle = { | ||
color: theme.palette.grey.w, | ||
padding: '6px 8px', | ||
backgroundColor: theme.palette.grey.g90, | ||
borderRadius: '4px', | ||
boxShadow: `0px 4px 10px 0px ${theme.palette.shadow}`, | ||
fontWeight: '400', | ||
fontStyle: 'normal', | ||
lineHeight: '18px', | ||
fontDisplay: 'auto', | ||
fontSize: '12px', | ||
}; | ||
const match = useMatch(matchTargets[type]); | ||
const navigate = useNavigate(); | ||
const middleware = useAtomValue(middlewareAtom); | ||
|
||
const isSettlementInfoEmpty = | ||
settlementInfo?.bankAccount === null || | ||
|
@@ -94,12 +112,74 @@ const ShowDetailLayout = ({ showName, children, onClickMiddleware }: ShowDetailL | |
return false; | ||
})(); | ||
|
||
return ( | ||
<Styled.TabItem | ||
active={match !== null} | ||
id={type === 'SETTLEMENT' ? 'settlement-page-tooltip' : undefined} | ||
onClick={async () => { | ||
if (!params.showId) return; | ||
|
||
if (middleware && !(await middleware())) { | ||
return; | ||
} | ||
|
||
navigate(toTargets[type](params.showId)); | ||
}} | ||
> | ||
{label[type]} | ||
{isTooltipVisible && ( | ||
<Tooltip | ||
content={settlementTooltipText[lastSettlementEvent?.settlementEventType ?? 'DEFAULT']} | ||
anchorSelect="#settlement-page-tooltip" | ||
isOpen | ||
style={tooltipStyle} | ||
className="tooltip" | ||
place="top" | ||
positionStrategy="fixed" | ||
offset={0} | ||
opacity={0.85} | ||
/> | ||
)} | ||
</Styled.TabItem> | ||
); | ||
}; | ||
|
||
const ShowDetailLayout = ({ children }: ShowDetailLayoutProps) => { | ||
const { ref: topObserverRef, inView: topInView } = useInView({ | ||
threshold: 1, | ||
initialInView: true, | ||
}); | ||
const { ref: headerObserverRef, inView: headerInView } = useInView({ | ||
threshold: 0.01, | ||
initialInView: true, | ||
}); | ||
const theme = useTheme(); | ||
const navigate = useNavigate(); | ||
const params = useParams<{ showId: string }>(); | ||
|
||
const authoritySettingDialog = useDialog(); | ||
const showId = Number(params!.showId); | ||
|
||
const [, setMyHostInfo] = useAtom(myHostInfoAtom); | ||
|
||
const deviceWidth = useDeviceWidth(); | ||
const isMobile = deviceWidth < parseInt(theme.breakpoint.mobile, 10); | ||
|
||
const { data: show } = useShowDetail(showId); | ||
const { data: myHostInfoData } = useMyHostInfo(showId); | ||
|
||
const middleware = useAtomValue(middlewareAtom); | ||
|
||
useEffect(() => { | ||
if (myHostInfoData) { | ||
setMyHostInfo({ ...myHostInfoData }); | ||
} | ||
}, [myHostInfoData, setMyHostInfo]); | ||
|
||
if (!show || !myHostInfoData) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
<Styled.TopObserver ref={topObserverRef} /> | ||
|
@@ -112,7 +192,7 @@ const ShowDetailLayout = ({ showName, children, onClickMiddleware }: ShowDetailL | |
<Styled.BackButton | ||
type="button" | ||
onClick={async () => { | ||
if (onClickMiddleware && !(await onClickMiddleware())) { | ||
if (middleware && !(await middleware())) { | ||
return; | ||
} | ||
|
||
|
@@ -128,7 +208,9 @@ const ShowDetailLayout = ({ showName, children, onClickMiddleware }: ShowDetailL | |
/> | ||
<Styled.HeaderContent> | ||
<Styled.ShowNameWrapper> | ||
<Styled.ShowName size={headerInView ? 'big' : 'small'}>{showName}</Styled.ShowName> | ||
<Styled.ShowName size={headerInView ? 'big' : 'small'}> | ||
{show?.name} | ||
</Styled.ShowName> | ||
{myHostInfoData?.type !== HostType.SUPPORTER && ( | ||
<Styled.AuthorSettingButton | ||
type="button" | ||
|
@@ -154,94 +236,11 @@ const ShowDetailLayout = ({ showName, children, onClickMiddleware }: ShowDetailL | |
</Styled.ShowNameWrapper> | ||
<Styled.TabContainer> | ||
<Styled.Tab> | ||
<Styled.TabItem | ||
active={matchInfoTab !== null} | ||
onClick={async () => { | ||
if (!params.showId) return; | ||
|
||
if (onClickMiddleware && !(await onClickMiddleware())) { | ||
return; | ||
} | ||
|
||
navigate(HREF.SHOW_INFO(params.showId)); | ||
}} | ||
> | ||
공연 기본 정보 | ||
</Styled.TabItem> | ||
<Styled.TabItem | ||
active={matchTicketTab !== null} | ||
onClick={async () => { | ||
if (!params.showId) return; | ||
|
||
if (onClickMiddleware && !(await onClickMiddleware())) { | ||
return; | ||
} | ||
|
||
navigate(HREF.SHOW_TICKET(params.showId)); | ||
}} | ||
> | ||
티켓 관리 | ||
</Styled.TabItem> | ||
<Styled.TabItem | ||
active={matchReservationTab !== null} | ||
onClick={async () => { | ||
if (!params.showId) return; | ||
|
||
if (onClickMiddleware && !(await onClickMiddleware())) { | ||
return; | ||
} | ||
|
||
navigate(HREF.SHOW_RESERVATION(params.showId)); | ||
}} | ||
> | ||
방문자 관리 | ||
</Styled.TabItem> | ||
<Styled.TabItem | ||
active={matchEntryTab !== null} | ||
onClick={async () => { | ||
if (!params.showId) return; | ||
|
||
if (onClickMiddleware && !(await onClickMiddleware())) { | ||
return; | ||
} | ||
|
||
navigate(HREF.SHOW_ENTRANCE(params.showId)); | ||
}} | ||
> | ||
입장 관리 | ||
</Styled.TabItem> | ||
<Styled.TabItem | ||
active={matchSettlementTab !== null} | ||
onClick={async () => { | ||
if (!params.showId) return; | ||
|
||
if (onClickMiddleware && !(await onClickMiddleware())) { | ||
return; | ||
} | ||
|
||
navigate(HREF.SHOW_SETTLEMENT(params.showId)); | ||
}} | ||
id="settlement-page-tooltip" | ||
> | ||
정산 관리 | ||
{isTooltipVisible && ( | ||
<Tooltip | ||
content={ | ||
settlementTooltipText[ | ||
lastSettlementEvent?.settlementEventType ?? 'DEFAULT' | ||
] | ||
} | ||
anchorSelect="#settlement-page-tooltip" | ||
isOpen | ||
style={tooltipStyle} | ||
className="tooltip" | ||
place="top" | ||
positionStrategy="fixed" | ||
offset={0} | ||
opacity={0.85} | ||
/> | ||
)} | ||
</Styled.TabItem> | ||
<TabItem type="INFO" /> | ||
<TabItem type="TICKET" /> | ||
<TabItem type="RESERVATION" /> | ||
<TabItem type="ENTRANCE" /> | ||
<TabItem type="SETTLEMENT" /> | ||
</Styled.Tab> | ||
</Styled.TabContainer> | ||
</Styled.HeaderContent> | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
레이아웃 사용하는 부분만 서브 라우터 분리