From b87b5a4ecaa3b6a41c44fa4ea09b85f022d58192 Mon Sep 17 00:00:00 2001 From: Suyoung Jung Date: Thu, 20 Jul 2023 20:48:49 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20crypto.randomUUID=EB=A5=BC=20=EB=8C=80?= =?UTF-8?q?=EC=B2=B4=ED=95=98=EB=8A=94=20=EC=9C=A0=ED=8B=B8=ED=95=A8?= =?UTF-8?q?=EC=88=98=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/utils/generateScheduleBars.ts | 3 ++- frontend/src/utils/generateUuid.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 frontend/src/utils/generateUuid.ts diff --git a/frontend/src/utils/generateScheduleBars.ts b/frontend/src/utils/generateScheduleBars.ts index 709228b5c..2023bfc2a 100644 --- a/frontend/src/utils/generateScheduleBars.ts +++ b/frontend/src/utils/generateScheduleBars.ts @@ -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; @@ -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({ diff --git a/frontend/src/utils/generateUuid.ts b/frontend/src/utils/generateUuid.ts new file mode 100644 index 000000000..61861df87 --- /dev/null +++ b/frontend/src/utils/generateUuid.ts @@ -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); + }); +};