npm run build

This commit is contained in:
Leon Serfaty G
2025-07-19 15:10:27 +00:00
parent caff416826
commit f5e94bf039
3 changed files with 118 additions and 7 deletions
+14
View File
@@ -67,6 +67,16 @@ export async function saveFlow(prevState: State, formData: FormData): Promise<St
try {
if (id) {
// Check if path is unique before updating
const checkStmt = db.prepare('SELECT id FROM flows WHERE path = ? AND id != ?');
const existing = checkStmt.get(path, id);
if (existing) {
return {
success: false,
message: 'A flow with this path already exists.',
errors: [{ path: ['path'], message: 'A flow with this path already exists.', code: 'custom' }],
};
}
// Update existing flow
const stmt = db.prepare(
'UPDATE flows SET name = ?, description = ?, path = ?, updatedAt = CURRENT_TIMESTAMP WHERE id = ?'
@@ -101,6 +111,10 @@ export async function saveFlow(prevState: State, formData: FormData): Promise<St
export async function deleteFlow(id: number): Promise<{ success: boolean, message: string }> {
try {
// Prevent deletion of the default flow (ID 1)
if (id === 1) {
return { success: false, message: "The default flow cannot be deleted." };
}
const stmt = db.prepare('DELETE FROM flows WHERE id = ?');
stmt.run(id);
revalidatePath('/admin/flows');