feat: rebuild admin account management and ticket assignment
This commit is contained in:
@@ -24,9 +24,17 @@ export async function createCustomerWithPortalAccess(payload) {
|
||||
return adminFetch('/api/admin/customers', { method: 'POST', body: payload })
|
||||
}
|
||||
|
||||
export async function listCustomersForAdmin() {
|
||||
return adminFetch('/api/admin/customers', { method: 'GET' })
|
||||
}
|
||||
|
||||
export async function updateCustomerWithPortalAccess(customerId, payload) {
|
||||
return adminFetch(`/api/admin/customers/${customerId}`, {
|
||||
method: 'PATCH',
|
||||
body: payload,
|
||||
})
|
||||
}
|
||||
|
||||
export async function deleteCustomerWithPortalAccess(customerId) {
|
||||
return adminFetch(`/api/admin/customers/${customerId}`, { method: 'DELETE' })
|
||||
}
|
||||
|
||||
40
src/lib/employeeAdminApi.js
Normal file
40
src/lib/employeeAdminApi.js
Normal file
@@ -0,0 +1,40 @@
|
||||
import { account } from './appwrite'
|
||||
|
||||
const PROJECT_ADMIN_URL =
|
||||
import.meta.env.VITE_PROJECT_ADMIN_URL || 'https://project.webklar.com'
|
||||
|
||||
async function adminFetch(path, { method = 'GET', body } = {}) {
|
||||
const jwt = await account.createJWT()
|
||||
const response = await fetch(`${PROJECT_ADMIN_URL}${path}`, {
|
||||
method,
|
||||
headers: {
|
||||
Authorization: `Bearer ${jwt.jwt}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: body ? JSON.stringify(body) : undefined,
|
||||
})
|
||||
const data = await response.json().catch(() => ({}))
|
||||
if (!response.ok) {
|
||||
throw new Error(data.error || `API-Fehler ${response.status}`)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
export function listEmployeesForAdmin() {
|
||||
return adminFetch('/api/admin/employees')
|
||||
}
|
||||
|
||||
export function createEmployeeWithLogin(payload) {
|
||||
return adminFetch('/api/admin/employees', { method: 'POST', body: payload })
|
||||
}
|
||||
|
||||
export function updateEmployeeWithLogin(employeeId, payload) {
|
||||
return adminFetch(`/api/admin/employees/${employeeId}`, {
|
||||
method: 'PATCH',
|
||||
body: payload,
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteEmployeeWithLogin(employeeId) {
|
||||
return adminFetch(`/api/admin/employees/${employeeId}`, { method: 'DELETE' })
|
||||
}
|
||||
Reference in New Issue
Block a user