From 5c00861e34b343407975bd180b13e6f039321cb3 Mon Sep 17 00:00:00 2001 From: Nathan Arthur Date: Tue, 27 Sep 2022 16:24:12 -0400 Subject: [PATCH 1/2] refactor imports --- src/App.spec.tsx | 2 +- src/components/organisms/ApiSettings.spec.tsx | 6 +++--- src/components/organisms/ApiSettings.tsx | 3 ++- src/components/organisms/BeeminderSettings.tsx | 2 +- src/components/organisms/GeneralSettings.tsx | 3 ++- src/components/organisms/PaymentSettings.tsx | 3 ++- src/components/organisms/TaskList.tsx | 2 +- src/components/pages/Account.spec.tsx | 4 ++-- src/components/pages/Tasks.spec.tsx | 2 +- src/lib/api/addTask.ts | 4 ++-- src/lib/api/editTask.ts | 4 ++-- src/lib/api/{apiFetch.spec.ts => fetch1.spec.ts} | 6 +++--- src/lib/api/{apiFetch.ts => fetch1.ts} | 2 +- src/lib/api/getCheckoutSession.ts | 4 ++-- src/lib/api/getMe.ts | 4 ++-- src/lib/api/getTasks.ts | 4 ++-- src/lib/api/getTimezones.ts | 4 ++-- src/lib/api/index.ts | 14 -------------- src/lib/api/login.ts | 4 ++-- src/lib/api/register.ts | 4 ++-- src/lib/api/requestResetEmail.ts | 4 ++-- src/lib/api/resetPassword.ts | 4 ++-- src/lib/api/updateMe.spec.ts | 14 +++++++------- src/lib/api/updateMe.ts | 4 ++-- src/lib/api/updatePassword.ts | 4 ++-- src/lib/api/updateTask.ts | 4 ++-- src/lib/api/useGetApiToken.ts | 4 ++-- 27 files changed, 54 insertions(+), 65 deletions(-) rename src/lib/api/{apiFetch.spec.ts => fetch1.spec.ts} (82%) rename src/lib/api/{apiFetch.ts => fetch1.ts} (96%) delete mode 100644 src/lib/api/index.ts diff --git a/src/App.spec.tsx b/src/App.spec.tsx index 5f37bdd3..15ba4a66 100644 --- a/src/App.spec.tsx +++ b/src/App.spec.tsx @@ -12,7 +12,7 @@ import { useSession } from './lib/api/useSession'; import { MemoryRouter } from 'react-router-dom'; import { __listRef } from 'react-list'; import { waitFor, screen } from '@testing-library/react'; -import { addTask } from './lib/api'; +import { addTask } from './lib/api/addTask'; import getQueryClient from './lib/getQueryClient'; import { QueryClient } from 'react-query'; import loadControlledPromise from './lib/test/loadControlledPromise'; diff --git a/src/components/organisms/ApiSettings.spec.tsx b/src/components/organisms/ApiSettings.spec.tsx index c7b31723..b2bef5c1 100644 --- a/src/components/organisms/ApiSettings.spec.tsx +++ b/src/components/organisms/ApiSettings.spec.tsx @@ -3,18 +3,18 @@ import userEvent from '@testing-library/user-event'; import { screen } from '@testing-library/react'; import React from 'react'; import ApiSettings from './ApiSettings'; -import { apiFetch } from '../../lib/api'; +import { fetch1 } from '../../lib/api/fetch1'; import { vi, Mock } from 'vitest'; import { describe, it, expect } from 'vitest'; vi.mock('../../lib/api/getMe'); vi.mock('../../lib/api/updateMe'); -vi.mock('../../lib/api/apiFetch'); +vi.mock('../../lib/api/fetch1'); describe('API settings', () => { it('displays loading indicator on request click', async () => { loadMe({}); - (apiFetch as Mock).mockResolvedValue(new Response()); + (fetch1 as Mock).mockResolvedValue(new Response()); renderWithQueryProvider(); diff --git a/src/components/organisms/ApiSettings.tsx b/src/components/organisms/ApiSettings.tsx index 4deaca12..1cfa631f 100644 --- a/src/components/organisms/ApiSettings.tsx +++ b/src/components/organisms/ApiSettings.tsx @@ -1,5 +1,6 @@ import React from 'react'; -import { useGetApiToken, useMe } from '../../lib/api'; +import { useGetApiToken } from '../../lib/api/useGetApiToken'; +import { useMe } from '../../lib/api/useMe'; import { LoadingButton } from '@mui/lab'; import { Alert, diff --git a/src/components/organisms/BeeminderSettings.tsx b/src/components/organisms/BeeminderSettings.tsx index 2a48321d..8211568f 100644 --- a/src/components/organisms/BeeminderSettings.tsx +++ b/src/components/organisms/BeeminderSettings.tsx @@ -1,6 +1,6 @@ import React, { FormEvent, useEffect, useState } from 'react'; import { IS_PRODUCTION } from '../../tr_constants'; -import { useMe } from '../../lib/api'; +import { useMe } from '../../lib/api/useMe'; import browser from '../../lib/Browser'; import { Stack, TextField, Alert } from '@mui/material'; import { LoadingButton } from '@mui/lab'; diff --git a/src/components/organisms/GeneralSettings.tsx b/src/components/organisms/GeneralSettings.tsx index c4ac6ff0..4f5cf3c3 100644 --- a/src/components/organisms/GeneralSettings.tsx +++ b/src/components/organisms/GeneralSettings.tsx @@ -1,5 +1,6 @@ import React, { FormEvent, useEffect, useState } from 'react'; -import { getMe, useTimezones } from '../../lib/api'; +import { getMe } from '../../lib/api/getMe'; +import { useTimezones } from '../../lib/api/useTimezones'; import { Stack, TextField, Autocomplete } from '@mui/material'; import { LoadingButton } from '@mui/lab'; import useUpdateMe from '../../lib/api/useUpdateMe'; diff --git a/src/components/organisms/PaymentSettings.tsx b/src/components/organisms/PaymentSettings.tsx index 7d9c0756..6f355a48 100644 --- a/src/components/organisms/PaymentSettings.tsx +++ b/src/components/organisms/PaymentSettings.tsx @@ -1,5 +1,6 @@ import React, { useEffect, useState } from 'react'; -import { useCheckoutSession, useMe } from '../../lib/api'; +import { useCheckoutSession } from '../../lib/api/useCheckoutSession'; +import { useMe } from '../../lib/api/useMe'; import { LoadingButton } from '@mui/lab'; import { Alert, diff --git a/src/components/organisms/TaskList.tsx b/src/components/organisms/TaskList.tsx index 81248865..f188d4cd 100644 --- a/src/components/organisms/TaskList.tsx +++ b/src/components/organisms/TaskList.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useRef, useState } from 'react'; import { sortTasks } from '../../lib/sortTasks'; -import { useTasks } from '../../lib/api'; +import { useTasks } from '../../lib/api/useTasks'; import createListItems from '../../lib/createListItems'; import ReactList from 'react-list'; import { Alert, AlertTitle, ListSubheader } from '@mui/material'; diff --git a/src/components/pages/Account.spec.tsx b/src/components/pages/Account.spec.tsx index fd35b159..3828d5e7 100644 --- a/src/components/pages/Account.spec.tsx +++ b/src/components/pages/Account.spec.tsx @@ -8,7 +8,7 @@ import { renderWithQueryProvider, } from '../../lib/test/helpers'; import userEvent from '@testing-library/user-event'; -import { useGetApiToken } from '../../lib/api'; +import { useGetApiToken } from '../../lib/api/useGetApiToken'; import { getCheckoutSession } from '../../lib/api/getCheckoutSession'; import { describe, it, expect, vi, beforeEach } from 'vitest'; @@ -16,7 +16,7 @@ vi.mock('../../lib/api/getTimezones'); vi.mock('../../lib/api/getMe'); vi.mock('../../lib/api/updateMe'); vi.mock('../../lib/api/getCheckoutSession'); -vi.mock('../../lib/api/apiFetch'); +vi.mock('../../lib/api/fetch1'); vi.mock('../../lib/api/updatePassword'); vi.mock('../../lib/api/useGetApiToken'); diff --git a/src/components/pages/Tasks.spec.tsx b/src/components/pages/Tasks.spec.tsx index a67ae95c..c658dc28 100644 --- a/src/components/pages/Tasks.spec.tsx +++ b/src/components/pages/Tasks.spec.tsx @@ -21,7 +21,7 @@ import { vi, Mock, describe, it, expect, beforeEach } from 'vitest'; import loadControlledPromise from '../../lib/test/loadControlledPromise'; import { findTaskCheckbox } from '../../lib/test/queries'; -vi.mock('../../lib/api/apiFetch'); +vi.mock('../../lib/api/fetch1'); vi.mock('../../lib/api/getTasks'); vi.mock('../../lib/api/getMe'); vi.mock('../../lib/api/updateTask'); diff --git a/src/lib/api/addTask.ts b/src/lib/api/addTask.ts index c9c062d0..e907acfb 100644 --- a/src/lib/api/addTask.ts +++ b/src/lib/api/addTask.ts @@ -1,4 +1,4 @@ -import { apiFetch } from './apiFetch'; +import { fetch1 } from './fetch1'; // Requires that user be authenticated. export async function addTask( @@ -6,7 +6,7 @@ export async function addTask( due: string, cents: number ): Promise { - const response = await apiFetch('me/tasks', true, 'POST', { + const response = await fetch1('me/tasks', true, 'POST', { task, due, cents, diff --git a/src/lib/api/editTask.ts b/src/lib/api/editTask.ts index edf1e862..84697fb7 100644 --- a/src/lib/api/editTask.ts +++ b/src/lib/api/editTask.ts @@ -1,4 +1,4 @@ -import { apiFetch } from './apiFetch'; +import { fetch1 } from './fetch1'; // Requires that user be authenticated. export async function editTask( @@ -6,7 +6,7 @@ export async function editTask( due: string, cents: number ): Promise { - const response = await apiFetch(`me/tasks/${id}`, true, 'PUT', { + const response = await fetch1(`me/tasks/${id}`, true, 'PUT', { due, cents, }); diff --git a/src/lib/api/apiFetch.spec.ts b/src/lib/api/fetch1.spec.ts similarity index 82% rename from src/lib/api/apiFetch.spec.ts rename to src/lib/api/fetch1.spec.ts index 2f68d0a6..0ea956c2 100644 --- a/src/lib/api/apiFetch.spec.ts +++ b/src/lib/api/fetch1.spec.ts @@ -1,7 +1,7 @@ -import { apiFetch } from './apiFetch'; +import { fetch1 } from './fetch1'; import { describe, it, expect } from 'vitest'; -describe('apiFetch', () => { +describe('fetch1', () => { it('uses localStorage token', async () => { fetchMock.mockResponse(JSON.stringify({})); @@ -10,7 +10,7 @@ describe('apiFetch', () => { global.localStorage.setItem('token', token); const url = 'https://example.com'; - await apiFetch(url); + await fetch1(url); expect(fetch).toHaveBeenCalledWith( expect.anything(), diff --git a/src/lib/api/apiFetch.ts b/src/lib/api/fetch1.ts similarity index 96% rename from src/lib/api/apiFetch.ts rename to src/lib/api/fetch1.ts index 71c695ce..17a798b9 100644 --- a/src/lib/api/apiFetch.ts +++ b/src/lib/api/fetch1.ts @@ -7,7 +7,7 @@ const _trim = (s: string, c: string) => { return s.replace(new RegExp('^[' + c + ']+|[' + c + ']+$', 'g'), ''); }; -export async function apiFetch( +export async function fetch1( route: string, protected_ = false, method = 'GET', diff --git a/src/lib/api/getCheckoutSession.ts b/src/lib/api/getCheckoutSession.ts index 48dbdaee..5a87f6c1 100644 --- a/src/lib/api/getCheckoutSession.ts +++ b/src/lib/api/getCheckoutSession.ts @@ -1,7 +1,7 @@ -import { apiFetch } from './apiFetch'; +import { fetch1 } from './fetch1'; export async function getCheckoutSession(): Promise { - const response = await apiFetch('payments/checkout/session'); + const response = await fetch1('payments/checkout/session'); return response.json() as Promise; } diff --git a/src/lib/api/getMe.ts b/src/lib/api/getMe.ts index cb1c4192..72e4abb3 100644 --- a/src/lib/api/getMe.ts +++ b/src/lib/api/getMe.ts @@ -1,7 +1,7 @@ -import { apiFetch } from './apiFetch'; +import { fetch1 } from './fetch1'; export async function getMe(): Promise { - const response = await apiFetch('me', true); + const response = await fetch1('me', true); if (!response.ok) { throw new Error('Failed to get me'); diff --git a/src/lib/api/getTasks.ts b/src/lib/api/getTasks.ts index e64cdd04..f6e41508 100644 --- a/src/lib/api/getTasks.ts +++ b/src/lib/api/getTasks.ts @@ -1,7 +1,7 @@ -import { apiFetch } from './apiFetch'; +import { fetch1 } from './fetch1'; export async function getTasks(): Promise { - const response = await apiFetch('me/tasks', true); + const response = await fetch1('me/tasks', true); return response.json(); } diff --git a/src/lib/api/getTimezones.ts b/src/lib/api/getTimezones.ts index 4e9b2de2..49efeeaf 100644 --- a/src/lib/api/getTimezones.ts +++ b/src/lib/api/getTimezones.ts @@ -1,7 +1,7 @@ -import { apiFetch } from './apiFetch'; +import { fetch1 } from './fetch1'; export async function getTimezones(): Promise { - const response = await apiFetch('timezones'); + const response = await fetch1('timezones'); return response.json() as Promise; } diff --git a/src/lib/api/index.ts b/src/lib/api/index.ts deleted file mode 100644 index 3fb85487..00000000 --- a/src/lib/api/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -export * from './useTasks'; -export * from './useMe'; -export * from './apiFetch'; -export * from './useTimezones'; -export * from './useCheckoutSession'; -export * from './getTasks'; -export * from './getMe'; -export * from './updateTask'; -export * from './getTimezones'; -export * from './getCheckoutSession'; -export * from './updateMe'; -export * from './addTask'; -export * from './updatePassword'; -export * from './useGetApiToken'; diff --git a/src/lib/api/login.ts b/src/lib/api/login.ts index 588ddab5..619114f9 100644 --- a/src/lib/api/login.ts +++ b/src/lib/api/login.ts @@ -1,8 +1,8 @@ import { publishSession } from './useSession'; -import { apiFetch } from './apiFetch'; +import { fetch1 } from './fetch1'; export function login(email: string, password: string): Promise { - return apiFetch('account/login', false, 'POST', { + return fetch1('account/login', false, 'POST', { email: email, password: password, }).then((res: Response) => { diff --git a/src/lib/api/register.ts b/src/lib/api/register.ts index 9b410488..61719546 100644 --- a/src/lib/api/register.ts +++ b/src/lib/api/register.ts @@ -1,4 +1,4 @@ -import { apiFetch } from './apiFetch'; +import { fetch1 } from './fetch1'; export default function register( name: string, @@ -7,7 +7,7 @@ export default function register( timezone: string, checkoutSessionId: string | null ): Promise { - return apiFetch('account/register', false, 'POST', { + return fetch1('account/register', false, 'POST', { name: name, email: email, password: password, diff --git a/src/lib/api/requestResetEmail.ts b/src/lib/api/requestResetEmail.ts index 573bf9e0..604d3205 100644 --- a/src/lib/api/requestResetEmail.ts +++ b/src/lib/api/requestResetEmail.ts @@ -1,5 +1,5 @@ -import { apiFetch } from './apiFetch'; +import { fetch1 } from './fetch1'; export function requestResetEmail(email: string): Promise { - return apiFetch('account/forgot-password', false, 'POST', { email: email }); + return fetch1('account/forgot-password', false, 'POST', { email: email }); } diff --git a/src/lib/api/resetPassword.ts b/src/lib/api/resetPassword.ts index 823c3f8b..88c5d728 100644 --- a/src/lib/api/resetPassword.ts +++ b/src/lib/api/resetPassword.ts @@ -1,10 +1,10 @@ -import { apiFetch } from './apiFetch'; +import { fetch1 } from './fetch1'; export function resetPassword( token: string, password: string ): Promise { - return apiFetch('account/reset-password', false, 'POST', { + return fetch1('account/reset-password', false, 'POST', { token: token, password: password, }); diff --git a/src/lib/api/updateMe.spec.ts b/src/lib/api/updateMe.spec.ts index b9ff9efd..41e2fc3f 100644 --- a/src/lib/api/updateMe.spec.ts +++ b/src/lib/api/updateMe.spec.ts @@ -1,13 +1,13 @@ import { updateMe } from './updateMe'; -import { apiFetch } from './apiFetch'; +import { fetch1 } from './fetch1'; import set from 'lodash/set'; import { describe, it, expect, beforeEach, vi } from 'vitest'; -vi.mock('./apiFetch'); +vi.mock('./fetch1'); describe('updateMe', () => { beforeEach(() => { - vi.mocked(apiFetch).mockResolvedValue({ ok: true } as Response); + vi.mocked(fetch1).mockResolvedValue({ ok: true } as Response); }); it('reformats beeminder integration token', async () => { @@ -21,7 +21,7 @@ describe('updateMe', () => { 'the_token' ); - expect(apiFetch).toBeCalledWith('me', true, 'PUT', expectedPayload); + expect(fetch1).toBeCalledWith('me', true, 'PUT', expectedPayload); }); it('reformats beeminder integration user', async () => { @@ -31,7 +31,7 @@ describe('updateMe', () => { const expectedPayload = set({}, 'integrations.beeminder.user', 'the_user'); - expect(apiFetch).toBeCalledWith('me', true, 'PUT', expectedPayload); + expect(fetch1).toBeCalledWith('me', true, 'PUT', expectedPayload); }); it('reformats beeminder integration goal', async () => { @@ -45,7 +45,7 @@ describe('updateMe', () => { 'the_goal' ); - expect(apiFetch).toBeCalledWith('me', true, 'PUT', expectedPayload); + expect(fetch1).toBeCalledWith('me', true, 'PUT', expectedPayload); }); it('pipes remaining fields', async () => { @@ -58,6 +58,6 @@ describe('updateMe', () => { await updateMe(inOut); - expect(apiFetch).toBeCalledWith('me', true, 'PUT', inOut); + expect(fetch1).toBeCalledWith('me', true, 'PUT', inOut); }); }); diff --git a/src/lib/api/updateMe.ts b/src/lib/api/updateMe.ts index 5a526225..72e24698 100644 --- a/src/lib/api/updateMe.ts +++ b/src/lib/api/updateMe.ts @@ -1,4 +1,4 @@ -import { apiFetch } from './apiFetch'; +import { fetch1 } from './fetch1'; import set from 'lodash/set'; import get from 'lodash/get'; @@ -44,7 +44,7 @@ export async function updateMe(input: MeInput): Promise { ['checkout_session_id', 'checkout_session_id'], ]); - const response = await apiFetch('me', true, 'PUT', payload); + const response = await fetch1('me', true, 'PUT', payload); if (!response.ok) { throw new Error('Failed to update me'); diff --git a/src/lib/api/updatePassword.ts b/src/lib/api/updatePassword.ts index 2af28680..327033e1 100644 --- a/src/lib/api/updatePassword.ts +++ b/src/lib/api/updatePassword.ts @@ -1,10 +1,10 @@ -import { apiFetch } from './apiFetch'; +import { fetch1 } from './fetch1'; export function updatePassword( oldPassword: string, newPassword: string ): Promise { - return apiFetch('me', true, 'PUT', { + return fetch1('me', true, 'PUT', { old_password: oldPassword, new_password: newPassword, }); diff --git a/src/lib/api/updateTask.ts b/src/lib/api/updateTask.ts index fbed46eb..90c845e8 100644 --- a/src/lib/api/updateTask.ts +++ b/src/lib/api/updateTask.ts @@ -1,4 +1,4 @@ -import { apiFetch } from './apiFetch'; +import { fetch1 } from './fetch1'; export interface TaskInput { complete?: boolean; @@ -7,5 +7,5 @@ export interface TaskInput { // Requires that user be authenticated. export function updateTask(taskId: string, data: TaskInput): Promise { - return apiFetch('me/tasks/' + taskId, true, 'PUT', data); + return fetch1('me/tasks/' + taskId, true, 'PUT', data); } diff --git a/src/lib/api/useGetApiToken.ts b/src/lib/api/useGetApiToken.ts index 3303769b..c96e665e 100644 --- a/src/lib/api/useGetApiToken.ts +++ b/src/lib/api/useGetApiToken.ts @@ -1,5 +1,5 @@ import { useMutation } from 'react-query'; -import { apiFetch } from './apiFetch'; +import { fetch1 } from './fetch1'; import { UseMutationResult } from 'react-query'; export function useGetApiToken(): UseMutationResult< @@ -9,7 +9,7 @@ export function useGetApiToken(): UseMutationResult< unknown > { return useMutation('api-token', async () => { - const response = await apiFetch('me/token', true, 'GET'); + const response = await fetch1('me/token', true, 'GET'); return response.text(); }); } From 14742e76eba6de9d7943240d1198b026b1ee3b36 Mon Sep 17 00:00:00 2001 From: Nathan Arthur Date: Tue, 27 Sep 2022 16:34:22 -0400 Subject: [PATCH 2/2] use default export for fetch1 --- src/components/organisms/ApiSettings.spec.tsx | 2 +- src/lib/api/addTask.ts | 2 +- src/lib/api/editTask.ts | 2 +- src/lib/api/fetch1.spec.ts | 2 +- src/lib/api/fetch1.ts | 2 +- src/lib/api/getCheckoutSession.ts | 2 +- src/lib/api/getMe.ts | 2 +- src/lib/api/getTasks.ts | 2 +- src/lib/api/getTimezones.ts | 2 +- src/lib/api/login.ts | 2 +- src/lib/api/register.ts | 2 +- src/lib/api/requestResetEmail.ts | 2 +- src/lib/api/resetPassword.ts | 2 +- src/lib/api/updateMe.spec.ts | 2 +- src/lib/api/updateMe.ts | 2 +- src/lib/api/updatePassword.ts | 2 +- src/lib/api/updateTask.ts | 2 +- src/lib/api/useGetApiToken.ts | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/components/organisms/ApiSettings.spec.tsx b/src/components/organisms/ApiSettings.spec.tsx index b2bef5c1..c1a52ab0 100644 --- a/src/components/organisms/ApiSettings.spec.tsx +++ b/src/components/organisms/ApiSettings.spec.tsx @@ -3,7 +3,7 @@ import userEvent from '@testing-library/user-event'; import { screen } from '@testing-library/react'; import React from 'react'; import ApiSettings from './ApiSettings'; -import { fetch1 } from '../../lib/api/fetch1'; +import fetch1 from '../../lib/api/fetch1'; import { vi, Mock } from 'vitest'; import { describe, it, expect } from 'vitest'; diff --git a/src/lib/api/addTask.ts b/src/lib/api/addTask.ts index e907acfb..b3c3b8ac 100644 --- a/src/lib/api/addTask.ts +++ b/src/lib/api/addTask.ts @@ -1,4 +1,4 @@ -import { fetch1 } from './fetch1'; +import fetch1 from './fetch1'; // Requires that user be authenticated. export async function addTask( diff --git a/src/lib/api/editTask.ts b/src/lib/api/editTask.ts index 84697fb7..625a551d 100644 --- a/src/lib/api/editTask.ts +++ b/src/lib/api/editTask.ts @@ -1,4 +1,4 @@ -import { fetch1 } from './fetch1'; +import fetch1 from './fetch1'; // Requires that user be authenticated. export async function editTask( diff --git a/src/lib/api/fetch1.spec.ts b/src/lib/api/fetch1.spec.ts index 0ea956c2..a6c5f070 100644 --- a/src/lib/api/fetch1.spec.ts +++ b/src/lib/api/fetch1.spec.ts @@ -1,4 +1,4 @@ -import { fetch1 } from './fetch1'; +import fetch1 from './fetch1'; import { describe, it, expect } from 'vitest'; describe('fetch1', () => { diff --git a/src/lib/api/fetch1.ts b/src/lib/api/fetch1.ts index 17a798b9..5d14c067 100644 --- a/src/lib/api/fetch1.ts +++ b/src/lib/api/fetch1.ts @@ -7,7 +7,7 @@ const _trim = (s: string, c: string) => { return s.replace(new RegExp('^[' + c + ']+|[' + c + ']+$', 'g'), ''); }; -export async function fetch1( +export default async function fetch1( route: string, protected_ = false, method = 'GET', diff --git a/src/lib/api/getCheckoutSession.ts b/src/lib/api/getCheckoutSession.ts index 5a87f6c1..aab63e2f 100644 --- a/src/lib/api/getCheckoutSession.ts +++ b/src/lib/api/getCheckoutSession.ts @@ -1,4 +1,4 @@ -import { fetch1 } from './fetch1'; +import fetch1 from './fetch1'; export async function getCheckoutSession(): Promise { const response = await fetch1('payments/checkout/session'); diff --git a/src/lib/api/getMe.ts b/src/lib/api/getMe.ts index 72e4abb3..87e79a39 100644 --- a/src/lib/api/getMe.ts +++ b/src/lib/api/getMe.ts @@ -1,4 +1,4 @@ -import { fetch1 } from './fetch1'; +import fetch1 from './fetch1'; export async function getMe(): Promise { const response = await fetch1('me', true); diff --git a/src/lib/api/getTasks.ts b/src/lib/api/getTasks.ts index f6e41508..98e91b24 100644 --- a/src/lib/api/getTasks.ts +++ b/src/lib/api/getTasks.ts @@ -1,4 +1,4 @@ -import { fetch1 } from './fetch1'; +import fetch1 from './fetch1'; export async function getTasks(): Promise { const response = await fetch1('me/tasks', true); diff --git a/src/lib/api/getTimezones.ts b/src/lib/api/getTimezones.ts index 49efeeaf..aa07cf7d 100644 --- a/src/lib/api/getTimezones.ts +++ b/src/lib/api/getTimezones.ts @@ -1,4 +1,4 @@ -import { fetch1 } from './fetch1'; +import fetch1 from './fetch1'; export async function getTimezones(): Promise { const response = await fetch1('timezones'); diff --git a/src/lib/api/login.ts b/src/lib/api/login.ts index 619114f9..da40c51d 100644 --- a/src/lib/api/login.ts +++ b/src/lib/api/login.ts @@ -1,5 +1,5 @@ import { publishSession } from './useSession'; -import { fetch1 } from './fetch1'; +import fetch1 from './fetch1'; export function login(email: string, password: string): Promise { return fetch1('account/login', false, 'POST', { diff --git a/src/lib/api/register.ts b/src/lib/api/register.ts index 61719546..6291cce2 100644 --- a/src/lib/api/register.ts +++ b/src/lib/api/register.ts @@ -1,4 +1,4 @@ -import { fetch1 } from './fetch1'; +import fetch1 from './fetch1'; export default function register( name: string, diff --git a/src/lib/api/requestResetEmail.ts b/src/lib/api/requestResetEmail.ts index 604d3205..450967b6 100644 --- a/src/lib/api/requestResetEmail.ts +++ b/src/lib/api/requestResetEmail.ts @@ -1,4 +1,4 @@ -import { fetch1 } from './fetch1'; +import fetch1 from './fetch1'; export function requestResetEmail(email: string): Promise { return fetch1('account/forgot-password', false, 'POST', { email: email }); diff --git a/src/lib/api/resetPassword.ts b/src/lib/api/resetPassword.ts index 88c5d728..3cbd3bcc 100644 --- a/src/lib/api/resetPassword.ts +++ b/src/lib/api/resetPassword.ts @@ -1,4 +1,4 @@ -import { fetch1 } from './fetch1'; +import fetch1 from './fetch1'; export function resetPassword( token: string, diff --git a/src/lib/api/updateMe.spec.ts b/src/lib/api/updateMe.spec.ts index 41e2fc3f..013aee71 100644 --- a/src/lib/api/updateMe.spec.ts +++ b/src/lib/api/updateMe.spec.ts @@ -1,5 +1,5 @@ import { updateMe } from './updateMe'; -import { fetch1 } from './fetch1'; +import fetch1 from './fetch1'; import set from 'lodash/set'; import { describe, it, expect, beforeEach, vi } from 'vitest'; diff --git a/src/lib/api/updateMe.ts b/src/lib/api/updateMe.ts index 72e24698..66cc3c65 100644 --- a/src/lib/api/updateMe.ts +++ b/src/lib/api/updateMe.ts @@ -1,4 +1,4 @@ -import { fetch1 } from './fetch1'; +import fetch1 from './fetch1'; import set from 'lodash/set'; import get from 'lodash/get'; diff --git a/src/lib/api/updatePassword.ts b/src/lib/api/updatePassword.ts index 327033e1..de38f41e 100644 --- a/src/lib/api/updatePassword.ts +++ b/src/lib/api/updatePassword.ts @@ -1,4 +1,4 @@ -import { fetch1 } from './fetch1'; +import fetch1 from './fetch1'; export function updatePassword( oldPassword: string, diff --git a/src/lib/api/updateTask.ts b/src/lib/api/updateTask.ts index 90c845e8..c75efc81 100644 --- a/src/lib/api/updateTask.ts +++ b/src/lib/api/updateTask.ts @@ -1,4 +1,4 @@ -import { fetch1 } from './fetch1'; +import fetch1 from './fetch1'; export interface TaskInput { complete?: boolean; diff --git a/src/lib/api/useGetApiToken.ts b/src/lib/api/useGetApiToken.ts index c96e665e..77940c4d 100644 --- a/src/lib/api/useGetApiToken.ts +++ b/src/lib/api/useGetApiToken.ts @@ -1,5 +1,5 @@ import { useMutation } from 'react-query'; -import { fetch1 } from './fetch1'; +import fetch1 from './fetch1'; import { UseMutationResult } from 'react-query'; export function useGetApiToken(): UseMutationResult<