feat(schema-workflow): PATCH /drafts/{id} — edit без recreate (A)
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
type SchemaDraft,
|
||||
type SubmitDraftRequest,
|
||||
type SubmitForReviewRequest,
|
||||
type UpdateSchemaDraftRequest,
|
||||
type WebhookDelivery,
|
||||
type WebhookSubscription,
|
||||
type WebhookTestPingResult,
|
||||
@@ -514,6 +515,35 @@ export const useCreateSchemaDraft = (dictionaryName: string) => {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Update content (proposedSchema / reason) в существующем draft'е без
|
||||
* recreate. Status-gate: только DRAFT и CHANGES_REQUESTED. Backend
|
||||
* автоматически переводит CHANGES_REQUESTED → DRAFT после update
|
||||
* (maker должен ре-submit на ревью осознанно).
|
||||
*/
|
||||
export const useUpdateSchemaDraft = (dictionaryName: string) => {
|
||||
const qc = useQueryClient()
|
||||
return useMutation({
|
||||
mutationFn: async (params: {
|
||||
draftId: string
|
||||
body: UpdateSchemaDraftRequest
|
||||
}): Promise<SchemaDraft> => {
|
||||
const { data } = await apiClient.patch<SchemaDraft>(
|
||||
`/dictionaries/${dictionaryName}/drafts/${params.draftId}`,
|
||||
params.body,
|
||||
)
|
||||
return data
|
||||
},
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: ['schema-draft-active', dictionaryName] })
|
||||
qc.invalidateQueries({ queryKey: ['schema-draft', dictionaryName] })
|
||||
qc.invalidateQueries({ queryKey: ['schema-drafts', dictionaryName] })
|
||||
qc.invalidateQueries({ queryKey: ['schema-review-queue'] })
|
||||
qc.invalidateQueries({ queryKey: ['changelog', dictionaryName] })
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** Maker submits draft → review_pending. 202 Accepted. */
|
||||
export const useSubmitSchemaDraftForReview = (dictionaryName: string) => {
|
||||
const qc = useQueryClient()
|
||||
|
||||
Reference in New Issue
Block a user