Skip to content

Commit

Permalink
Merge pull request #1558 from 42organization/agenda
Browse files Browse the repository at this point in the history
[test-deploy] ui bug fix 및 기타 등등
  • Loading branch information
cweedlee authored Sep 7, 2024
2 parents 7e32062 + 71a0e45 commit 3b42838
Show file tree
Hide file tree
Showing 39 changed files with 382 additions and 128 deletions.
4 changes: 0 additions & 4 deletions components/admin/takgu/party/PartyTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ export default function PartyTemplate() {
const setModal = useSetRecoilState(modalState);
const [selectedCategory, setSelectedCategory] = useState('all');

useEffect(() => {
console.log('Render');
}, [templates]);

const handleEditTemplate = (template?: PartyGameTemplate) => {
setModal({ modalName: 'ADMIN-PARTY_TEMPLATE', template });
};
Expand Down
17 changes: 11 additions & 6 deletions components/agenda/Form/AgendaForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const AgendaForm = ({
const { openModal } = useModal();
const setSnackBar = useSetRecoilState(toastState);
const router = useRouter();
const minDistance = 10;
const minDistance = 1;
// 날짜 초기화
const today = new Date();
const tommorrow = new Date(); // 기준값으로 사용
Expand Down Expand Up @@ -66,6 +66,7 @@ const AgendaForm = ({
isEdit ? data.agendaMaxPeople === 1 : false
);

// team limit
const handleChange = (
event: Event,
newValue: number | number[],
Expand All @@ -80,13 +81,15 @@ const AgendaForm = ({
setTeamLimit([clamped, clamped + minDistance]);
} else {
const clamped = Math.max(newValue[1], minDistance);
if (clamped - minDistance < newValue[0]) setTeamLimit([2, 12]);
if (clamped - minDistance < newValue[0]) setTeamLimit([2, 10]);
else setTeamLimit([clamped - minDistance, clamped]);
}
} else {
setTeamLimit(newValue as number[]);
}
};

// people limit
const handleChangePeople = (
event: Event,
newValue: number | number[],
Expand All @@ -97,10 +100,11 @@ const AgendaForm = ({
}
setPeopleLimit(newValue as number[]);
};

const handleRecruitEnd = (e: React.ChangeEvent<HTMLInputElement>) => {
if (!e.target.value) return;
const newEnd = new Date(e.target.value);
console.log(newEnd);

checkWarn(newEnd, 0);
setRecruitEnd(new Date(e.target.value));
};
Expand All @@ -125,13 +129,14 @@ const AgendaForm = ({
function checkWarn(newDate: Date, index: number) {
const newWarning = [...dateWarn];
const DateValues = [recruitEnd, dateRange[0], dateRange[1]];

DateValues[index] = newDate;
tommorrow.setHours(0);
tommorrow.setMinutes(0);
tommorrow.setSeconds(0);
tommorrow.setMilliseconds(0);
// 모집마감일 오류
if (DateValues[0].getTime() < tommorrow.getTime()) {
if (!isAdmin && DateValues[0].getTime() < tommorrow.getTime()) {
newWarning[0] = '내일 이후의 날짜를 선택해주세요';
} else if (
DateValues[0].getTime() > DateValues[1].getTime() ||
Expand All @@ -142,7 +147,7 @@ const AgendaForm = ({
newWarning[0] = '';
}
// 대회 기간 시작일 오류
if (DateValues[1].getTime() < tommorrow.getTime()) {
if (!isAdmin && DateValues[1].getTime() < tommorrow.getTime()) {
newWarning[1] = '내일 이후의 날짜를 선택해주세요';
} else if (DateValues[1].getTime() > DateValues[2].getTime()) {
newWarning[1] = '종료일보다 시작일이 뒤에 있습니다.';
Expand All @@ -152,7 +157,7 @@ const AgendaForm = ({
newWarning[1] = '';
}
// 대회 기간 종료일 오류
if (DateValues[2].getTime() < tommorrow.getTime()) {
if (!isAdmin && DateValues[2].getTime() < tommorrow.getTime()) {
newWarning[2] = '내일 이후의 날짜를 선택해주세요.';
} else if (DateValues[2].getTime() < DateValues[1].getTime()) {
newWarning[2] = '시작일보다 이전 날짜입니다.';
Expand Down
3 changes: 0 additions & 3 deletions components/agenda/Form/SubmitAgendaForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ function agendadataToMsg(data: FormData, isEdit: boolean) {
let msg = '';
msg += '행사 제목 : ' + data.get('agendaTitle') + '\n';
msg += '타입: ';
console.log(msg);
msg += data.get('agendaIsRanking') === 'true' ? '대회\n' : '행사\n';
msg += '행사 내용 : ' + data.get('agendaContent') + '\n';
msg +=
Expand All @@ -29,7 +28,6 @@ function agendadataToMsg(data: FormData, isEdit: boolean) {
' ~ ' +
data.get('agendaMaxPeople') +
'\n';
console.log(msg);
msg += '개최지 : ' + data.get('agendaLocation') + '\n';
msg += '포스터 : ';
msg +=
Expand Down Expand Up @@ -147,7 +145,6 @@ const SubmitAgendaForm = async (
if (res.status === 204 || res.status === 200)
onProceed && onProceed();
if (!isEdit) {
console.log(res.data.agendaKey);
router.push(`/agenda/detail?agenda_key=${res.data.agendaKey}`);
}
})
Expand Down
11 changes: 9 additions & 2 deletions components/agenda/Form/TicketForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { useState } from 'react';
import { useSetRecoilState } from 'recoil';
import { toastState } from 'utils/recoil/toast';
import AgendaSelect from 'components/agenda/Input/AgendaSelect';
import { useModal } from 'components/agenda/modal/useModal';
import useFetchGet from 'hooks/agenda/useFetchGet';
Expand All @@ -18,6 +20,7 @@ const TicketForm = ({ stringKey }: userFormProps) => {
const handleSelectChange = (e: { target: { value: any } }) => {
setSelectedAgendaKey(e.target.value);
};
const setSnackbar = useSetRecoilState(toastState);

const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
Expand All @@ -30,7 +33,6 @@ const TicketForm = ({ stringKey }: userFormProps) => {

jsonData.issuedFromKey = selectedAgendaKey;

console.log('data', jsonData);
sendRequest(
'POST',
'admin/ticket',
Expand All @@ -40,7 +42,12 @@ const TicketForm = ({ stringKey }: userFormProps) => {
closeModal();
},
(error: string) => {
console.error(error);
setSnackbar({
toastName: `response error`,
severity: 'error',
message: `🔥 ${error} 🔥`,
clicked: true,
});
}
);
};
Expand Down
58 changes: 44 additions & 14 deletions components/agenda/Home/AgendaDeadLine.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,60 @@
import React from 'react';
import { AgendaStatus } from 'constants/agenda/agenda';
import styles from 'styles/agenda/Home/AgendaDeadLine.module.scss';

interface deadLineProps {
deadLine: string | Date;
status: AgendaStatus;
start?: string | Date;
end?: string | Date;
}

const AgendaDeadLine = ({ deadLine }: deadLineProps) => {
const AgendaDeadLine = ({ deadLine, status, start, end }: deadLineProps) => {
const currentDate = new Date();
const deadLineDate = new Date(deadLine);
const startDate = new Date(start || '');
const endDate = new Date(end || '');

const timeDiff = deadLineDate.getTime() - currentDate.getTime();
let daysLeft;
let daysLeft: number | string = 'DAY';

if (timeDiff == 0) daysLeft = 'Day';
else if (timeDiff > 0) daysLeft = Math.ceil(timeDiff / (1000 * 60 * 60 * 24));
if (timeDiff > 0) daysLeft = Math.ceil(timeDiff / (1000 * 60 * 60 * 24));

if (timeDiff >= 0) {
return (
<div className={styles.agendaItemDeadLineBox}>
<div className={styles.agendaDeadLineText}>모집마감</div>
<div className={styles.agendaDeadLine}>D-{daysLeft}</div>
</div>
);
}
// 컨펌인 상태 구분
let curr;
if (!start || !end) curr = 'error';
else if (currentDate >= startDate && currentDate <= endDate) curr = '진행중';
else if (currentDate < startDate) curr = '진행예정';
else curr = '진행완료';

return null;
switch (status) {
case 'FINISH':
return (
<div className={`${styles.agendaItemDeadLineBox} ${styles.finished}`}>
<div className={styles.agendaDeadLineText}>종료</div>
</div>
);
case 'CONFIRM':
return (
<div className={`${styles.agendaItemDeadLineBox} ${styles.confirm}`}>
<div className={styles.agendaDeadLineText}>{curr}</div>
</div>
);
case 'CANCEL':
return (
<div className={`${styles.agendaItemDeadLineBox} ${styles.cancel}`}>
<div className={styles.agendaDeadLineText}>취소</div>
</div>
);
default:
if (timeDiff >= 0) {
return (
<div className={styles.agendaItemDeadLineBox}>
<div className={styles.agendaDeadLineText}>모집마감</div>
<div className={styles.agendaDeadLine}>D-{daysLeft}</div>
</div>
);
} else return null;
}
};

export default AgendaDeadLine;
24 changes: 22 additions & 2 deletions components/agenda/Home/AgendaList.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { useRouter } from 'next/router';
import React, { useState } from 'react';
import { AgendaDataProps } from 'types/agenda/agendaDetail/agendaTypes';
import { AgendaStatus } from 'constants/agenda/agenda';
import AgendaDeadLine from 'components/agenda/Home/AgendaDeadLine';
import AgendaInfo from 'components/agenda/Home/AgendaInfo';
import styles from 'styles/agenda/Home/AgendaList.module.scss';

const AgendaList = ({ agendaList }: { agendaList: AgendaDataProps[] }) => {
const AgendaList = ({
agendaList,
status,
}: {
agendaList: AgendaDataProps[];
status: AgendaStatus;
}) => {
const [selectedItem, setSelectedItem] = useState<number | null>(0);

return (
Expand All @@ -18,6 +25,7 @@ const AgendaList = ({ agendaList }: { agendaList: AgendaDataProps[] }) => {
<div className={styles.agendaListItemContainer}>
{agendaList.map((agendaInfo, idx) => {
agendaInfo.idx = idx;
agendaInfo.agendaStatus = status;
return (
<AgendaListItem
agendaInfo={agendaInfo}
Expand Down Expand Up @@ -87,7 +95,19 @@ const AgendaListItem = ({
>
<AgendaInfo agendaInfo={agendaInfo} idx={idx} />
<div className={`${type === 'list' && styles.show}`}>
<AgendaDeadLine deadLine={agendaInfo.agendaDeadLine} />
{agendaInfo.agendaStatus === 'CONFIRM' ? (
<AgendaDeadLine
deadLine={agendaInfo.agendaDeadLine}
status={agendaInfo.agendaStatus}
start={agendaInfo.agendaStartTime}
end={agendaInfo.agendaEndTime}
/>
) : (
<AgendaDeadLine
deadLine={agendaInfo.agendaDeadLine}
status={agendaInfo.agendaStatus}
/>
)}
</div>
</button>
);
Expand Down
2 changes: 1 addition & 1 deletion components/agenda/Layout/MenuBarContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const MenuBarContent = ({
useContext<HeaderContextState | null>(HeaderContext)
?.resetOpenMenuBarState ||
function () {
console.log('resetOpenMenuBarState is not defined');
console.log('resetOpenMenuBarState is not defined'); //error
};

return (
Expand Down
11 changes: 0 additions & 11 deletions components/agenda/agendaDetail/AgendaInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,9 @@ export default function AgendaInfo({
{ agenda_key: agendaKey, teamKey: newTeamKey },
() => {
window.location.reload();
},
(err) => {
console.log('개인 확정에 실패했습니다.', err);
}
);
} else {
console.log('개인 팀키를 찾지 못했습니다.');
}
},
(err) => {
console.log('개인 참여에 실패했습니다.', err);
}
);
};
Expand All @@ -94,9 +86,6 @@ export default function AgendaInfo({
},
() => {
window.location.reload();
},
(err) => {
console.log('등록취소에 실패했습니다.', err);
}
);
};
Expand Down
4 changes: 1 addition & 3 deletions components/agenda/agendaDetail/TabContent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { TabContentProps } from 'types/agenda/button/tabButtonTypes';
import AgendaAnnouncements from 'components/agenda/agendaDetail/tabs/AgendaAnnouncements';
import AgendaConditions from 'components/agenda/agendaDetail/tabs/AgendaConditions';
import AgendaDescription from 'components/agenda/agendaDetail/tabs/AgendaDescription';
import AgendaParticipants from 'components/agenda/agendaDetail/tabs/AgendaParticipants';
import AgendaPoster from 'components/agenda/agendaDetail/tabs/AgendaPoster';
Expand All @@ -27,8 +26,7 @@ export default function TabContent({
return <AgendaParticipants agendaData={agendaData} myTeam={myTeam} />;
case tabs.NOTIFICATIONS:
return <AgendaAnnouncements />;
case tabs.CONDITIONS:
return <AgendaConditions agendaData={agendaData} />;

case tabs.POSTER:
return (
<div className={styles.flex}>
Expand Down
7 changes: 5 additions & 2 deletions components/agenda/agendaDetail/tabs/AgendaAnnouncements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ export default function AgendaAnnouncements() {
});

if (!agendaKey || !content) {
return <AgendaLoading />;
return (
<div className={styles.emptyContainer}>
<AgendaLoading />
</div>
);
}

return (
<>
{content && content.length > 0 ? (
Expand Down
Loading

0 comments on commit 3b42838

Please sign in to comment.