Skip to content

Commit

Permalink
Fix sending content of attributes of content type date and datetime i…
Browse files Browse the repository at this point in the history
…n request payload from attribute editor (#786)
  • Loading branch information
AbbyB97 authored Aug 27, 2024
1 parent 268a3f2 commit 164efb8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/utils/attributes/attributes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,20 @@ export const getAttributeContent = (contentType: AttributeContentType, content:

const getAttributeFormValue = (contentType: AttributeContentType, item: any) => {
if (contentType === AttributeContentType.Datetime) {
const returnVal = item?.value?.data ? { data: new Date(item.value.data).toISOString() } : new Date(item).toISOString();
const returnVal = item?.value?.data
? { data: new Date(item.value.data).toISOString() }
: typeof item === 'string'
? { data: new Date(item).toISOString() }
: new Date(item).toISOString();
return returnVal;
}
if (contentType === AttributeContentType.Date) {
console.log('inside date =>item', item);
const returnVal = item?.value?.data
? { data: new Date(item.value.data).toISOString().slice(0, 10) }
: new Date(item).toISOString().slice(0, 10);
: typeof item === 'string'
? { data: new Date(item).toISOString().slice(0, 10) }
: new Date(item).toISOString().slice(0, 10);

return returnVal;
}
Expand Down

0 comments on commit 164efb8

Please sign in to comment.