Skip to content

Commit

Permalink
[CLD-673] disable categoryID in revision submit (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
zlatanpham authored Jan 6, 2020
1 parent 3530ea5 commit b41cf7f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/sagas/__stubs__/revision-submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CreateAppRevisionModel } from '@reapit/foundations-ts-definitions'

export const revisionSubmitStub: { data: CreateAppRevisionModel } = {
data: {
categoryId: '',
description: 'Lorem ipsum',
homePage: 'https://reapit.com',
iconImageUrl: 'https://some-s3-image-url.com',
Expand Down
2 changes: 1 addition & 1 deletion src/sagas/__tests__/submit-revision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('submit-revision post data', () => {
url: `${URLS.apps}/${id}/revisions`,
api: process.env.MARKETPLACE_API_BASE_URL as string,
method: 'POST',
body: updatedData,
body: { ...updatedData, categoryId: undefined },
headers: MARKETPLACE_HEADERS
})
)
Expand Down
4 changes: 2 additions & 2 deletions src/sagas/submit-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const submitApp = function*({ data }: Action<SubmitAppArgs>) {
screen4ImageUrl: imageUploaderResults[4] ? imageUploaderResults[4].Url : ''
}

const stripOutCategoryIfNotChose = {
const updatedValuesAfterValidatingCategoryId = {
...updatedValues,
categoryId: categoryId === '' ? undefined : categoryId
}
Expand All @@ -79,7 +79,7 @@ export const submitApp = function*({ data }: Action<SubmitAppArgs>) {
url: URLS.apps,
api: process.env.MARKETPLACE_API_BASE_URL as string,
method: 'POST',
body: stripOutCategoryIfNotChose,
body: updatedValuesAfterValidatingCategoryId,
headers: MARKETPLACE_HEADERS
})

Expand Down
19 changes: 17 additions & 2 deletions src/sagas/submit-revision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@ export const submitRevision = function*({ data }: Action<CreateAppRevisionModel
// TODO: for this situation we need check the value of imageData
// upload and also update into imageUrl as new property from backend
try {
const { id, name, iconImageUrl, screen1ImageUrl, screen2ImageUrl, screen3ImageUrl, screen4ImageUrl, ...body } = data
const {
id,
name,
iconImageUrl,
screen1ImageUrl,
screen2ImageUrl,
screen3ImageUrl,
screen4ImageUrl,
categoryId,
...body
} = data

const formatedName = name ? name.replace(/\s+/g, '-') : ''
const imageUploaderReqs = [
Expand All @@ -38,11 +48,16 @@ export const submitRevision = function*({ data }: Action<CreateAppRevisionModel
name
}

const updatedValuesAfterValidatingCategoryId = {
...updatedValues,
categoryId: categoryId === '' ? undefined : categoryId
}

const regResponse: true | undefined = yield call(fetcher, {
url: `${URLS.apps}/${id}/revisions`,
api: process.env.MARKETPLACE_API_BASE_URL as string,
method: 'POST',
body: updatedValues,
body: updatedValuesAfterValidatingCategoryId,
headers: MARKETPLACE_HEADERS
})

Expand Down

0 comments on commit b41cf7f

Please sign in to comment.