Skip to content

Commit

Permalink
refactor: simplify data check
Browse files Browse the repository at this point in the history
- put the data checks in a single `if (data)` block to greatly reduce system requirements with a single control

SUE-64
  • Loading branch information
d4v3d4vE authored and ardasnturk committed Jul 29, 2024
1 parent 34d9877 commit 3ea4752
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/queries/SUE/requests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down

0 comments on commit 3ea4752

Please sign in to comment.