From 3ea4752d2ff6b3d65456b2a802e62c7e4f91e0e3 Mon Sep 17 00:00:00 2001 From: d4v3d4vE Date: Mon, 29 Jul 2024 10:22:20 +0200 Subject: [PATCH] refactor: simplify data check - put the data checks in a single `if (data)` block to greatly reduce system requirements with a single control SUE-64 --- src/queries/SUE/requests.tsx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/queries/SUE/requests.tsx b/src/queries/SUE/requests.tsx index 835fb9718..0d9858d91 100644 --- a/src/queries/SUE/requests.tsx +++ b/src/queries/SUE/requests.tsx @@ -31,16 +31,18 @@ export const postRequests = async (data: any) => { const { apiKey = '', suePostRequest = '' } = await fetchSueEndpoints(); const formData = new FormData(); - data?.addressString && formData.append('address_string', data.addressString); - data?.description && formData.append('description', data.description); - data?.email && formData.append('email', data.email); - data?.firstName && formData.append('first_name', data.firstName); - data?.lastName && formData.append('last_name', data.lastName); - data?.lat && formData.append('lat', data.lat); - data?.long && formData.append('long', data.long); - data?.phone && formData.append('phone', data.phone); - data?.serviceCode && formData.append('service_code', data.serviceCode); - data?.title && formData.append('title', data.title); + if (data) { + formData.append('address_string', data.addressString); + formData.append('description', data.description); + formData.append('email', data.email); + formData.append('first_name', data.firstName); + formData.append('last_name', data.lastName); + formData.append('lat', data.lat); + formData.append('long', data.long); + formData.append('phone', data.phone); + formData.append('service_code', data.serviceCode); + formData.append('title', data.title); + } const images = JSON.parse(data?.images) || []; for (let i = 0; i < images.length; i++) {