Skip to content

Commit

Permalink
fix: redirect user to list when a secret is created (#1587)
Browse files Browse the repository at this point in the history
  • Loading branch information
aloisio-m-bastian authored Aug 6, 2024
1 parent d8f7088 commit a7fbe18
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/services/variables-services/create-variables-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,25 @@ export const createVariablesService = async (payload) => {
body: payload
})

return parseHttpResponse(httpResponse)
return parseHttpResponse(httpResponse, payload)
}

/**
* @param {Object} httpResponse - The HTTP response object.
* @param {Object} payload - The request sent payload.
* @param {Object} httpResponse.body - The response body.
* @param {String} httpResponse.statusCode - The HTTP status code.
* @returns {string} The result message based on the status code.
* @throws {Error} If there is an error with the response.
*/
const parseHttpResponse = (httpResponse) => {
const parseHttpResponse = (httpResponse, payload) => {
switch (httpResponse.statusCode) {
case 201:
const editUrl = `/variables/edit/${httpResponse.body.uuid}`
const listUrl = '/variables'
return {
feedback: 'Your variable has been created',
urlToEditView: `/variables/edit/${httpResponse.body.uuid}`
urlToEditView: payload.secret ? listUrl : editUrl
}
case 400:
const apiError = extractApiError(httpResponse)
Expand Down

0 comments on commit a7fbe18

Please sign in to comment.