Corrección 1 — Delete de proceso restaurado + Corrección 2 — Patrón userId en repos

This commit is contained in:
2026-05-28 01:13:28 -03:00
parent 1bc80e190f
commit 0a3c60cd09
26 changed files with 1650 additions and 25844 deletions

View File

@@ -14,12 +14,12 @@ interface LibraryState {
load: () => Promise<void>
createGroup: (name: string) => Promise<ProcessGroup>
createGroup: (name: string, userId: string) => Promise<ProcessGroup>
deleteGroup: (id: string) => Promise<void>
deleteProcess: (id: string) => Promise<void>
assignProcessToGroup: (processId: string, groupId: string | null) => Promise<void>
assignProcessToGroup: (processId: string, groupId: string | null, userId: string) => Promise<void>
getProcessesByGroup: (groupId: string | null) => Process[]
getLatestSimulation: (processId: string) => Promise<Simulation | undefined>
@@ -51,15 +51,15 @@ export const useLibraryStore = create<LibraryState>((set, get) => ({
}
},
createGroup: async (name: string) => {
createGroup: async (name, userId) => {
const now = Date.now()
const group: ProcessGroup = { id: uuidv4(), name, createdAt: now, updatedAt: now }
await supabaseGroupRepo.save(group)
await supabaseGroupRepo.save(group, userId)
set((state) => ({ groups: [...state.groups, group].sort((a, b) => a.name.localeCompare(b.name)) }))
return group
},
deleteGroup: async (id: string) => {
deleteGroup: async (id) => {
await supabaseGroupRepo.delete(id)
set((state) => ({
groups: state.groups.filter((g) => g.id !== id),
@@ -67,29 +67,29 @@ export const useLibraryStore = create<LibraryState>((set, get) => ({
}))
},
deleteProcess: async (id: string) => {
deleteProcess: async (id) => {
await supabaseProcessRepo.delete(id)
set((state) => ({ processes: state.processes.filter((p) => p.id !== id) }))
},
assignProcessToGroup: async (processId: string, groupId: string | null) => {
assignProcessToGroup: async (processId, groupId, userId) => {
const process = get().processes.find((p) => p.id === processId)
if (!process) return
const updated = { ...process, groupId, updatedAt: Date.now() }
await supabaseProcessRepo.save(updated)
await supabaseProcessRepo.save(updated, userId)
set((state) => ({
processes: state.processes.map((p) => p.id === processId ? updated : p),
}))
},
getProcessesByGroup: (groupId: string | null) => {
getProcessesByGroup: (groupId) => {
const processes = get().processes
return groupId === null
? processes.filter((p) => p.groupId == null)
: processes.filter((p) => p.groupId === groupId)
},
getLatestSimulation: (processId: string) => {
getLatestSimulation: (processId) => {
return simulationRepo.getLatestByProcess(processId)
},