Skip to content

Commit

Permalink
chore: 기록 시도 시 하루가 넘어갈 때만 체크
Browse files Browse the repository at this point in the history
  • Loading branch information
wokbjso committed Sep 13, 2024
1 parent 579b32a commit f81888c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion features/record/components/organisms/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { useRecordForm } from '../../hooks';
import { saveSwimTime } from '../../server-actions';
import { formSubInfoState } from '../../store/form-sub-info';
import { formSectionStyles } from '../../styles/form-section';
import { isFuture } from '../../utils';
import { compareTime, isFuture } from '../../utils';
import { DiarySection } from './diary-section';
import { DistancePageModal } from './distance-page-modal';
import { EquipmentSection } from './equipment-section';
Expand Down Expand Up @@ -184,6 +184,11 @@ export function Form({ prevSwimStartTime, prevSwimEndTime }: FormProps) {
const onSubmit: SubmitHandler<RecordRequestProps> = async (data) => {
if (isLoading || !startTime || !endTime) return;

//하루가 넘어갈 때
if (!compareTime(startTime, endTime)) {
toast('시간을 해당 기록 날짜 내로 설정해주세요', { type: 'warning' });
return;
}
//기록 수정 모드일 때
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { poolName, laneMeter, totalDistance, ...restData } = data;
Expand Down
4 changes: 2 additions & 2 deletions features/record/components/organisms/time-bottom-sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ export function TimeBottomSheet({ startTime, endTime }: TimeBottomSheetProps) {
// 시작 시간이 아직 설정 안됨 or 시작 시간이 종료 시간보다 이후일 경우
if (
!getValues('startTime') ||
getValues('startTime') > getValues('endTime')
getValues('startTime') >= getValues('endTime')
)
setValue('startTime', subtractMinutes(pickerValue, 50));
};

const autoSetEndTime = () => {
// 끝 시간이 아직 설정 안됨 or 시작 시간이 종료 시간보다 이후일 경우
if (!getValues('endTime') || getValues('startTime') > getValues('endTime'))
if (!getValues('endTime') || getValues('startTime') >= getValues('endTime'))
setValue('endTime', addMinutes(pickerValue, 50));
};

Expand Down

0 comments on commit f81888c

Please sign in to comment.