Skip to content

Commit

Permalink
common folder
Browse files Browse the repository at this point in the history
  • Loading branch information
mwarman committed Oct 31, 2024
1 parent 2dfe52e commit fc71601
Show file tree
Hide file tree
Showing 192 changed files with 252 additions and 260 deletions.
18 changes: 9 additions & 9 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { RouterProvider } from 'react-router-dom';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';

import ErrorBoundary from 'components/Errors/ErrorBoundary';
import ErrorFallback from 'components/Errors/ErrorFallback';
import ConfigContextProvider from 'providers/ConfigProvider';
import SettingsContextProvider from 'providers/SettingsProvider';
import AxiosContextProvider from 'providers/AxiosProvider';
import { router } from 'components/Router/Router';
import Theme from 'components/Theme/Theme';
import AuthContextProvider from 'providers/AuthProvider';
import ToastsProvider from 'providers/ToastsProvider';
import ErrorBoundary from 'common/components/Errors/ErrorBoundary';
import ErrorFallback from 'common/components/Errors/ErrorFallback';
import ConfigContextProvider from 'common/providers/ConfigProvider';
import SettingsContextProvider from 'common/providers/SettingsProvider';
import AxiosContextProvider from 'common/providers/AxiosProvider';
import { router } from 'common/components/Router/Router';
import Theme from 'common/components/Theme/Theme';
import AuthContextProvider from 'common/providers/AuthProvider';
import ToastsProvider from 'common/providers/ToastsProvider';

/**
* React Query `QueryClient` and configuration.
Expand Down
2 changes: 1 addition & 1 deletion src/__fixtures__/settings.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { Settings } from 'api/useGetSettings';
import { Settings } from 'common/api/useGetSettings';

export const settingsFixture: Settings = { theme: 'dark' };
2 changes: 1 addition & 1 deletion src/__fixtures__/toasts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ToastDetail } from 'providers/ToastsContext';
import { ToastDetail } from 'common/providers/ToastsContext';

export const toastFixture: ToastDetail = {
id: 'toast1',
Expand Down
2 changes: 1 addition & 1 deletion src/__fixtures__/tokens.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UserTokens } from 'api/useGetUserTokens';
import { UserTokens } from 'common/api/useGetUserTokens';

export const userTokensFixture: UserTokens = {
id_token: 'id-token',
Expand Down
2 changes: 1 addition & 1 deletion src/__fixtures__/users.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { User } from 'api/useGetUser';
import { User } from 'common/api/useGetUser';

export const userFixture1: User = {
id: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
import { renderHook, waitFor } from 'test/test-utils';

import { userFixture1 } from '__fixtures__/users';
import storage from 'utils/storage';
import storage from 'common/utils/storage';

import { useGetCurrentUser } from 'api/useGetCurrentUser';
import { useGetCurrentUser } from 'common/api/useGetCurrentUser';

describe('useGetCurrentUser', () => {
const getItemSpy = vi.spyOn(storage, 'getItem');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
import { renderHook, waitFor } from 'test/test-utils';

import { settingsFixture } from '__fixtures__/settings';
import { DEFAULT_SETTINGS, StorageKeys } from 'utils/constants';
import storage from 'utils/storage';
import { DEFAULT_SETTINGS, StorageKeys } from 'common/utils/constants';
import storage from 'common/utils/storage';

import { useGetSettings } from 'api/useGetSettings';
import { useGetSettings } from 'common/api/useGetSettings';

describe('useGetSettings', () => {
const getItemSpy = vi.spyOn(storage, 'getItem');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
import { useGetUser } from 'api/useGetUser';
import { useGetUser } from 'common/api/useGetUser';
import { renderHook, waitFor } from 'test/test-utils';

describe('useGetUser', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import dayjs from 'dayjs';

import { renderHook, waitFor } from 'test/test-utils';
import WithQueryClientProvider from 'test/wrappers/WithQueryClientProvider';
import storage from 'utils/storage';
import storage from 'common/utils/storage';
import { userTokensFixture } from '__fixtures__/tokens';

import { UserTokens, useGetUserTokens } from 'api/useGetUserTokens';
import { UserTokens, useGetUserTokens } from 'common/api/useGetUserTokens';

describe('useGetTokens', () => {
const getItemSpy = vi.spyOn(storage, 'getItem');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { describe, expect, it, vi } from 'vitest';
import { renderHook, waitFor } from 'test/test-utils';

import storage from 'utils/storage';
import { Settings } from 'api/useGetSettings';
import storage from 'common/utils/storage';
import { Settings } from 'common/api/useGetSettings';

import { useSetSettings } from 'api/useSetSettings';
import { useSetSettings } from 'common/api/useSetSettings';

describe('useSetSettings', () => {
const setItemSpy = vi.spyOn(storage, 'setItem');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useQuery } from '@tanstack/react-query';

import storage from 'utils/storage';
import storage from 'common/utils/storage';
import { User } from './useGetUser';
import { QueryKeys, StorageKeys } from 'utils/constants';
import { QueryKeys, StorageKeys } from 'common/utils/constants';

/**
* An API hook which fetches the currently authenticated `User`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useQuery } from '@tanstack/react-query';

import { DEFAULT_SETTINGS, QueryKeys, StorageKeys } from 'utils/constants';
import storage from 'utils/storage';
import { DEFAULT_SETTINGS, QueryKeys, StorageKeys } from 'common/utils/constants';
import storage from 'common/utils/storage';

/**
* The `Settings` are user preferences.
Expand Down
6 changes: 3 additions & 3 deletions src/api/useGetUser.ts → src/common/api/useGetUser.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { UseQueryResult, useQuery } from '@tanstack/react-query';

import { useAxios } from 'hooks/useAxios';
import { useConfig } from 'hooks/useConfig';
import { QueryKeys } from 'utils/constants';
import { useAxios } from 'common/hooks/useAxios';
import { useConfig } from 'common/hooks/useConfig';
import { QueryKeys } from 'common/utils/constants';

/**
* The `Address` type.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { UseQueryOptions, UseQueryResult, useQuery } from '@tanstack/react-query';
import dayjs from 'dayjs';

import { QueryKeys, StorageKeys } from 'utils/constants';
import storage from 'utils/storage';
import { QueryKeys, StorageKeys } from 'common/utils/constants';
import storage from 'common/utils/storage';

/**
* A `UserTokens` object contains OAuth access, id, and refresh tokens
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';

import storage from 'utils/storage';
import { DEFAULT_SETTINGS, QueryKeys, StorageKeys } from 'utils/constants';
import storage from 'common/utils/storage';
import { DEFAULT_SETTINGS, QueryKeys, StorageKeys } from 'common/utils/constants';
import { Settings } from './useGetSettings';

/**
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ButtonVariant, PropsWithClassName } from '@leanstacks/react-common';
import { useTranslation } from 'react-i18next';

import { StorageKeys } from 'utils/constants';
import storage from 'utils/storage';
import Dropdown from 'components/Dropdown/Dropdown';
import FAIcon from 'components/Icon/FAIcon';
import DropdownContent from 'components/Dropdown/DropdownContent';
import DropdownItem from 'components/Dropdown/DropdownItem';
import { StorageKeys } from 'common/utils/constants';
import storage from 'common/utils/storage';
import Dropdown from 'common/components/Dropdown/Dropdown';
import FAIcon from 'common/components/Icon/FAIcon';
import DropdownContent from 'common/components/Dropdown/DropdownContent';
import DropdownItem from 'common/components/Dropdown/DropdownItem';
import Button from './Button';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ButtonVariant, PropsWithClassName } from '@leanstacks/react-common';
import classNames from 'classnames';

import { useSetSettings } from 'api/useSetSettings';
import { useSettings } from 'hooks/useSettings';
import { useSetSettings } from 'common/api/useSetSettings';
import { useSettings } from 'common/hooks/useSettings';
import Button from './Button';
import FAIcon from 'components/Icon/FAIcon';
import FAIcon from 'common/components/Icon/FAIcon';

/**
* Properties for the `ThemeToggle` component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import userEvent from '@testing-library/user-event';
import { describe, expect, it, vi } from 'vitest';

import { StorageKeys } from 'utils/constants';
import { StorageKeys } from 'common/utils/constants';
import { render, screen } from 'test/test-utils';
import storage from 'utils/storage';
import storage from 'common/utils/storage';

import LanguageToggle from '../LanguageToggle';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { UseMutationResult } from '@tanstack/react-query';
import userEvent from '@testing-library/user-event';

import { render, screen } from 'test/test-utils';
import { Settings } from 'api/useGetSettings';
import * as UseSettings from 'hooks/useSettings';
import * as UseSetSettings from 'api/useSetSettings';
import { Settings } from 'common/api/useGetSettings';
import * as UseSettings from 'common/hooks/useSettings';
import * as UseSetSettings from 'common/api/useSetSettings';
import { settingsFixture } from '__fixtures__/settings';

import ThemeToggle from '../ThemeToggle';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import classNames from 'classnames';

import Card, { CardProps } from './Card';
import FAIcon, { FAIconProps } from 'components/Icon/FAIcon';
import FAIcon, { FAIconProps } from 'common/components/Icon/FAIcon';

/**
* Properties for the `MessageCard` React component.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import classNames from 'classnames';
import dayjs from 'dayjs';
import { useTranslation } from 'react-i18next';

import Link from 'components/Link/Link';
import Link from 'common/components/Link/Link';

/**
* Properties for the `Footer` component.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ChangeEvent, ReactElement, useEffect, useRef } from 'react';
import { PropsWithClassName, PropsWithTestId } from '@leanstacks/react-common';
import classNames from 'classnames';

import FAIcon from 'components/Icon/FAIcon';
import FAIcon from 'common/components/Icon/FAIcon';
import { SearchResultProps } from './SearchResult';

/**
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PropsWithTestId } from '@leanstacks/react-common';
import { useField } from 'formik';
import classNames from 'classnames';

import FAIcon from 'components/Icon/FAIcon';
import FAIcon from 'common/components/Icon/FAIcon';

/**
* Describes a single option for a `SelectField`. If `label` is omitted,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useAuth } from 'hooks/useAuth';
import { useGetCurrentUser } from 'api/useGetCurrentUser';
import { useAuth } from 'common/hooks/useAuth';
import { useGetCurrentUser } from 'common/api/useGetCurrentUser';

import logo from './logo.png';
import SideMenu, { SideMenuProps } from 'components/Menu/SideMenu/SideMenu';
import MenuNavLink from 'components/Menu/MenuNavLink';
import Avatar from 'components/Icon/Avatar';
import MenuSeparator from 'components/Menu/MenuSeparator';
import SideMenu, { SideMenuProps } from 'common/components/Menu/SideMenu/SideMenu';
import MenuNavLink from 'common/components/Menu/MenuNavLink';
import Avatar from 'common/components/Icon/Avatar';
import MenuSeparator from 'common/components/Menu/MenuSeparator';

/**
* Properties fro the `AppMenu` component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Link } from 'react-router-dom';
import { PropsWithTestId } from '@leanstacks/react-common';

import { useAuth } from 'hooks/useAuth';
import { useAuth } from 'common/hooks/useAuth';
import logo from './logo.png';
import ThemeToggle from 'components/Button/ThemeToggle';
import ThemeToggle from 'common/components/Button/ThemeToggle';
import AppMenu from './AppMenu';
import MenuButton from 'components/Menu/MenuButton';
import LanguageToggle from 'components/Button/LanguageToggle';
import MenuButton from 'common/components/Menu/MenuButton';
import LanguageToggle from 'common/components/Button/LanguageToggle';

/**
* Properties for the `Header` component.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { render, screen } from 'test/test-utils';
import { queryClient } from 'test/query-client';
import { UseQueryResult } from '@tanstack/react-query';

import { User } from 'api/useGetUser';
import * as UseAuth from 'hooks/useAuth';
import * as UseGetCurrentUser from 'api/useGetCurrentUser';
import { User } from 'common/api/useGetUser';
import * as UseAuth from 'common/hooks/useAuth';
import * as UseGetCurrentUser from 'common/api/useGetCurrentUser';
import { userFixture1 } from '__fixtures__/users';

import AppMenu from '../AppMenu';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Route, Routes } from 'react-router-dom';

import { render, screen } from 'test/test-utils';

import * as UseAuth from 'hooks/useAuth';
import * as UseAuth from 'common/hooks/useAuth';

import Header from '../Header';

Expand Down
File renamed without changes
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { PropsWithClassName, PropsWithTestId } from '@leanstacks/react-common';
import { Outlet } from 'react-router-dom';

import Header from 'components/Header/Header';
import Footer from 'components/Footer/Footer';
import Toasts from 'components/Toast/Toasts';
import Header from 'common/components/Header/Header';
import Footer from 'common/components/Footer/Footer';
import Toasts from 'common/components/Toast/Toasts';

/**
* Properties for the `StandardLayout` component.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import classNames from 'classnames';
import { BaseComponentProps } from '@leanstacks/react-common';

import FAIcon, { FAIconProps } from 'components/Icon/FAIcon';
import FAIcon, { FAIconProps } from 'common/components/Icon/FAIcon';

/**
* Properties for the `LoaderSpinner` component.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { ButtonVariant, PropsWithClassName, PropsWithTestId } from '@leanstacks/
import classNames from 'classnames';

import { MenuProps } from './Menu';
import Button from 'components/Button/Button';
import FAIcon from 'components/Icon/FAIcon';
import Button from 'common/components/Button/Button';
import FAIcon from 'common/components/Icon/FAIcon';

/**
* Properties for the `MenuButton` component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ButtonVariant, PropsWithClassName, PropsWithTestId } from '@leanstacks/react-common';
import classNames from 'classnames';

import Button from 'components/Button/Button';
import FAIcon from 'components/Icon/FAIcon';
import Button from 'common/components/Button/Button';
import FAIcon from 'common/components/Icon/FAIcon';

/**
* Properties for the `MenuCloseButton` component.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NavLink, NavLinkProps } from 'react-router-dom';
import { PropsWithTestId } from '@leanstacks/react-common';
import classNames from 'classnames';

import FAIcon, { FAIconProps } from 'components/Icon/FAIcon';
import FAIcon, { FAIconProps } from 'common/components/Icon/FAIcon';

/**
* Properties for the `MenuNavLink` component.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useAuth } from 'hooks/useAuth';
import { useAuth } from 'common/hooks/useAuth';
import { Navigate, Outlet } from 'react-router-dom';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Navigate, RouteObject, createBrowserRouter } from 'react-router-dom';

import StandardLayout from 'components/Layout/StandardLayout';
import StandardLayout from 'common/components/Layout/StandardLayout';
import ErrorPage from 'pages/ErrorPage/ErrorPage';
import PrivateOutlet from './PrivateOutlet';
import LandingPage from 'pages/LandingPage/LandingPage';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
import { Navigate, Route, Routes } from 'react-router-dom';

import { render, screen } from 'test/test-utils';
import * as UseAuth from 'hooks/useAuth';
import * as UseAuth from 'common/hooks/useAuth';

import PrivateOutlet from '../PrivateOutlet';

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { PropsWithTestId } from '@leanstacks/react-common';
import { useSearchParams } from 'react-router-dom';
import classNames from 'classnames';

import { toNumberBetween } from 'utils/numbers';
import { SearchParam } from 'utils/constants';
import { toNumberBetween } from 'common/utils/numbers';
import { SearchParam } from 'common/utils/constants';
import Tab, { TabProps } from './Tab';
import TabContent, { TabContentProps } from './TabContent';

Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit fc71601

Please sign in to comment.