File tree Expand file tree Collapse file tree 3 files changed +75
-0
lines changed
frontend/app/src/entities/proposed-changes Expand file tree Collapse file tree 3 files changed +75
-0
lines changed Original file line number Diff line number Diff line change
1
+ import graphqlClient from "@/shared/api/graphql/graphqlClientApollo" ;
2
+ import { BranchContextParams } from "@/shared/api/types" ;
3
+ import { gql } from "@apollo/client" ;
4
+
5
+ const MUTATION = `
6
+ mutation ProposedChangeReview($id: ID, $decison: String) {
7
+ CoreProposedChangeReview(data: {
8
+ id: $id,
9
+ decision: $decision
10
+ }) {
11
+ ok
12
+ }
13
+ }
14
+ ` ;
15
+
16
+ export interface UpdateReviewFromApiApiParams extends BranchContextParams {
17
+ proposedChangeId : string ;
18
+ decision : string ;
19
+ }
20
+
21
+ export function udpateReviewFromApi ( {
22
+ proposedChangeId,
23
+ decision,
24
+ branchName,
25
+ } : UpdateReviewFromApiApiParams ) {
26
+ return graphqlClient . mutate ( {
27
+ mutation : gql ( MUTATION ) ,
28
+ variables : {
29
+ proposedChangeId,
30
+ decision,
31
+ } ,
32
+ context : {
33
+ branch : branchName ,
34
+ } ,
35
+ } ) ;
36
+ }
Original file line number Diff line number Diff line change
1
+ import { useCurrentBranch } from "@/entities/branches/ui/branches-provider" ;
2
+ import { useMutation } from "@tanstack/react-query" ;
3
+ import { UpdateReviewFromApiApiParams } from "../api/updateReviewFromApi" ;
4
+ import { updateReview } from "./update-review" ;
5
+
6
+ interface UpdateReviewProps {
7
+ onSuccess ?: ( ) => void ;
8
+ onError ?: ( ) => void ;
9
+ onSettled ?: ( ) => void ;
10
+ }
11
+
12
+ export function useUpdateReview ( { onSuccess, onError, onSettled } : UpdateReviewProps ) {
13
+ const { currentBranch } = useCurrentBranch ( ) ;
14
+
15
+ return useMutation ( {
16
+ mutationFn : async ( params : Omit < UpdateReviewFromApiApiParams , "branchName" > ) => {
17
+ return updateReview ( {
18
+ ...params ,
19
+ branchName : currentBranch . name ,
20
+ } ) ;
21
+ } ,
22
+ onSuccess,
23
+ onError,
24
+ onSettled,
25
+ } ) ;
26
+ }
Original file line number Diff line number Diff line change
1
+ import { UpdateReviewFromApiApiParams , udpateReviewFromApi } from "../api/updateReviewFromApi" ;
2
+
3
+ export type UpdateReview = ( data : UpdateReviewFromApiApiParams ) => Promise < void > ;
4
+
5
+ export const updateReview : UpdateReview = async ( params ) => {
6
+ const { data, errors } = await udpateReviewFromApi ( params ) ;
7
+
8
+ if ( errors ?. [ 0 ] ?. message ) {
9
+ throw new Error ( errors [ 0 ] . message ) ;
10
+ }
11
+
12
+ return data . CoreProposedChangeReview . object ;
13
+ } ;
You can’t perform that action at this time.
0 commit comments