fix: Corregir errores de crypto.randomUUID, hydration y UI de impresoras
- Agregar fallback para crypto.randomUUID en useTemplates.ts (compatibilidad con navegadores antiguos) - Envolver sidebar con ClientOnly para evitar hydration mismatch - Agregar botón de configuración de impresoras en sidebar - Agregar drawer lateral para gestión de impresoras en desktop
This commit is contained in:
@@ -11,6 +11,19 @@ export interface PrintTemplate {
|
||||
|
||||
const STORAGE_KEY = 'printercentral-templates'
|
||||
|
||||
// Función para generar UUID compatible con todos los navegadores
|
||||
function generateId(): string {
|
||||
if (typeof crypto !== 'undefined' && crypto.randomUUID) {
|
||||
return crypto.randomUUID()
|
||||
}
|
||||
// Fallback para navegadores sin crypto.randomUUID
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
||||
const r = Math.random() * 16 | 0
|
||||
const v = c === 'x' ? r : (r & 0x3 | 0x8)
|
||||
return v.toString(16)
|
||||
})
|
||||
}
|
||||
|
||||
export function useTemplates() {
|
||||
const templates = useState<PrintTemplate[]>('templates', () => [])
|
||||
const initialized = useState('templatesInitialized', () => false)
|
||||
@@ -37,7 +50,7 @@ export function useTemplates() {
|
||||
|
||||
function saveTemplate(name: string, description: string, operations: Operation[]): PrintTemplate {
|
||||
const template: PrintTemplate = {
|
||||
id: crypto.randomUUID(),
|
||||
id: generateId(),
|
||||
name,
|
||||
description,
|
||||
operations: JSON.parse(JSON.stringify(operations)),
|
||||
|
||||
Reference in New Issue
Block a user