Skip to content

Commit

Permalink
Merge pull request #1527 from 42organization/fix/#1514-login-page-error
Browse files Browse the repository at this point in the history
[test-deploy] 로그인 만료 후 로그인페이지로도 돌아가지 않는 문제
  • Loading branch information
cweedlee authored Sep 2, 2024
2 parents e04d684 + 1b9dd38 commit 920b948
Show file tree
Hide file tree
Showing 13 changed files with 215 additions and 119 deletions.
6 changes: 5 additions & 1 deletion Layout/LayoutProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useRecoilValue } from 'recoil';
import { loginState } from 'utils/recoil/login';
import AdminAppLayout from 'Layout/AdminLayout';
import AgendaAppLayout from 'Layout/AgendaLayout';
import TakguAppLayout from 'Layout/TakguLayout';
Expand All @@ -10,15 +12,17 @@ type LayoutProviderProps = {
// 현재 페이지가 어떤 레이아웃을 사용할지 결정
// 로그인 스테이트 등은 각 레이아웃에서 확인
const LayoutProvider = ({ children }: LayoutProviderProps) => {
const isLogin = useRecoilValue(loginState);
console.log(isLogin);
const app = usePathname();
switch (app) {
case '':
case 'agenda':
return <AgendaAppLayout>{children}</AgendaAppLayout>;
case 'takgu':
return <TakguAppLayout>{children}</TakguAppLayout>;
case 'admin':
return <AdminAppLayout>{children}</AdminAppLayout>;
case '':
default:
return <>{children}</>;
}
Expand Down
4 changes: 2 additions & 2 deletions components/agenda/Form/AgendaForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ const AgendaForm = ({
if (!Array.isArray(newValue)) {
return;
}

if (newValue[1] - newValue[0] < minDistance) {
if (activeThumb === 0) {
const clamped = Math.min(newValue[0], 100 - minDistance);
setTeamLimit([clamped, clamped + minDistance]);
} else {
const clamped = Math.max(newValue[1], minDistance);
setTeamLimit([clamped - minDistance, clamped]);
if (clamped - minDistance < newValue[0]) setTeamLimit([2, 12]);
else setTeamLimit([clamped - minDistance, clamped]);
}
} else {
setTeamLimit(newValue as number[]);
Expand Down
6 changes: 3 additions & 3 deletions components/agenda/Home/AgendaInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import styles from 'styles/agenda/Home/AgendaInfo.module.scss';
// Props: API data
const AgendaInfo = ({
agendaInfo,
key,
idx,
}: {
agendaInfo: AgendaDataProps;
key: number;
idx: number;
}) => {
if (!agendaInfo) {
return <div>There is no agenda</div>;
Expand All @@ -20,7 +20,7 @@ const AgendaInfo = ({
const endDate = new Date(agendaInfo.agendaEndTime);

return (
<div className={styles.agendaInfoContainer} key={key}>
<div className={styles.agendaInfoContainer} key={idx}>
<div className={styles.agendaDateBox}>
<div className={styles.agendaStartDateMonth}>
{fillZero(`${startDate.getMonth()}`, 2)}
Expand Down
69 changes: 36 additions & 33 deletions components/agenda/Home/AgendaList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,48 @@ const AgendaList = ({ agendaList }: { agendaList: AgendaDataProps[] }) => {
const [selectedItem, setSelectedItem] = useState<number | null>(0);

return (
<div className={styles.container}>
<div className={styles.agendaListContainer}>
<div className={styles.agendaListItemContainer}>
{!agendaList || !agendaList.length ? (
<div>
<div className={styles.emptyContainer}>일정이 없습니다.</div>
<>
{!agendaList || !agendaList.length ? (
<div className={styles.emptyContainer}>일정이 없습니다.</div>
) : (
<div className={styles.container}>
<div className={styles.agendaListContainer}>
<div className={styles.agendaListItemContainer}>
{agendaList.map((agendaInfo, idx) => {
agendaInfo.idx = idx;
return (
<AgendaListItem
agendaInfo={agendaInfo}
key={idx}
idx={idx}
type='list'
className={idx === selectedItem ? styles.selected : ''}
setSelectedItem={setSelectedItem}
/>
);
})}
</div>
) : (
agendaList.map((agendaInfo, idx) => {
agendaInfo.idx = idx;
return (
<AgendaListItem
agendaInfo={agendaInfo}
key={idx}
type='list'
className={idx === selectedItem ? styles.selected : ''}
setSelectedItem={setSelectedItem}
/>
);
})
)}
</div>
<AgendaListItem
agendaInfo={agendaList[selectedItem || 0]}
idx={selectedItem || 0}
type='big'
/>
</div>
</div>
{agendaList.length && (
<AgendaListItem
agendaInfo={agendaList[selectedItem || 0]}
key={selectedItem || 0}
type='big'
/>
)}
</div>
</>
);
};

const AgendaListItem = ({
agendaInfo,
key,
idx,
type,
className,
setSelectedItem,
}: {
agendaInfo: AgendaDataProps;
key: number;
idx: number;
type?: string;
className?: string;
setSelectedItem?: (key: number) => void;
Expand All @@ -69,20 +68,24 @@ const AgendaListItem = ({
agendaInfo.agendaPosterUrl || '/image/agenda/42.jpg'
}) lightgray 50% / cover no-repeat`,
}}
key={key}
key={idx}
onClick={() => {
if (window.innerWidth < 961) {
router.push(href);
return;
}
if (type === 'list' && setSelectedItem && agendaInfo.idx) {
if (
type === 'list' &&
setSelectedItem &&
typeof agendaInfo.idx === 'number'
) {
setSelectedItem(agendaInfo.idx);
return;
}
router.push(href);
}}
>
<AgendaInfo agendaInfo={agendaInfo} key={key} />
<AgendaInfo agendaInfo={agendaInfo} idx={idx} />
<AgendaDeadLine />
</button>
);
Expand Down
3 changes: 1 addition & 2 deletions components/agenda/Home/MyAgendaBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const MyAgendaBtn = () => {
};
const myList =
useFetchGet<MyTeamDataProps[]>('/profile/current/list')?.data || [];
console.log(myList);
return (
<div
className={`${styles.myAgendaContainer} ${
Expand Down Expand Up @@ -61,7 +60,7 @@ const MyAgendaBtn = () => {
key={idx}
>
<div className={styles.myagendaItemContainer} key={idx}>
<MyTeamInfo myTeamInfo={myTeamInfo} key={idx} />
<MyTeamInfo myTeamInfo={myTeamInfo} key={idx} idx={idx} />
</div>
</Link>
))
Expand Down
6 changes: 3 additions & 3 deletions components/agenda/Home/MyTeamInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import styles from 'styles/agenda/Home/MyTeamInfo.module.scss';
// Props: API data
const MyTeamInfo = ({
myTeamInfo,
key,
idx,
}: {
myTeamInfo: MyTeamDataProps;
key: number;
idx: number;
}) => {
if (!myTeamInfo) {
return <div>참가중인 일정이 없습니다.</div>;
Expand All @@ -19,7 +19,7 @@ const MyTeamInfo = ({
const startDate = new Date(myTeamInfo.agendaStartTime as string);
//아래 주석달린 부분은 api 변경시 추가 예정입니다.
return (
<div className={styles.Container} key={key}>
<div className={styles.Container} key={idx}>
<div className={agendastyles.agendaDateBox}>
<div className={agendastyles.agendaStartDateMonth}>
{fillZero(`${startDate.getMonth()}`, 2)}
Expand Down
36 changes: 20 additions & 16 deletions components/agenda/utils/PageController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const PageController = ({
const max = data.length;

const fetchAgendaList = async () => {
const url = '/list';
const url = '/open';
const data = await instanceInAgenda
.get(url)
.then((res) => {
Expand Down Expand Up @@ -73,39 +73,43 @@ const PageController = ({

return (
<div className={styles.container}>
<button
<div
className={styles.agendaInfoContainer}
style={{
background: `linear-gradient(0deg, #fff 7rem, rgba(0, 0, 0, 0) 10rem), url(${
background: `linear-gradient(180deg, #fff 7rem, rgba(0, 0, 0, 0) 10rem), url(${
data[current]?.agendaPosterUrl || '/image/agenda/42.jpg'
}) lightgray 50% / cover no-repeat`,
}}
onClick={(e) => {
const target = e.target as HTMLElement;
if (
target.className.includes(styles.moveButton) ||
target.closest(styles.moveButton)
)
return;
data.length && data[current]
? handleNavigation('/agenda/' + data[current].agendaKey)
: null;
}}
>
<button
onClick={movePrev}
className={`${styles.moveButton} ${styles.moveButtonPrev}`}
>
<div className={styles.prev} />
</button>
<button
onClick={(e) => {
const target = e.target as HTMLElement;
if (
target.className.includes(styles.moveButton) ||
target.closest(styles.moveButton)
)
return;
data.length && data[current]
? handleNavigation('/agenda/' + data[current].agendaKey)
: null;
}}
className={styles.toClick}
/>

<button
className={`${styles.moveButton} ${styles.moveButtonNext}`}
onClick={moveNext}
>
<div className={styles.next} />
</button>
<AgendaInfo agendaInfo={data[current]} key={current || 0} />
</button>
<AgendaInfo agendaInfo={data[current]} idx={current || 0} />
</div>
<PageControllerNavigator
currentPage={current}
maxPage={data.length}
Expand Down
39 changes: 23 additions & 16 deletions pages/agenda/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,15 @@ import styles from 'styles/agenda/Home/Agenda.module.scss';
import listStyles from 'styles/agenda/Home/AgendaList.module.scss';

const Agenda: NextPage = () => {
const [showCurrent, setShowCurrent] = useState<boolean>(true);
const [showCurrent, setShowCurrent] = useState<string>('open');

const { PagaNationElementProps, content: historyData } =
usePageNation<AgendaDataProps>({
url: '/history',
});

const { data: currentData } = useFetchGet<AgendaDataProps[]>('/list');
const toggleStatus = (e: React.MouseEvent) => {
const target = e.target as HTMLButtonElement;
const status = showCurrent ? 'ongoing' : 'closed';
if ((target && target.name === status) || !target.name) return;
setShowCurrent(target.name === 'ongoing');
};
const { data: currentData } = useFetchGet<AgendaDataProps[]>('/confirm');
const { data: openData } = useFetchGet<AgendaDataProps[]>('/open');

return (
<div className={styles.agendaPageContainer}>
Expand All @@ -33,28 +28,40 @@ const Agenda: NextPage = () => {
<h2>AGENDA LIST</h2>
<div>
<button
className={`${listStyles.agendaListStatus} ${
showCurrent ? listStyles.selectedStatus : ''
}`}
className={`${listStyles.agendaListStatus}
${showCurrent === 'open' ? listStyles.selectedStatus : ''}`}
name='ongoing'
onClick={toggleStatus}
onClick={() => setShowCurrent('open')}
>
모집중
</button>
{' | '}
<button
className={`${listStyles.agendaListStatus}
${showCurrent === 'current' ? listStyles.selectedStatus : ''}`}
name='closed'
onClick={() => setShowCurrent('current')}
>
진행중
</button>
{' | '}
<button
className={`${listStyles.agendaListStatus}
${showCurrent ? '' : listStyles.selectedStatus}`}
${showCurrent === 'history' ? listStyles.selectedStatus : ''}`}
name='closed'
onClick={toggleStatus}
onClick={() => setShowCurrent('history')}
>
종료된
</button>
</div>
</div>

{showCurrent ? (
<AgendaList agendaList={currentData || []} />
{showCurrent !== 'history' ? (
<AgendaList
agendaList={
showCurrent === 'open' ? openData || [] : currentData || []
}
/>
) : (
<>
<AgendaList agendaList={historyData || []} />
Expand Down
Loading

0 comments on commit 920b948

Please sign in to comment.