Skip to content

Commit

Permalink
Merge pull request #573 from uoslife/feature/tf-academic-calendar-50
Browse files Browse the repository at this point in the history
[tf-academic-calendar-50] QA 수정사항 반영
  • Loading branch information
choidongjune authored Jul 8, 2024
2 parents 7d4b3e7 + d7731b8 commit 862cbf4
Show file tree
Hide file tree
Showing 3 changed files with 349 additions and 185 deletions.
15 changes: 13 additions & 2 deletions src/api/core/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,19 @@ export const put = async <T extends unknown>(
clientType: ClientType = 'DEFAULT',
): KyJsonResponse<T> => {
const client = changeClient(clientType);
const putRes = await client.put(url, {json: body});
return await putRes.json();
try {
return body
? await client.put(url, {json: body}).json()
: await client.put(url).json();
} catch (error) {
const errorJson = await (error as any).response.json();
const {message, status, code} = errorJson;

throw new CustomError(status, code, message);
}
// const putRes = await client.put(url, {json: body});
// console.log(putRes);
// return await putRes.json();
};

export const del = async <T extends unknown>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Checkbox from './Checkbox';
import {ScheduleTabEnum} from '../constants';
import {ISchedule} from '../api/academicCalendarAPI.type';
import customShowToast from '../../../../configs/toast';
import useModal from '../../../../hooks/useModal';

type ScheduleItemProps = {
schedule: ISchedule;
Expand All @@ -18,7 +19,7 @@ type ScheduleItemProps = {
bookmarkHandler?: (param: number, flag: boolean) => void;
notificationHandler?: (
param: number,
date: string,
startDate: string,
isNotification: boolean,
) => void;
delNotificationHandler?: (notificationId: number[]) => void;
Expand All @@ -38,6 +39,7 @@ const ScheduleItem = ({
const [checked, setChecked] = useState<boolean>(false);
const [isBookmarked, setIsBookmarked] = useState<boolean>(false);
const [isNotificated, setIsNotificated] = useState<boolean>(false);
const [isNotiInactive, setIsNotiInactive] = useState<boolean>(false);
const copyToClipboard = async () => {
Clipboard.setString(
`${schedule.title}\n${schedule.startDate}~${schedule.endDate}`,
Expand All @@ -60,8 +62,16 @@ const ScheduleItem = ({
if (schedule.setNotification === undefined) return;
setIsNotificated(schedule.setNotification);
}
const standardDateStr = schedule.endDate;
const formattedStandardDateStr = standardDateStr.split('.').join('-');
const standardDate = new Date(formattedStandardDateStr); // KST
const today = new Date();
const result = today.getTime() - standardDate.getTime();
if (result / 1000 / 60 / 60 >= 24) setIsNotiInactive(true);
}, [schedule, tabType]);

useEffect(() => {});

useEffect(() => {
if (isChecked) return;
setChecked(isChecked);
Expand Down Expand Up @@ -139,9 +149,17 @@ const ScheduleItem = ({
customShowToast('deleteNotification');
}}>
<S.Icon>
<S.Img source={require('../assets/notifications_on.png')} />
{isNotiInactive ? (
<S.Img
source={require('../assets/notifications_inactive.png')}
/>
) : (
<S.Img
source={require('../assets/notifications_on.png')}
/>
)}
<Txt
color="primaryBrand"
color={isNotiInactive ? 'grey90' : 'primaryBrand'}
typograph="labelMedium"
label="알림"
/>
Expand All @@ -153,20 +171,37 @@ const ScheduleItem = ({
onPress={() => {
if (!notificationHandler) return;
if (schedule.setNotification === undefined) return;
setIsNotificated(!isNotificated);
notificationHandler(
schedule.scheduleId,
schedule.startDate,
schedule.setNotification,
);
customShowToast('addNotification');

const standardDateStr = schedule.endDate;
const formattedStandardDateStr = standardDateStr
.split('.')
.join('-');
const standardDate = new Date(formattedStandardDateStr); // KST
const today = new Date();
const result = today.getTime() - standardDate.getTime();
if (result / 1000 / 60 / 60 >= 24) setIsNotificated(false);
else {
setIsNotificated(!isNotificated);
notificationHandler(
schedule.scheduleId,
schedule.startDate,
schedule.setNotification,
);
customShowToast('addNotification');
}
}}>
<S.Icon>
<S.Img
source={require('../assets/notifications_off.png')}
/>
{isNotiInactive ? (
<S.Img
source={require('../assets/notifications_inactive.png')}
/>
) : (
<S.Img
source={require('../assets/notifications_off.png')}
/>
)}
<Txt
color="primaryLight"
color={isNotiInactive ? 'grey90' : 'primaryLight'}
typograph="labelMedium"
label="알림"
/>
Expand Down Expand Up @@ -203,7 +238,6 @@ const S = {
border-radius: 16px;
border: 1px solid ${colors.grey40};
background: #fff;
성적열람제한해제수강지도기간(학업계획서,복학생상담)
${props => props.editable && `gap: 16px;`}
`,
Expand Down
Loading

0 comments on commit 862cbf4

Please sign in to comment.