Skip to content

Commit

Permalink
[FE] crypto.randomUUID를 대체하는 유틸함수 작성 (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
suyoungj authored Jul 20, 2023
1 parent 5e3ab34 commit 5d7c675
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion frontend/src/utils/generateScheduleBars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { ScheduleBarProps } from '~/components/ScheduleBar/ScheduleBar';
import { CALENDAR, ONE_DAY } from '~/constants/calendar';
import type { Position, Schedule } from '~/types/schedule';
import { parseDate } from '~/utils/parseDate';
import { generateUuid } from '~/utils/generateUuid';

type CalendarObject = Record<string, Position>;

Expand Down Expand Up @@ -103,7 +104,7 @@ const generateRawScheduleBars = (

if (startDate <= endDate) {
const duration = calcDuration(startDate, endDate);
const id = crypto.randomUUID();
const id = generateUuid();
const { row, column } = calendarObject[formatDate(startDate)];

rawScheduleBars.push({
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/utils/generateUuid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const generateUuid = () => {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const r = (Math.random() * 16) | 0,
v = c == 'x' ? r : (r & 0x3) | 0x8;

return v.toString(16);
});
};

0 comments on commit 5d7c675

Please sign in to comment.