Skip to content

Commit

Permalink
bugfix(service card): do not allow to erase (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
manojava-gk authored Aug 9, 2023
1 parent bbc465c commit c992cba
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions src/components/shared/basic/ReleaseProcess/OfferCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export default function OfferCard() {
alt: fetchServiceStatus?.leadPictureUri || '',
},
}
}, [fetchServiceStatus, imageData])
}, [fetchServiceStatus])

const {
handleSubmit,
Expand Down Expand Up @@ -234,16 +234,19 @@ export default function OfferCard() {
apiBody: CreateServiceStep1Item,
buttonLabel: string
) => {
const uploadImageValue = getValues().uploadImage
.leadPictureUri as unknown as DropzoneFile
const uploadImageValue =
getValues().uploadImage &&
(getValues().uploadImage.leadPictureUri as unknown as DropzoneFile)
await saveService({
id: serviceId,
body: apiBody,
})
.unwrap()
.then(() => {
!uploadImageValue.id &&
handleUploadDocument(serviceId, uploadImageValue)
if (uploadImageValue) {
!uploadImageValue.id &&
handleUploadDocument(serviceId, uploadImageValue)
}
dispatch(setServiceId(serviceId))
buttonLabel === ButtonLabelTypes.SAVE_AND_PROCEED &&
dispatch(serviceReleaseStepIncrement())
Expand All @@ -261,16 +264,20 @@ export default function OfferCard() {
apiBody: CreateServiceStep1Item,
buttonLabel: string
) => {
const uploadImageValue = getValues().uploadImage
.leadPictureUri as unknown as DropzoneFile
const uploadImageValue =
getValues().uploadImage &&
(getValues().uploadImage.leadPictureUri as unknown as DropzoneFile)
await createService({
id: '',
body: apiBody,
})
.unwrap()
.then((result) => {
if (isString(result)) {
!uploadImageValue.id && handleUploadDocument(result, uploadImageValue)
if (uploadImageValue) {
!uploadImageValue.id &&
handleUploadDocument(result, uploadImageValue)
}
dispatch(setServiceId(result))
buttonLabel === ButtonLabelTypes.SAVE_AND_PROCEED &&
dispatch(serviceReleaseStepIncrement())
Expand All @@ -293,10 +300,11 @@ export default function OfferCard() {
const apiBody = {
serviceTypeIds: data.serviceTypeIds,
title: data.title,
leadPictureUri:
data.uploadImage.leadPictureUri !== null &&
Object.keys(data.uploadImage.leadPictureUri).length > 0 &&
Object.values(data.uploadImage.leadPictureUri)[0],
leadPictureUri: data.uploadImage?.leadPictureUri
? data.uploadImage.leadPictureUri !== null &&
Object.keys(data.uploadImage.leadPictureUri).length > 0 &&
Object.values(data.uploadImage.leadPictureUri)[0]
: '',
descriptions: [
{
languageCode: 'de',
Expand Down

0 comments on commit c992cba

Please sign in to comment.