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 { useState, useCallback } from 'react'
|
||||||
import { databases, DATABASE_ID, COLLECTIONS, Query } from '../lib/appwrite'
|
import { databases, DATABASE_ID, COLLECTIONS, Query } from '../lib/appwrite'
|
||||||
|
import { assignWebsiteProject } from '../lib/projectAdminApi'
|
||||||
|
import { assignSequentially } from '../lib/projectAssign'
|
||||||
|
|
||||||
export function useWebsiteProjects() {
|
export function useWebsiteProjects() {
|
||||||
const [projects, setProjects] = useState([])
|
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 assignProjects = async (projectIds, ctx) => {
|
||||||
const results = await Promise.all(projectIds.map((id) => assignProject(id, ctx)))
|
const results = await assignSequentially(projectIds, ctx, assignWebsiteProject)
|
||||||
return results.find((r) => !r.success) || { success: true }
|
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
|
// Nur vom Ticket loesen: customerId bleibt, sonst verliert der Kunde die Vorschau im Portal
|
||||||
|
|||||||
@@ -29,6 +29,21 @@ export async function syncGiteaRepos() {
|
|||||||
return adminFetch('/api/admin/gitea/sync-repos', { method: 'POST' })
|
return adminFetch('/api/admin/gitea/sync-repos', { method: 'POST' })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function importNewRepos() {
|
||||||
|
return adminFetch('/api/admin/gitea/import-repos', { method: 'POST' })
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function assignWebsiteProject(id, { customerId, ticketId }) {
|
||||||
|
return adminFetch(`/api/admin/website-projects/${id}/assign`, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({ customerId, ticketId }),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function backfillProjectPushes(id) {
|
||||||
|
return adminFetch(`/api/admin/website-projects/${id}/pushes`, { method: 'POST' })
|
||||||
|
}
|
||||||
|
|
||||||
export async function updateWebsiteProject(id, payload) {
|
export async function updateWebsiteProject(id, payload) {
|
||||||
return adminFetch(`/api/admin/website-projects/${id}`, {
|
return adminFetch(`/api/admin/website-projects/${id}`, {
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
|
|||||||
Reference in new issue
Block a user