Skip to content

Commit

Permalink
Refactor query call to hook
Browse files Browse the repository at this point in the history
  • Loading branch information
beganovich committed Nov 30, 2023
1 parent fd701e8 commit 87256b5
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/pages/clients/create/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @license https://www.elastic.co/licensing/elastic-license
*/

import { AxiosError, AxiosResponse } from 'axios';
import { AxiosError } from 'axios';
import { endpoint } from '$app/common/helpers';
import { request } from '$app/common/helpers/request';
import { route } from '$app/common/helpers/route';
Expand All @@ -27,11 +27,10 @@ import { Contacts } from '../edit/components/Contacts';
import { Details } from '../edit/components/Details';
import { toast } from '$app/common/helpers/toast/toast';
import { useHandleCompanySave } from '$app/pages/settings/common/hooks/useHandleCompanySave';
import { useQuery } from 'react-query';
import { useTitle } from '$app/common/hooks/useTitle';
import { ValidationAlert } from '$app/components/ValidationAlert';
import { GenericSingleResourceResponse } from '$app/common/interfaces/generic-api-response';
import { $refetch } from '$app/common/hooks/useRefetch';
import { useBlankClientQuery } from '$app/common/queries/clients';

export default function Create() {
const { documentTitle } = useTitle('new_client');
Expand Down Expand Up @@ -63,15 +62,7 @@ export default function Create() {
},
]);

const { data: blankClient } = useQuery({
queryKey: ['/api/v1/clients/create'],
queryFn: () =>
request('GET', endpoint('/api/v1/clients/create')).then(
(response: AxiosResponse<GenericSingleResourceResponse<Client>>) =>
response.data.data
),
staleTime: Infinity,
});
const { data: blankClient } = useBlankClientQuery({});

useEffect(() => {
if (blankClient) {
Expand Down

0 comments on commit 87256b5

Please sign in to comment.