Skip to content

Commit

Permalink
chore: fix media upload
Browse files Browse the repository at this point in the history
  • Loading branch information
pantheredeye committed Dec 5, 2024
1 parent 57761a4 commit 6dbfc07
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions web/src/pages/NewInspectionPage/NewInspectionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const NewInspectionPage = () => {

Object.keys(data).forEach((key) => {
const match = key.match(/(.*)-(\d+)/)
if (match) {
if (match && !key.startsWith('media-description')) {
const fieldName = match[1]
const bmpId = parseInt(match[2], 10)
if (!bmpData[bmpId]) {
Expand All @@ -162,10 +162,17 @@ const NewInspectionPage = () => {
? parseFloat(cleanedData.approximatePrecipitation)
: null

data.media = media.map((item) => ({
url: item.url,
description: item.description,
}))
data.media = media.map((item, index) => {
const descriptionKey = `media-description-${index}`
const mediaItem = {
url: item.url,
description: data[descriptionKey] || '', // Attach description
}

delete cleanedData[descriptionKey]

return mediaItem
})

await createInspection({
variables: {
Expand Down

0 comments on commit 6dbfc07

Please sign in to comment.