Table updates
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { useCommonHooks } from 'hooks';
|
||||
import { useCallback } from 'react';
|
||||
import { useCallback, useState } from 'react';
|
||||
|
||||
const url = `${import.meta.env.PROD ? import.meta.env.VITE_DOMAIN_PROD : import.meta.env.VITE_DOMAIN_DEV}/${import.meta.env.VITE_BASE_URL}`;
|
||||
|
||||
@@ -34,6 +34,7 @@ export function useQueryAPI({ endpoint }: { endpoint: string }) {
|
||||
|
||||
export function useMutationAPI() {
|
||||
const { notify } = useCommonHooks();
|
||||
const [message, setMessage] = useState('');
|
||||
const callEndpoint = async (
|
||||
method: string,
|
||||
endpoint: string,
|
||||
@@ -52,7 +53,8 @@ export function useMutationAPI() {
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
};
|
||||
notify('Sending...');
|
||||
setMessage('Sending...');
|
||||
notify(message);
|
||||
const response = await fetch(`${url}/${endpoint}`, options);
|
||||
if (!response.ok) {
|
||||
notify('Error!');
|
||||
@@ -91,7 +93,7 @@ export function useMutationAPI() {
|
||||
|
||||
throw new Error(errorResponse);
|
||||
}
|
||||
notify('Success!');
|
||||
setMessage('Success!');
|
||||
return await response.json();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user