Zuweisen über das Portal, Import neuer Repos, Pushes nachtragen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cc59e7978e
commit
56489b8d6d
2 files changed
+21
-15
No files matched your search
@@ -1,5 +1,7 @@
|
||||
import { useState, useCallback } from 'react'
|
||||
import { databases, DATABASE_ID, COLLECTIONS, Query } from '../lib/appwrite'
|
||||
import { assignWebsiteProject } from '../lib/projectAdminApi'
|
||||
import { assignSequentially } from '../lib/projectAssign'
|
||||
|
||||
export function useWebsiteProjects() {
|
||||
const [projects, setProjects] = useState([])
|
||||
@@ -37,22 +39,11 @@ export function useWebsiteProjects() {
|
||||
}
|
||||
}, [])
|
||||
|
||||
const assignProject = async (projectId, { customerId, ticketId }) => {
|
||||
try {
|
||||
const response = await databases.updateDocument(
|
||||
DATABASE_ID, COLLECTIONS.WEBSITE_PROJECTS, projectId,
|
||||
{ customerId, ticketId, updatedAt: new Date().toISOString() }
|
||||
)
|
||||
setProjects((prev) => prev.map((p) => (p.$id === projectId ? response : p)))
|
||||
return { success: true }
|
||||
} catch (err) {
|
||||
return { success: false, error: err.message }
|
||||
}
|
||||
}
|
||||
|
||||
const assignProjects = async (projectIds, ctx) => {
|
||||
const results = await Promise.all(projectIds.map((id) => assignProject(id, ctx)))
|
||||
return results.find((r) => !r.success) || { success: true }
|
||||
const results = await assignSequentially(projectIds, ctx, assignWebsiteProject)
|
||||
const success = results.every((r) => r.ok)
|
||||
const firstError = results.find((r) => !r.ok)
|
||||
return { success, error: firstError?.error, results }
|
||||
}
|
||||
|
||||
// Nur vom Ticket loesen: customerId bleibt, sonst verliert der Kunde die Vorschau im Portal
|
||||
|
||||
Reference in new issue
Block a user