fix: replace random ID generation with generateUUID()
This commit is contained in:
@@ -4,7 +4,7 @@ import { useState, useCallback } from 'react';
|
|||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
import { X, Plus, Pencil, Trash2, ExternalLink, PanelRight } from 'lucide-react';
|
import { X, Plus, Pencil, Trash2, ExternalLink, PanelRight } from 'lucide-react';
|
||||||
import { icons as lucideIcons, type LucideIcon } from 'lucide-react';
|
import { icons as lucideIcons, type LucideIcon } from 'lucide-react';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn, generateUUID } from '@/lib/utils';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { IconPicker } from './icon-picker';
|
import { IconPicker } from './icon-picker';
|
||||||
@@ -207,7 +207,7 @@ export function SidebarAppsModal({ isOpen, onClose }: SidebarAppsModalProps) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleCreate = useCallback((data: SidebarAppFormData) => {
|
const handleCreate = useCallback((data: SidebarAppFormData) => {
|
||||||
const id = `app-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`;
|
const id = `app-${generateUUID()}`;
|
||||||
addSidebarApp({ id, ...data });
|
addSidebarApp({ id, ...data });
|
||||||
setIsCreating(false);
|
setIsCreating(false);
|
||||||
}, [addSidebarApp]);
|
}, [addSidebarApp]);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { IconPicker } from "@/components/layout/icon-picker";
|
|||||||
import { useSettingsStore, type SidebarApp } from "@/stores/settings-store";
|
import { useSettingsStore, type SidebarApp } from "@/stores/settings-store";
|
||||||
import { useConfirmDialog } from "@/hooks/use-confirm-dialog";
|
import { useConfirmDialog } from "@/hooks/use-confirm-dialog";
|
||||||
import { ConfirmDialog } from "@/components/ui/confirm-dialog";
|
import { ConfirmDialog } from "@/components/ui/confirm-dialog";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn, generateUUID } from "@/lib/utils";
|
||||||
|
|
||||||
interface SidebarAppFormData {
|
interface SidebarAppFormData {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -188,7 +188,7 @@ export function SidebarAppsSettings() {
|
|||||||
const draggedIndexRef = useRef<number | null>(null);
|
const draggedIndexRef = useRef<number | null>(null);
|
||||||
|
|
||||||
const handleAdd = useCallback((data: SidebarAppFormData) => {
|
const handleAdd = useCallback((data: SidebarAppFormData) => {
|
||||||
const id = `app-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`;
|
const id = `app-${generateUUID()}`;
|
||||||
addSidebarApp({ id, ...data });
|
addSidebarApp({ id, ...data });
|
||||||
setShowAddForm(false);
|
setShowAddForm(false);
|
||||||
}, [addSidebarApp]);
|
}, [addSidebarApp]);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export const useToastStore = create<ToastStore>((set) => ({
|
|||||||
toasts: [],
|
toasts: [],
|
||||||
|
|
||||||
addToast: (toast) => {
|
addToast: (toast) => {
|
||||||
const id = Math.random().toString(36).substring(2, 11);
|
const id = crypto.randomUUID();
|
||||||
const newToast: Toast = {
|
const newToast: Toast = {
|
||||||
...toast,
|
...toast,
|
||||||
id,
|
id,
|
||||||
|
|||||||
Reference in New Issue
Block a user