Fix DELETE sending empty JSON body, add repair_note to allowed file entity types
API client no longer sets Content-Type: application/json on requests without a body (fixes DELETE 400 errors). Added repair_note to the allowed entityTypes whitelist for file uploads so photos can be attached to repair notes.
This commit is contained in:
@@ -15,8 +15,10 @@ class ApiError extends Error {
|
|||||||
async function request<T>(method: string, path: string, body?: unknown): Promise<T> {
|
async function request<T>(method: string, path: string, body?: unknown): Promise<T> {
|
||||||
const { token } = useAuthStore.getState()
|
const { token } = useAuthStore.getState()
|
||||||
|
|
||||||
const headers: Record<string, string> = {
|
const headers: Record<string, string> = {}
|
||||||
'Content-Type': 'application/json',
|
|
||||||
|
if (body) {
|
||||||
|
headers['Content-Type'] = 'application/json'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token) {
|
if (token) {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export const fileRoutes: FastifyPluginAsync = async (app) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate entityType is a known type
|
// Validate entityType is a known type
|
||||||
const allowedEntityTypes = ['user', 'member', 'member_identifier', 'product', 'rental_agreement', 'repair_ticket']
|
const allowedEntityTypes = ['user', 'member', 'member_identifier', 'product', 'rental_agreement', 'repair_ticket', 'repair_note']
|
||||||
if (!allowedEntityTypes.includes(entityType)) {
|
if (!allowedEntityTypes.includes(entityType)) {
|
||||||
throw new ValidationError(`Invalid entityType: ${entityType}`)
|
throw new ValidationError(`Invalid entityType: ${entityType}`)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user