Skip to content

Commit

Permalink
Add approve/reject ownership mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
vhande committed Oct 23, 2024
1 parent 5394afc commit 9c86caf
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/hooks/api/ownerships.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { fetchFromApi, isErrorObject } from '@/utils/fetchFromApi';

import {
ServerSideQueryOptions,
useAuthenticatedMutation,
useAuthenticatedQuery,
} from './authenticated-query';

Expand Down Expand Up @@ -59,4 +60,40 @@ const useGetOwnershipRequestsQuery = (
...configuration,
});

export { useGetOwnershipRequestsQuery };
const approveOwnershipRequest = async ({ headers, ownershipId }) =>
fetchFromApi({
path: `/ownerships/${ownershipId}/approve`,
options: {
method: 'POST',
headers,
},
});

const useApproveOwnershipRequestMutation = (configuration = {}) =>
useAuthenticatedMutation({
mutationFn: approveOwnershipRequest,
mutationKey: 'approve-ownership-request',
...configuration,
});

const rejectOwnershipRequest = async ({ headers, ownershipId }) =>
fetchFromApi({
path: `/ownerships/${ownershipId}/reject`,
options: {
method: 'POST',
headers,
},
});

const useRejectOwnershipRequestMutation = (configuration = {}) =>
useAuthenticatedMutation({
mutationFn: rejectOwnershipRequest,
mutationKey: 'reject-ownership-request',
...configuration,
});

export {
useApproveOwnershipRequestMutation,
useGetOwnershipRequestsQuery,
useRejectOwnershipRequestMutation,
};

0 comments on commit 9c86caf

Please sign in to comment.