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:
Ryan Moon
2026-03-29 11:23:21 -05:00
parent e224b535ce
commit ba94adb8d7
2 changed files with 5 additions and 3 deletions

View File

@@ -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) {

View File

@@ -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}`)
} }