Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add changes to draft * Make domain type and schema match * Deleting change from changeset * Add ability to merge * Revert "Add ability to merge" This reverts commit 504e7e7. * gRevert "Deleting change from changeset" This reverts commit 2effc20. * Revert "Make domain type and schema match" This reverts commit 079f46c. Co-authored-by: sjaanus <sellinjaanus@gmail.com>
- Loading branch information
Showing
6 changed files
with
98 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
frontend/src/hooks/api/actions/useSuggestChangeApi/useSuggestChangeApi.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import useAPI from '../useApi/useApi'; | ||
|
||
interface ISuggestChangeSchema { | ||
feature: string; | ||
action: | ||
| 'updateEnabled' | ||
| 'strategyAdd' | ||
| 'strategyUpdate' | ||
| 'strategyDelete'; | ||
payload: string | boolean | object | number; | ||
} | ||
|
||
export const useSuggestChangeApi = (project: string) => { | ||
const { makeRequest, createRequest, errors, loading } = useAPI({ | ||
propagateErrors: true, | ||
}); | ||
|
||
const addSuggestion = async ( | ||
environment: string, | ||
payload: ISuggestChangeSchema | ||
) => { | ||
const path = `api/admin/projects/${project}/environments/${environment}/suggest-changes`; | ||
const req = createRequest(path, { | ||
method: 'POST', | ||
body: JSON.stringify(payload), | ||
}); | ||
try { | ||
const response = await makeRequest(req.caller, req.id); | ||
return await response.json(); | ||
} catch (e) { | ||
throw e; | ||
} | ||
}; | ||
|
||
return { | ||
addSuggestion, | ||
errors, | ||
loading, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters