From 8000df963ba50613cd23f336e70c7936de8efcbd Mon Sep 17 00:00:00 2001 From: Jono M Date: Wed, 2 Aug 2023 08:37:51 +0100 Subject: [PATCH] Temporarily fixed eslint rules being disabled in AdminX (#17565) no issue --- apps/admin-x-settings/.eslintrc.cjs | 83 +++++++++++++++++++ apps/admin-x-settings/src/App.tsx | 16 ++-- .../experimental/Tasklist.stories.tsx | 2 +- .../src/admin-x-ds/global/Button.tsx | 2 +- .../src/admin-x-ds/global/Icon.tsx | 2 +- .../src/admin-x-ds/global/List.stories.tsx | 4 +- .../admin-x-ds/global/ListItem.stories.tsx | 4 +- .../src/admin-x-ds/global/Menu.stories.tsx | 4 +- .../global/SortableList.stories.tsx | 10 +-- .../global/StickyFooter.stories.tsx | 4 +- .../src/admin-x-ds/global/Table.stories.tsx | 4 +- .../src/admin-x-ds/global/Toast.stories.tsx | 6 +- .../src/admin-x-ds/global/Toast.tsx | 2 +- .../global/chrome/DesktopChrome.stories.tsx | 4 +- .../global/chrome/MobileChrome.stories.tsx | 4 +- .../global/form/Checkbox.stories.tsx | 4 +- .../src/admin-x-ds/global/form/HtmlEditor.tsx | 2 +- .../src/admin-x-ds/global/form/HtmlField.tsx | 2 +- .../global/form/ImageUpload.stories.tsx | 4 +- .../admin-x-ds/global/form/Radio.stories.tsx | 6 +- .../admin-x-ds/global/form/Select.stories.tsx | 8 +- .../src/admin-x-ds/global/form/Select.tsx | 2 +- .../global/form/TextArea.stories.tsx | 6 +- .../global/form/TextField.stories.tsx | 6 +- .../src/admin-x-ds/global/form/TextField.tsx | 2 +- .../admin-x-ds/global/form/Toggle.stories.tsx | 4 +- .../modal/ConfirmationModal.stories.tsx | 4 +- .../admin-x-ds/global/modal/Modal.stories.tsx | 4 +- .../global/modal/PreviewModal.stories.tsx | 6 +- .../settings/SettingGroup.stories.tsx | 4 +- .../settings/SettingSection.stories.tsx | 4 +- .../src/admin-x-ds/settings/StripeButton.tsx | 2 +- .../components/providers/RoutingProvider.tsx | 62 +++++++------- .../components/settings/email/Newsletters.tsx | 4 +- .../newsletters/NewsletterDetailModal.tsx | 20 ++--- .../email/newsletters/NewsletterPreview.tsx | 10 +-- .../email/newsletters/NewslettersList.tsx | 2 +- .../settings/general/InviteUserModal.tsx | 8 +- .../settings/general/SocialAccounts.tsx | 4 +- .../components/settings/general/Twitter.tsx | 6 +- .../settings/general/UserDetailModal.tsx | 24 +++--- .../components/settings/membership/Tiers.tsx | 14 ++-- .../membership/portal/PortalFrame.tsx | 6 +- .../membership/portal/SignupOptions.tsx | 10 +-- .../membership/stripe/StripeConnectModal.tsx | 44 +++++----- .../membership/tiers/TierDetailModal.tsx | 18 ++-- .../settings/membership/tiers/TiersList.tsx | 8 +- .../components/settings/site/DesignModal.tsx | 18 ++-- .../components/settings/site/ThemeModal.tsx | 10 +-- .../site/designAndBranding/ThemeSettings.tsx | 8 +- apps/admin-x-settings/src/hooks/useForm.ts | 2 +- .../src/hooks/useSettings.tsx | 8 +- .../src/utils/api/customThemeSettings.ts | 4 +- .../admin-x-settings/src/utils/api/invites.ts | 2 +- .../admin-x-settings/src/utils/api/members.ts | 4 +- .../src/utils/api/newsletters.ts | 4 +- .../src/utils/api/settings.ts | 4 +- apps/admin-x-settings/src/utils/api/themes.ts | 4 +- apps/admin-x-settings/src/utils/api/tiers.ts | 4 +- apps/admin-x-settings/src/utils/api/users.ts | 6 +- .../admin-x-settings/src/utils/apiRequests.ts | 14 ++-- .../test/e2e/membership/tiers.test.ts | 20 ++--- .../test/e2e/site/theme.test.ts | 4 +- apps/admin-x-settings/test/utils/e2e.ts | 30 +++---- 64 files changed, 345 insertions(+), 262 deletions(-) diff --git a/apps/admin-x-settings/.eslintrc.cjs b/apps/admin-x-settings/.eslintrc.cjs index 2f13138b49..b388190d85 100644 --- a/apps/admin-x-settings/.eslintrc.cjs +++ b/apps/admin-x-settings/.eslintrc.cjs @@ -17,6 +17,89 @@ module.exports = { } }, rules: { + // ---------------------- + // Rules COPIED from base config, remove these when the config is fixed + + // Style Rules + // Require 4 spaces + indent: ['error', 4], + // Require single quotes for strings & properties (allows template literals) + quotes: ['error', 'single', {allowTemplateLiterals: true}], + 'quote-props': ['error', 'as-needed'], + // Require semi colons, always at the end of a line + semi: ['error', 'always'], + 'semi-style': ['error', 'last'], + // Don't allow dangling commas + 'comma-dangle': ['error', 'never'], + // Always require curly braces, and position them at the end and beginning of lines + curly: 'error', + 'brace-style': ['error', '1tbs'], + // Don't allow padding inside of blocks + 'padded-blocks': ['error', 'never'], + // Require objects to be consistently formatted with newlines + 'object-curly-newline': ['error', {consistent: true}], + // Don't allow more than 1 consecutive empty line or an empty 1st line + 'no-multiple-empty-lines': ['error', {max: 1, maxBOF: 0}], + // Variables must be camelcase, but properties are not checked + camelcase: ['error', {properties: 'never'}], + // Allow newlines before dots, not after e.g. .then goes on a new line + 'dot-location': ['error', 'property'], + // Prefer dot notation over array notation + 'dot-notation': ['error'], + + // Spacing rules + // Don't allow multiple spaces anywhere + 'no-multi-spaces': 'error', + // Anonymous functions have a sape, named functions never do + 'space-before-function-paren': ['error', {anonymous: 'always', named: 'never'}], + // Don't put spaces inside of objects or arrays + 'object-curly-spacing': ['error', 'never'], + 'array-bracket-spacing': ['error', 'never'], + // Allow a max of one space between colons and values + 'key-spacing': ['error', {mode: 'strict'}], + // Require spaces before and after keywords like if, else, try, catch etc + 'keyword-spacing': 'error', + // No spaces around semis + 'semi-spacing': 'error', + // 1 space around arrows + 'arrow-spacing': 'error', + // Don't allow spaces inside parenthesis + 'space-in-parens': ['error', 'never'], + // Require single spaces either side of operators + 'space-unary-ops': 'error', + 'space-infix-ops': 'error', + + // Best practice rules + // Require === / !== + eqeqeq: ['error', 'always'], + // Don't allow ++ and -- + 'no-plusplus': ['error', {allowForLoopAfterthoughts: true}], + // Don't allow eval + 'no-eval': 'error', + // Throw errors for unnecessary usage of .call or .apply + 'no-useless-call': 'error', + // Don't allow console.* calls + 'no-console': 'error', + // Prevent [variable shadowing](https://en.wikipedia.org/wiki/Variable_shadowing) + 'no-shadow': ['error'], + + // Return rules + // Prevent missing return statements in array functions like map & reduce + 'array-callback-return': 'error', + 'no-constructor-return': 'error', + 'no-promise-executor-return': 'error', + + // Arrow function styles + // Do not enforce single lines when using arrow functions. + // https://eslint.org/docs/rules/arrow-body-style + 'arrow-body-style': 'off', + 'arrow-parens': ['error', 'as-needed', {requireForBlockBody: true}], + 'implicit-arrow-linebreak': 'error', + 'no-confusing-arrow': 'error', + + // ---------------------- + // Rules NOT COPIED from base config, keep these + // sort multiple import lines into alphabetical groups 'ghost/sort-imports-es6-autofix/sort-imports-es6': ['error', { memberSyntaxSortOrder: ['none', 'all', 'single', 'multiple'] diff --git a/apps/admin-x-settings/src/App.tsx b/apps/admin-x-settings/src/App.tsx index adbe86f618..b09ebb6d49 100644 --- a/apps/admin-x-settings/src/App.tsx +++ b/apps/admin-x-settings/src/App.tsx @@ -5,11 +5,11 @@ import NiceModal from '@ebay/nice-modal-react'; import RoutingProvider from './components/providers/RoutingProvider'; import Settings from './components/Settings'; import Sidebar from './components/Sidebar'; -import { GlobalDirtyStateProvider } from './hooks/useGlobalDirtyState'; -import { OfficialTheme } from './models/themes'; -import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; -import { ServicesProvider } from './components/providers/ServiceProvider'; -import { Toaster } from 'react-hot-toast'; +import {GlobalDirtyStateProvider} from './hooks/useGlobalDirtyState'; +import {OfficialTheme} from './models/themes'; +import {QueryClient, QueryClientProvider} from '@tanstack/react-query'; +import {ServicesProvider} from './components/providers/ServiceProvider'; +import {Toaster} from 'react-hot-toast'; interface AppProps { ghostVersion: string; @@ -26,9 +26,9 @@ function App({ghostVersion, officialThemes}: AppProps) {
diff --git a/apps/admin-x-settings/src/admin-x-ds/experimental/Tasklist.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/experimental/Tasklist.stories.tsx index 7e0ed38a7f..e07cb3ed48 100644 --- a/apps/admin-x-settings/src/admin-x-ds/experimental/Tasklist.stories.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/experimental/Tasklist.stories.tsx @@ -1,5 +1,5 @@ import TaskList from './Tasklist'; -import { ReactNode } from 'react'; +import {ReactNode} from 'react'; import * as TaskStories from './Task.stories'; diff --git a/apps/admin-x-settings/src/admin-x-ds/global/Button.tsx b/apps/admin-x-settings/src/admin-x-ds/global/Button.tsx index 752935dc3b..367d8ee937 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/Button.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/Button.tsx @@ -1,5 +1,5 @@ import Icon from './Icon'; -import React, { HTMLProps } from 'react'; +import React, {HTMLProps} from 'react'; export type ButtonColor = 'clear' | 'grey' | 'black' | 'green' | 'red' | 'white' | 'outline'; export type ButtonSize = 'sm' | 'md'; diff --git a/apps/admin-x-settings/src/admin-x-ds/global/Icon.tsx b/apps/admin-x-settings/src/admin-x-ds/global/Icon.tsx index 424571539a..f121db5491 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/Icon.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/Icon.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, {useEffect, useState} from 'react'; import clsx from 'clsx'; interface UseDynamicSVGImportOptions { diff --git a/apps/admin-x-settings/src/admin-x-ds/global/List.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/global/List.stories.tsx index 318c74f05e..b8cd791ced 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/List.stories.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/List.stories.tsx @@ -1,9 +1,9 @@ -import type { Meta, StoryObj } from '@storybook/react'; +import type {Meta, StoryObj} from '@storybook/react'; import * as ListItemStories from './ListItem.stories'; import List from './List'; import ListItem from './ListItem'; -import { ReactNode } from 'react'; +import {ReactNode} from 'react'; const meta = { title: 'Global / List', diff --git a/apps/admin-x-settings/src/admin-x-ds/global/ListItem.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/global/ListItem.stories.tsx index f43812eeed..35cfa96a65 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/ListItem.stories.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/ListItem.stories.tsx @@ -1,5 +1,5 @@ -import React, { ReactNode } from 'react'; -import type { Meta, StoryObj } from '@storybook/react'; +import React, {ReactNode} from 'react'; +import type {Meta, StoryObj} from '@storybook/react'; import Avatar from './Avatar'; import Button from './Button'; diff --git a/apps/admin-x-settings/src/admin-x-ds/global/Menu.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/global/Menu.stories.tsx index 143bd79fdc..6ea3b5f8b8 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/Menu.stories.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/Menu.stories.tsx @@ -1,5 +1,5 @@ -import { ReactNode } from 'react'; -import type { Meta, StoryObj } from '@storybook/react'; +import {ReactNode} from 'react'; +import type {Meta, StoryObj} from '@storybook/react'; import Button from './Button'; import Menu from './Menu'; diff --git a/apps/admin-x-settings/src/admin-x-ds/global/SortableList.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/global/SortableList.stories.tsx index af381eef42..8447aaa44e 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/SortableList.stories.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/SortableList.stories.tsx @@ -1,10 +1,10 @@ -import { useArgs } from '@storybook/preview-api'; -import type { Meta, StoryObj } from '@storybook/react'; +import {useArgs} from '@storybook/preview-api'; +import type {Meta, StoryObj} from '@storybook/react'; -import SortableList, { SortableListProps } from './SortableList'; +import SortableList, {SortableListProps} from './SortableList'; import clsx from 'clsx'; -import { arrayMove } from '@dnd-kit/sortable'; -import { useState } from 'react'; +import {arrayMove} from '@dnd-kit/sortable'; +import {useState} from 'react'; const Wrapper = (props: SortableListProps<{id: string}> & {updateArgs: (args: Partial>) => void}) => { // Seems like Storybook recreates items on every render, so we need to keep our own state diff --git a/apps/admin-x-settings/src/admin-x-ds/global/StickyFooter.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/global/StickyFooter.stories.tsx index 6e455b8dfa..83a5bac106 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/StickyFooter.stories.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/StickyFooter.stories.tsx @@ -1,5 +1,5 @@ -import { ReactNode } from 'react'; -import type { Meta, StoryObj } from '@storybook/react'; +import {ReactNode} from 'react'; +import type {Meta, StoryObj} from '@storybook/react'; import StickyFooter from './StickyFooter'; diff --git a/apps/admin-x-settings/src/admin-x-ds/global/Table.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/global/Table.stories.tsx index 301d8a58cf..fade7cee09 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/Table.stories.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/Table.stories.tsx @@ -1,5 +1,5 @@ -import { ReactNode } from 'react'; -import type { Meta, StoryObj } from '@storybook/react'; +import {ReactNode} from 'react'; +import type {Meta, StoryObj} from '@storybook/react'; import Table from './Table'; import TableCell from './TableCell'; diff --git a/apps/admin-x-settings/src/admin-x-ds/global/Toast.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/global/Toast.stories.tsx index 42798ac19a..f806ef499c 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/Toast.stories.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/Toast.stories.tsx @@ -1,8 +1,8 @@ -import { ReactNode } from 'react'; -import type { Meta, StoryObj } from '@storybook/react'; +import {ReactNode} from 'react'; +import type {Meta, StoryObj} from '@storybook/react'; import ToastContainer from './ToastContainer'; -import { Toaster } from 'react-hot-toast'; +import {Toaster} from 'react-hot-toast'; const meta = { title: 'Global / Toast', diff --git a/apps/admin-x-settings/src/admin-x-ds/global/Toast.tsx b/apps/admin-x-settings/src/admin-x-ds/global/Toast.tsx index a51490074c..42af1b5899 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/Toast.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/Toast.tsx @@ -1,7 +1,7 @@ import Icon from './Icon'; import React from 'react'; import clsx from 'clsx'; -import { Toast as HotToast, ToastOptions, toast } from 'react-hot-toast'; +import {Toast as HotToast, ToastOptions, toast} from 'react-hot-toast'; export type ToastType = 'neutral' | 'success' | 'error' | 'pageError'; diff --git a/apps/admin-x-settings/src/admin-x-ds/global/chrome/DesktopChrome.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/global/chrome/DesktopChrome.stories.tsx index e4ed1565e9..1c1cd98f91 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/chrome/DesktopChrome.stories.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/chrome/DesktopChrome.stories.tsx @@ -1,5 +1,5 @@ -import { ReactNode } from 'react'; -import type { Meta, StoryObj } from '@storybook/react'; +import {ReactNode} from 'react'; +import type {Meta, StoryObj} from '@storybook/react'; import DesktopChrome from './DesktopChrome'; diff --git a/apps/admin-x-settings/src/admin-x-ds/global/chrome/MobileChrome.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/global/chrome/MobileChrome.stories.tsx index d0432309c5..ecf7dc0b1d 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/chrome/MobileChrome.stories.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/chrome/MobileChrome.stories.tsx @@ -1,5 +1,5 @@ -import { ReactNode } from 'react'; -import type { Meta, StoryObj } from '@storybook/react'; +import {ReactNode} from 'react'; +import type {Meta, StoryObj} from '@storybook/react'; import MobileChrome from './MobileChrome'; diff --git a/apps/admin-x-settings/src/admin-x-ds/global/form/Checkbox.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/global/form/Checkbox.stories.tsx index 114d9c554d..f06f3a3d0f 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/form/Checkbox.stories.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/form/Checkbox.stories.tsx @@ -1,5 +1,5 @@ -import { ReactNode } from 'react'; -import type { Meta, StoryObj } from '@storybook/react'; +import {ReactNode} from 'react'; +import type {Meta, StoryObj} from '@storybook/react'; import Checkbox from './Checkbox'; diff --git a/apps/admin-x-settings/src/admin-x-ds/global/form/HtmlEditor.tsx b/apps/admin-x-settings/src/admin-x-ds/global/form/HtmlEditor.tsx index 646e083aae..356721d050 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/form/HtmlEditor.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/form/HtmlEditor.tsx @@ -1,4 +1,4 @@ -import React, { ReactNode, Suspense, useCallback, useMemo } from 'react'; +import React, {ReactNode, Suspense, useCallback, useMemo} from 'react'; export interface HtmlEditorProps { value?: string diff --git a/apps/admin-x-settings/src/admin-x-ds/global/form/HtmlField.tsx b/apps/admin-x-settings/src/admin-x-ds/global/form/HtmlField.tsx index 1ce3fc595e..3134441e3a 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/form/HtmlField.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/form/HtmlField.tsx @@ -1,6 +1,6 @@ import Heading from '../Heading'; import Hint from '../Hint'; -import HtmlEditor, { HtmlEditorProps } from './HtmlEditor'; +import HtmlEditor, {HtmlEditorProps} from './HtmlEditor'; import React from 'react'; import clsx from 'clsx'; diff --git a/apps/admin-x-settings/src/admin-x-ds/global/form/ImageUpload.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/global/form/ImageUpload.stories.tsx index 673ab05618..a987ce2ecb 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/form/ImageUpload.stories.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/form/ImageUpload.stories.tsx @@ -1,5 +1,5 @@ -import { ReactNode } from 'react'; -import type { Meta, StoryObj } from '@storybook/react'; +import {ReactNode} from 'react'; +import type {Meta, StoryObj} from '@storybook/react'; import ImageUpload from './ImageUpload'; diff --git a/apps/admin-x-settings/src/admin-x-ds/global/form/Radio.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/global/form/Radio.stories.tsx index 6f079f9bd0..ee3bfd65a2 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/form/Radio.stories.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/form/Radio.stories.tsx @@ -1,7 +1,7 @@ -import { ReactNode } from 'react'; -import type { Meta, StoryObj } from '@storybook/react'; +import {ReactNode} from 'react'; +import type {Meta, StoryObj} from '@storybook/react'; -import Radio, { RadioOption } from './Radio'; +import Radio, {RadioOption} from './Radio'; const meta = { title: 'Global / Form / Radio', diff --git a/apps/admin-x-settings/src/admin-x-ds/global/form/Select.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/global/form/Select.stories.tsx index 76109ab859..baf27fcf34 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/form/Select.stories.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/form/Select.stories.tsx @@ -1,8 +1,8 @@ -import { ReactNode } from 'react'; -import { useArgs } from '@storybook/preview-api'; -import type { Meta, StoryObj } from '@storybook/react'; +import {ReactNode} from 'react'; +import {useArgs} from '@storybook/preview-api'; +import type {Meta, StoryObj} from '@storybook/react'; -import Select, { SelectOption } from './Select'; +import Select, {SelectOption} from './Select'; const meta = { title: 'Global / Form / Select', diff --git a/apps/admin-x-settings/src/admin-x-ds/global/form/Select.tsx b/apps/admin-x-settings/src/admin-x-ds/global/form/Select.tsx index a44034af06..d321b198e3 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/form/Select.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/form/Select.tsx @@ -1,4 +1,4 @@ -import React, { useId } from 'react'; +import React, {useId} from 'react'; import Heading from '../Heading'; import Hint from '../Hint'; diff --git a/apps/admin-x-settings/src/admin-x-ds/global/form/TextArea.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/global/form/TextArea.stories.tsx index 7b7bfced39..c9be2b8f35 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/form/TextArea.stories.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/form/TextArea.stories.tsx @@ -1,6 +1,6 @@ -import { ReactNode } from 'react'; -import { useArgs } from '@storybook/preview-api'; -import type { Meta, StoryObj } from '@storybook/react'; +import {ReactNode} from 'react'; +import {useArgs} from '@storybook/preview-api'; +import type {Meta, StoryObj} from '@storybook/react'; import TextArea from './TextArea'; diff --git a/apps/admin-x-settings/src/admin-x-ds/global/form/TextField.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/global/form/TextField.stories.tsx index 0a48d87429..e22ad00b1e 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/form/TextField.stories.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/form/TextField.stories.tsx @@ -1,6 +1,6 @@ -import { ReactNode } from 'react'; -import { useArgs } from '@storybook/preview-api'; -import type { Meta, StoryObj } from '@storybook/react'; +import {ReactNode} from 'react'; +import {useArgs} from '@storybook/preview-api'; +import type {Meta, StoryObj} from '@storybook/react'; import TextField from './TextField'; diff --git a/apps/admin-x-settings/src/admin-x-ds/global/form/TextField.tsx b/apps/admin-x-settings/src/admin-x-ds/global/form/TextField.tsx index 099e2657ca..189a330e61 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/form/TextField.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/form/TextField.tsx @@ -93,7 +93,7 @@ const TextField: React.FC = ({ return (
{field} - {title && {title}} + {title && {title}} {hint && {hint}}
); diff --git a/apps/admin-x-settings/src/admin-x-ds/global/form/Toggle.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/global/form/Toggle.stories.tsx index 567cf031cd..68a9b131b4 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/form/Toggle.stories.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/form/Toggle.stories.tsx @@ -1,5 +1,5 @@ -import { ReactNode } from 'react'; -import type { Meta, StoryObj } from '@storybook/react'; +import {ReactNode} from 'react'; +import type {Meta, StoryObj} from '@storybook/react'; import Toggle from './Toggle'; diff --git a/apps/admin-x-settings/src/admin-x-ds/global/modal/ConfirmationModal.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/global/modal/ConfirmationModal.stories.tsx index 01a0619b50..3355112e85 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/modal/ConfirmationModal.stories.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/modal/ConfirmationModal.stories.tsx @@ -1,5 +1,5 @@ -import { ReactNode } from 'react'; -import type { Meta, StoryContext, StoryObj } from '@storybook/react'; +import {ReactNode} from 'react'; +import type {Meta, StoryContext, StoryObj} from '@storybook/react'; import ConfirmationModal from './ConfirmationModal'; import ConfirmationModalContainer from './ConfirmationModalContainer'; diff --git a/apps/admin-x-settings/src/admin-x-ds/global/modal/Modal.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/global/modal/Modal.stories.tsx index 98dcb5f26c..912f7a2c35 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/modal/Modal.stories.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/modal/Modal.stories.tsx @@ -1,5 +1,5 @@ -import { ReactNode } from 'react'; -import type { Meta, StoryContext, StoryObj } from '@storybook/react'; +import {ReactNode} from 'react'; +import type {Meta, StoryContext, StoryObj} from '@storybook/react'; import Modal from './Modal'; import ModalContainer from './ModalContainer'; diff --git a/apps/admin-x-settings/src/admin-x-ds/global/modal/PreviewModal.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/global/modal/PreviewModal.stories.tsx index 09d4e2a4a1..e4c2c8ada2 100644 --- a/apps/admin-x-settings/src/admin-x-ds/global/modal/PreviewModal.stories.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/global/modal/PreviewModal.stories.tsx @@ -1,11 +1,11 @@ -import { ReactNode } from 'react'; -import type { Meta, StoryContext, StoryObj } from '@storybook/react'; +import {ReactNode} from 'react'; +import type {Meta, StoryContext, StoryObj} from '@storybook/react'; import Heading from '../Heading'; import NiceModal from '@ebay/nice-modal-react'; import PreviewModal from './PreviewModal'; import PreviewModalContainer from './PreviewModalContainer'; -import { Tab } from '../TabView'; +import {Tab} from '../TabView'; const meta = { title: 'Global / Modal / Preview Modal', diff --git a/apps/admin-x-settings/src/admin-x-ds/settings/SettingGroup.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/settings/SettingGroup.stories.tsx index 8921e213ab..2891cdfcee 100644 --- a/apps/admin-x-settings/src/admin-x-ds/settings/SettingGroup.stories.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/settings/SettingGroup.stories.tsx @@ -1,5 +1,5 @@ -import { ReactNode } from 'react'; -import type { Meta, StoryObj } from '@storybook/react'; +import {ReactNode} from 'react'; +import type {Meta, StoryObj} from '@storybook/react'; import * as SettingGroupContentStories from './SettingGroupContent.stories'; import * as SettingGroupHeaderStories from './SettingGroupHeader.stories'; diff --git a/apps/admin-x-settings/src/admin-x-ds/settings/SettingSection.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/settings/SettingSection.stories.tsx index bd6b6c8625..36081df7d9 100644 --- a/apps/admin-x-settings/src/admin-x-ds/settings/SettingSection.stories.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/settings/SettingSection.stories.tsx @@ -1,5 +1,5 @@ -import { ReactNode } from 'react'; -import type { Meta, StoryObj } from '@storybook/react'; +import {ReactNode} from 'react'; +import type {Meta, StoryObj} from '@storybook/react'; import * as SettingGroupStories from './SettingGroup.stories'; import SettingGroup from './SettingGroup'; diff --git a/apps/admin-x-settings/src/admin-x-ds/settings/StripeButton.tsx b/apps/admin-x-settings/src/admin-x-ds/settings/StripeButton.tsx index ef89a3ae81..dc22cbaef3 100644 --- a/apps/admin-x-settings/src/admin-x-ds/settings/StripeButton.tsx +++ b/apps/admin-x-settings/src/admin-x-ds/settings/StripeButton.tsx @@ -1,4 +1,4 @@ -import Button, { ButtonProps } from '../global/Button'; +import Button, {ButtonProps} from '../global/Button'; import React from 'react'; import clsx from 'clsx'; diff --git a/apps/admin-x-settings/src/components/providers/RoutingProvider.tsx b/apps/admin-x-settings/src/components/providers/RoutingProvider.tsx index 5e10cd07bb..fab45521e5 100644 --- a/apps/admin-x-settings/src/components/providers/RoutingProvider.tsx +++ b/apps/admin-x-settings/src/components/providers/RoutingProvider.tsx @@ -1,12 +1,12 @@ -import ChangeThemeModal from "../settings/site/ThemeModal"; -import DesignModal from "../settings/site/DesignModal"; -import InviteUserModal from "../settings/general/InviteUserModal"; -import NavigationModal from "../settings/site/NavigationModal"; -import NiceModal from "@ebay/nice-modal-react"; -import PortalModal from "../settings/membership/portal/PortalModal"; -import React, { createContext, useCallback, useEffect, useState } from "react"; -import StripeConnectModal from "../settings/membership/stripe/StripeConnectModal"; -import TierDetailModal from "../settings/membership/tiers/TierDetailModal"; +import ChangeThemeModal from '../settings/site/ThemeModal'; +import DesignModal from '../settings/site/DesignModal'; +import InviteUserModal from '../settings/general/InviteUserModal'; +import NavigationModal from '../settings/site/NavigationModal'; +import NiceModal from '@ebay/nice-modal-react'; +import PortalModal from '../settings/membership/portal/PortalModal'; +import React, {createContext, useCallback, useEffect, useState} from 'react'; +import StripeConnectModal from '../settings/membership/stripe/StripeConnectModal'; +import TierDetailModal from '../settings/membership/tiers/TierDetailModal'; type RoutingContextProps = { route: string; @@ -17,11 +17,11 @@ type RoutingContextProps = { }; export const RouteContext = createContext({ - route: "", - scrolledRoute: "", + route: '', + scrolledRoute: '', yScroll: 0, updateRoute: () => {}, - updateScrolled: () => {}, + updateScrolled: () => {} }); function getHashPath(urlPath: string | undefined) { @@ -41,7 +41,7 @@ function getHashPath(urlPath: string | undefined) { const scrollToSectionGroup = (pathName: string) => { const element = document.getElementById(pathName); if (element) { - element.scrollIntoView({ behavior: "smooth" }); + element.scrollIntoView({behavior: 'smooth'}); } }; @@ -56,19 +56,19 @@ const handleNavigation = (scroll: boolean = true) => { const pathName = getHashPath(hash); if (pathName) { - if (pathName === "design/edit/themes") { + if (pathName === 'design/edit/themes') { NiceModal.show(ChangeThemeModal); - } else if (pathName === "design/edit") { + } else if (pathName === 'design/edit') { NiceModal.show(DesignModal); - } else if (pathName === "navigation/edit") { + } else if (pathName === 'navigation/edit') { NiceModal.show(NavigationModal); - } else if (pathName === "users/invite") { + } else if (pathName === 'users/invite') { NiceModal.show(InviteUserModal); - } else if (pathName === "portal/edit") { + } else if (pathName === 'portal/edit') { NiceModal.show(PortalModal); - } else if (pathName === "tiers/add") { + } else if (pathName === 'tiers/add') { NiceModal.show(TierDetailModal); - } else if (pathName === "stripe-connect") { + } else if (pathName === 'stripe-connect') { NiceModal.show(StripeConnectModal); } @@ -78,17 +78,17 @@ const handleNavigation = (scroll: boolean = true) => { return pathName; } - return ""; + return ''; }; type RouteProviderProps = { children: React.ReactNode; }; -const RoutingProvider: React.FC = ({ children }) => { - const [route, setRoute] = useState(""); +const RoutingProvider: React.FC = ({children}) => { + const [route, setRoute] = useState(''); const [yScroll, setYScroll] = useState(0); - const [scrolledRoute, setScrolledRoute] = useState(""); + const [scrolledRoute, setScrolledRoute] = useState(''); const updateRoute = useCallback( (newPath: string) => { @@ -116,21 +116,21 @@ const RoutingProvider: React.FC = ({ children }) => { }; const handleScroll = () => { - const element = document.getElementById("admin-x-root"); + const element = document.getElementById('admin-x-root'); const scrollPosition = element!.scrollTop; setYScroll(scrollPosition); }; - const element = document.getElementById("admin-x-root"); + const element = document.getElementById('admin-x-root'); const matchedRoute = handleNavigation(); setRoute(matchedRoute); - element!.addEventListener("scroll", handleScroll); + element!.addEventListener('scroll', handleScroll); - window.addEventListener("hashchange", handleHashChange); + window.addEventListener('hashchange', handleHashChange); return () => { - element!.removeEventListener("scroll", handleScroll); - window.removeEventListener("hashchange", handleHashChange); + element!.removeEventListener('scroll', handleScroll); + window.removeEventListener('hashchange', handleHashChange); }; }, []); @@ -141,7 +141,7 @@ const RoutingProvider: React.FC = ({ children }) => { scrolledRoute, yScroll, updateRoute, - updateScrolled, + updateScrolled }} > {children} diff --git a/apps/admin-x-settings/src/components/settings/email/Newsletters.tsx b/apps/admin-x-settings/src/components/settings/email/Newsletters.tsx index 18481e4645..f5d489617a 100644 --- a/apps/admin-x-settings/src/components/settings/email/Newsletters.tsx +++ b/apps/admin-x-settings/src/components/settings/email/Newsletters.tsx @@ -1,10 +1,10 @@ import Button from '../../../admin-x-ds/global/Button'; import NewslettersList from './newsletters/NewslettersList'; -import React, { useState } from 'react'; +import React, {useState} from 'react'; import SettingGroup from '../../../admin-x-ds/settings/SettingGroup'; import TabView from '../../../admin-x-ds/global/TabView'; import useRouting from '../../../hooks/useRouting'; -import { useBrowseNewsletters } from '../../../utils/api/newsletters'; +import {useBrowseNewsletters} from '../../../utils/api/newsletters'; const Newsletters: React.FC<{ keywords: string[] }> = ({keywords}) => { const {updateRoute} = useRouting(); diff --git a/apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx b/apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx index bd7aa76fee..45c2c3b5b3 100644 --- a/apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx +++ b/apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx @@ -1,5 +1,5 @@ import Form from '../../../../admin-x-ds/global/form/Form'; -import NiceModal, { useModal } from '@ebay/nice-modal-react'; +import NiceModal, {useModal} from '@ebay/nice-modal-react'; import ButtonGroup from '../../../../admin-x-ds/global/ButtonGroup'; import Heading from '../../../../admin-x-ds/global/Heading'; @@ -7,20 +7,20 @@ import Hint from '../../../../admin-x-ds/global/Hint'; import Icon from '../../../../admin-x-ds/global/Icon'; import ImageUpload from '../../../../admin-x-ds/global/form/ImageUpload'; import NewsletterPreview from './NewsletterPreview'; -import React, { useState } from 'react'; -import Select, { SelectOption } from '../../../../admin-x-ds/global/form/Select'; +import React, {useState} from 'react'; +import Select, {SelectOption} from '../../../../admin-x-ds/global/form/Select'; import StickyFooter from '../../../../admin-x-ds/global/StickyFooter'; -import TabView, { Tab } from '../../../../admin-x-ds/global/TabView'; +import TabView, {Tab} from '../../../../admin-x-ds/global/TabView'; import TextArea from '../../../../admin-x-ds/global/form/TextArea'; import TextField from '../../../../admin-x-ds/global/form/TextField'; import Toggle from '../../../../admin-x-ds/global/form/Toggle'; import useForm from '../../../../hooks/useForm'; import useSettings from '../../../../hooks/useSettings'; -import { Newsletter } from '../../../../types/api'; -import { PreviewModalContent } from '../../../../admin-x-ds/global/modal/PreviewModal'; -import { fullEmailAddress, getSettingValues } from '../../../../utils/helpers'; -import { getImageUrl, useUploadImage } from '../../../../utils/api/images'; -import { useEditNewsletter } from '../../../../utils/api/newsletters'; +import {Newsletter} from '../../../../types/api'; +import {PreviewModalContent} from '../../../../admin-x-ds/global/modal/PreviewModal'; +import {fullEmailAddress, getSettingValues} from '../../../../utils/helpers'; +import {getImageUrl, useUploadImage} from '../../../../utils/api/images'; +import {useEditNewsletter} from '../../../../utils/api/newsletters'; interface NewsletterDetailModalProps { newsletter: Newsletter @@ -248,7 +248,7 @@ const NewsletterDetailModal: React.FC = ({newsletter await editNewsletter(formState); modal.remove(); } - }) + }); const updateNewsletter = (fields: Partial) => { updateForm(state => ({...state, ...fields})); diff --git a/apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterPreview.tsx b/apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterPreview.tsx index 6e24f37d49..015028baf8 100644 --- a/apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterPreview.tsx +++ b/apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterPreview.tsx @@ -6,10 +6,10 @@ import LatestPosts3 from '../../../../assets/images/latest-posts-3.png'; import React from 'react'; import clsx from 'clsx'; import useSettings from '../../../../hooks/useSettings'; -import { ReactComponent as GhostOrb } from '../../../../admin-x-ds/assets/images/ghost-orb.svg'; -import { Newsletter } from '../../../../types/api'; -import { fullEmailAddress, getSettingValues } from '../../../../utils/helpers'; -import { useGlobalData } from '../../../providers/DataProvider'; +import {ReactComponent as GhostOrb} from '../../../../admin-x-ds/assets/images/ghost-orb.svg'; +import {Newsletter} from '../../../../types/api'; +import {fullEmailAddress, getSettingValues} from '../../../../utils/helpers'; +import {useGlobalData} from '../../../providers/DataProvider'; const NewsletterPreview: React.FC<{newsletter: Newsletter}> = ({newsletter}) => { const {currentUser} = useGlobalData(); @@ -35,7 +35,7 @@ const NewsletterPreview: React.FC<{newsletter: Newsletter}> = ({newsletter}) => const currentYear = new Date().getFullYear(); const showCommentCta = newsletter.show_comment_cta && commentsEnabled !== 'off'; - const showFeedback = newsletter.feedback_enabled && config.labs.audienceFeedback + const showFeedback = newsletter.feedback_enabled && config.labs.audienceFeedback; return (
diff --git a/apps/admin-x-settings/src/components/settings/email/newsletters/NewslettersList.tsx b/apps/admin-x-settings/src/components/settings/email/newsletters/NewslettersList.tsx index cbb50d7bca..4de554f73f 100644 --- a/apps/admin-x-settings/src/components/settings/email/newsletters/NewslettersList.tsx +++ b/apps/admin-x-settings/src/components/settings/email/newsletters/NewslettersList.tsx @@ -5,7 +5,7 @@ import React from 'react'; import Table from '../../../../admin-x-ds/global/Table'; import TableCell from '../../../../admin-x-ds/global/TableCell'; import TableRow from '../../../../admin-x-ds/global/TableRow'; -import { Newsletter } from '../../../../types/api'; +import {Newsletter} from '../../../../types/api'; interface NewslettersListProps { tab?: string; diff --git a/apps/admin-x-settings/src/components/settings/general/InviteUserModal.tsx b/apps/admin-x-settings/src/components/settings/general/InviteUserModal.tsx index db5090dfba..f60487bb79 100644 --- a/apps/admin-x-settings/src/components/settings/general/InviteUserModal.tsx +++ b/apps/admin-x-settings/src/components/settings/general/InviteUserModal.tsx @@ -4,10 +4,10 @@ import Radio from '../../../admin-x-ds/global/form/Radio'; import TextField from '../../../admin-x-ds/global/form/TextField'; import useRouting from '../../../hooks/useRouting'; import validator from 'validator'; -import { showToast } from '../../../admin-x-ds/global/Toast'; -import { useAddInvite } from '../../../utils/api/invites'; -import { useBrowseRoles } from '../../../utils/api/roles'; -import { useEffect, useRef, useState } from 'react'; +import {showToast} from '../../../admin-x-ds/global/Toast'; +import {useAddInvite} from '../../../utils/api/invites'; +import {useBrowseRoles} from '../../../utils/api/roles'; +import {useEffect, useRef, useState} from 'react'; type RoleType = 'administrator' | 'editor' | 'author' | 'contributor'; diff --git a/apps/admin-x-settings/src/components/settings/general/SocialAccounts.tsx b/apps/admin-x-settings/src/components/settings/general/SocialAccounts.tsx index c5e5f1146d..7594864539 100644 --- a/apps/admin-x-settings/src/components/settings/general/SocialAccounts.tsx +++ b/apps/admin-x-settings/src/components/settings/general/SocialAccounts.tsx @@ -1,10 +1,10 @@ -import React, { useRef, useState } from 'react'; +import React, {useRef, useState} from 'react'; import SettingGroup from '../../../admin-x-ds/settings/SettingGroup'; import SettingGroupContent from '../../../admin-x-ds/settings/SettingGroupContent'; import TextField from '../../../admin-x-ds/global/form/TextField'; import useSettingGroup from '../../../hooks/useSettingGroup'; import validator from 'validator'; -import { getSettingValues } from '../../../utils/helpers'; +import {getSettingValues} from '../../../utils/helpers'; function validateFacebookUrl(newUrl: string) { const errMessage = 'The URL must be in a format like https://www.facebook.com/yourPage'; diff --git a/apps/admin-x-settings/src/components/settings/general/Twitter.tsx b/apps/admin-x-settings/src/components/settings/general/Twitter.tsx index fb5629ab26..2c2dba75d5 100644 --- a/apps/admin-x-settings/src/components/settings/general/Twitter.tsx +++ b/apps/admin-x-settings/src/components/settings/general/Twitter.tsx @@ -4,9 +4,9 @@ import SettingGroup from '../../../admin-x-ds/settings/SettingGroup'; import SettingGroupContent from '../../../admin-x-ds/settings/SettingGroupContent'; import TextField from '../../../admin-x-ds/global/form/TextField'; import useSettingGroup from '../../../hooks/useSettingGroup'; -import { ReactComponent as TwitterLogo } from '../../../admin-x-ds/assets/images/twitter-logo.svg'; -import { getImageUrl, useUploadImage } from '../../../utils/api/images'; -import { getSettingValues } from '../../../utils/helpers'; +import {ReactComponent as TwitterLogo} from '../../../admin-x-ds/assets/images/twitter-logo.svg'; +import {getImageUrl, useUploadImage} from '../../../utils/api/images'; +import {getSettingValues} from '../../../utils/helpers'; const Twitter: React.FC<{ keywords: string[] }> = ({keywords}) => { const { diff --git a/apps/admin-x-settings/src/components/settings/general/UserDetailModal.tsx b/apps/admin-x-settings/src/components/settings/general/UserDetailModal.tsx index 5bd53445cf..6b0e001972 100644 --- a/apps/admin-x-settings/src/components/settings/general/UserDetailModal.tsx +++ b/apps/admin-x-settings/src/components/settings/general/UserDetailModal.tsx @@ -3,24 +3,24 @@ import ConfirmationModal from '../../../admin-x-ds/global/modal/ConfirmationModa import Heading from '../../../admin-x-ds/global/Heading'; import Icon from '../../../admin-x-ds/global/Icon'; import ImageUpload from '../../../admin-x-ds/global/form/ImageUpload'; -import Menu, { MenuItem } from '../../../admin-x-ds/global/Menu'; +import Menu, {MenuItem} from '../../../admin-x-ds/global/Menu'; import Modal from '../../../admin-x-ds/global/modal/Modal'; -import NiceModal, { useModal } from '@ebay/nice-modal-react'; +import NiceModal, {useModal} from '@ebay/nice-modal-react'; import Radio from '../../../admin-x-ds/global/form/Radio'; -import React, { useEffect, useRef, useState } from 'react'; +import React, {useEffect, useRef, useState} from 'react'; import SettingGroup from '../../../admin-x-ds/settings/SettingGroup'; import SettingGroupContent from '../../../admin-x-ds/settings/SettingGroupContent'; import TextField from '../../../admin-x-ds/global/form/TextField'; import Toggle from '../../../admin-x-ds/global/form/Toggle'; import useStaffUsers from '../../../hooks/useStaffUsers'; import validator from 'validator'; -import { User } from '../../../types/api'; -import { getImageUrl, useUploadImage } from '../../../utils/api/images'; -import { isAdminUser, isOwnerUser } from '../../../utils/helpers'; -import { showToast } from '../../../admin-x-ds/global/Toast'; -import { toast } from 'react-hot-toast'; -import { useBrowseRoles } from '../../../utils/api/roles'; -import { useDeleteUser, useEditUser, useMakeOwner, useUpdatePassword } from '../../../utils/api/users'; +import {User} from '../../../types/api'; +import {getImageUrl, useUploadImage} from '../../../utils/api/images'; +import {isAdminUser, isOwnerUser} from '../../../utils/helpers'; +import {showToast} from '../../../admin-x-ds/global/Toast'; +import {toast} from 'react-hot-toast'; +import {useBrowseRoles} from '../../../utils/api/roles'; +import {useDeleteUser, useEditUser, useMakeOwner, useUpdatePassword} from '../../../utils/api/users'; interface CustomHeadingProps { children?: React.ReactNode; @@ -104,7 +104,7 @@ const BasicInputs: React.FC = ({errors, validators, user, setUs { @@ -633,7 +633,7 @@ const UserDetailModal:React.FC = ({user}) => { if (error) { showToast({ type: 'pageError', - message: "Can't save user! One or more fields have errors, please doublecheck you filled all mandatory fields" + message: 'Can\'t save user! One or more fields have errors, please doublecheck you filled all mandatory fields' }); setSaveState(''); return; diff --git a/apps/admin-x-settings/src/components/settings/membership/Tiers.tsx b/apps/admin-x-settings/src/components/settings/membership/Tiers.tsx index cdf328ba50..68f672baa0 100644 --- a/apps/admin-x-settings/src/components/settings/membership/Tiers.tsx +++ b/apps/admin-x-settings/src/components/settings/membership/Tiers.tsx @@ -1,13 +1,13 @@ import Button from '../../../admin-x-ds/global/Button'; -import React, { useState } from 'react'; +import React, {useState} from 'react'; import SettingGroup from '../../../admin-x-ds/settings/SettingGroup'; import StripeButton from '../../../admin-x-ds/settings/StripeButton'; import TabView from '../../../admin-x-ds/global/TabView'; import TiersList from './tiers/TiersList'; import useRouting from '../../../hooks/useRouting'; -import { Tier } from '../../../types/api'; -import { checkStripeEnabled, getActiveTiers, getArchivedTiers } from '../../../utils/helpers'; -import { useGlobalData } from '../../providers/DataProvider'; +import {Tier} from '../../../types/api'; +import {checkStripeEnabled, getActiveTiers, getArchivedTiers} from '../../../utils/helpers'; +import {useGlobalData} from '../../providers/DataProvider'; const Tiers: React.FC<{ keywords: string[] }> = ({keywords}) => { const [selectedTab, setSelectedTab] = useState('active-tiers'); @@ -44,11 +44,11 @@ const Tiers: React.FC<{ keywords: string[] }> = ({keywords}) => { } ]; - let content + let content; if (checkStripeEnabled(settings, config)) { - content = + content = ; } else { - content = tier.type === 'free')} /> + content = tier.type === 'free')} />; } return ( diff --git a/apps/admin-x-settings/src/components/settings/membership/portal/PortalFrame.tsx b/apps/admin-x-settings/src/components/settings/membership/portal/PortalFrame.tsx index c69a20e889..58694c130a 100644 --- a/apps/admin-x-settings/src/components/settings/membership/portal/PortalFrame.tsx +++ b/apps/admin-x-settings/src/components/settings/membership/portal/PortalFrame.tsx @@ -1,7 +1,7 @@ -import React, { useEffect, useRef, useState } from 'react'; +import React, {useEffect, useRef, useState} from 'react'; import useSettingGroup from '../../../../hooks/useSettingGroup'; -import { Setting, SiteData, Tier } from '../../../../types/api'; -import { getSettingValue } from '../../../../utils/helpers'; +import {Setting, SiteData, Tier} from '../../../../types/api'; +import {getSettingValue} from '../../../../utils/helpers'; type PortalFrameProps = { settings: Setting[]; diff --git a/apps/admin-x-settings/src/components/settings/membership/portal/SignupOptions.tsx b/apps/admin-x-settings/src/components/settings/membership/portal/SignupOptions.tsx index e7957af35b..54fae53b94 100644 --- a/apps/admin-x-settings/src/components/settings/membership/portal/SignupOptions.tsx +++ b/apps/admin-x-settings/src/components/settings/membership/portal/SignupOptions.tsx @@ -1,12 +1,12 @@ import CheckboxGroup from '../../../../admin-x-ds/global/form/CheckboxGroup'; import Form from '../../../../admin-x-ds/global/form/Form'; import HtmlField from '../../../../admin-x-ds/global/form/HtmlField'; -import React, { useEffect, useMemo } from 'react'; +import React, {useEffect, useMemo} from 'react'; import Toggle from '../../../../admin-x-ds/global/form/Toggle'; -import { CheckboxProps } from '../../../../admin-x-ds/global/form/Checkbox'; -import { Setting, SettingValue, Tier } from '../../../../types/api'; -import { checkStripeEnabled, getSettingValues } from '../../../../utils/helpers'; -import { useGlobalData } from '../../../providers/DataProvider'; +import {CheckboxProps} from '../../../../admin-x-ds/global/form/Checkbox'; +import {Setting, SettingValue, Tier} from '../../../../types/api'; +import {checkStripeEnabled, getSettingValues} from '../../../../utils/helpers'; +import {useGlobalData} from '../../../providers/DataProvider'; const SignupOptions: React.FC<{ localSettings: Setting[] diff --git a/apps/admin-x-settings/src/components/settings/membership/stripe/StripeConnectModal.tsx b/apps/admin-x-settings/src/components/settings/membership/stripe/StripeConnectModal.tsx index a0b2c79f82..eee93870ab 100644 --- a/apps/admin-x-settings/src/components/settings/membership/stripe/StripeConnectModal.tsx +++ b/apps/admin-x-settings/src/components/settings/membership/stripe/StripeConnectModal.tsx @@ -6,8 +6,8 @@ import GhostLogo from '../../../../assets/images/orb-squircle.png'; import GhostLogoPink from '../../../../assets/images/orb-pink.png'; import Heading from '../../../../admin-x-ds/global/Heading'; import Modal from '../../../../admin-x-ds/global/modal/Modal'; -import NiceModal, { useModal } from '@ebay/nice-modal-react'; -import React, { useState } from 'react'; +import NiceModal, {useModal} from '@ebay/nice-modal-react'; +import React, {useState} from 'react'; import StripeButton from '../../../../admin-x-ds/settings/StripeButton'; import StripeLogo from '../../../../assets/images/stripe-emblem.svg'; import TextArea from '../../../../admin-x-ds/global/form/TextArea'; @@ -16,15 +16,15 @@ import Toggle from '../../../../admin-x-ds/global/form/Toggle'; import useRouting from '../../../../hooks/useRouting'; import useSettingGroup from '../../../../hooks/useSettingGroup'; import useSettings from '../../../../hooks/useSettings'; -import { ApiError } from '../../../../utils/apiRequests'; -import { ReactComponent as StripeVerified } from '../../../../assets/images/stripe-verified.svg'; -import { checkStripeEnabled, getGhostPaths, getSettingValue, getSettingValues } from '../../../../utils/helpers'; -import { showToast } from '../../../../admin-x-ds/global/Toast'; -import { toast } from 'react-hot-toast'; -import { useBrowseMembers } from '../../../../utils/api/members'; -import { useBrowseTiers, useEditTier } from '../../../../utils/api/tiers'; -import { useDeleteStripeSettings, useEditSettings } from '../../../../utils/api/settings'; -import { useGlobalData } from '../../../providers/DataProvider'; +import {ApiError} from '../../../../utils/apiRequests'; +import {ReactComponent as StripeVerified} from '../../../../assets/images/stripe-verified.svg'; +import {checkStripeEnabled, getGhostPaths, getSettingValue, getSettingValues} from '../../../../utils/helpers'; +import {showToast} from '../../../../admin-x-ds/global/Toast'; +import {toast} from 'react-hot-toast'; +import {useBrowseMembers} from '../../../../utils/api/members'; +import {useBrowseTiers, useEditTier} from '../../../../utils/api/tiers'; +import {useDeleteStripeSettings, useEditSettings} from '../../../../utils/api/settings'; +import {useGlobalData} from '../../../providers/DataProvider'; const RETRY_PRODUCT_SAVE_POLL_LENGTH = 1000; const RETRY_PRODUCT_SAVE_MAX_POLL = 15 * RETRY_PRODUCT_SAVE_POLL_LENGTH; @@ -64,7 +64,7 @@ const Connect: React.FC = () => { const saveTier = async () => { const {data} = await fetchActiveTiers(); - const tier = data?.tiers[0] + const tier = data?.tiers[0]; if (tier) { tier.monthly_price = 500; @@ -75,7 +75,7 @@ const Connect: React.FC = () => { /** To allow Stripe config to be ready in backend, we poll the save tier request */ while (pollTimeout < RETRY_PRODUCT_SAVE_MAX_POLL) { await new Promise((resolve) => { - setTimeout(resolve, RETRY_PRODUCT_SAVE_POLL_LENGTH) + setTimeout(resolve, RETRY_PRODUCT_SAVE_POLL_LENGTH); }); try { @@ -118,7 +118,7 @@ const Connect: React.FC = () => { } else { setError('Please enter a secure key'); } - } + }; const {apiRoot} = getGhostPaths(); const stripeConnectUrl = `${apiRoot}/members/stripe_connect?mode=${testMode ? 'test' : 'live'}`; @@ -152,7 +152,7 @@ const Connected: React.FC<{onClose?: () => void}> = ({onClose}) => { const [stripeConnectAccountName, stripeConnectLivemode] = getSettingValues(settings, ['stripe_connect_account_name', 'stripe_connect_livemode']); const {refetch: fetchMembers, isFetching: isFetchingMembers} = useBrowseMembers({ - searchParams: { filter: 'status:paid', limit: '0' }, + searchParams: {filter: 'status:paid', limit: '0'}, enabled: false }); @@ -160,11 +160,11 @@ const Connected: React.FC<{onClose?: () => void}> = ({onClose}) => { const openDisconnectStripeModal = async () => { const {data} = await fetchMembers(); - const hasActiveStripeSubscriptions = Boolean(data?.meta?.pagination.total) + const hasActiveStripeSubscriptions = Boolean(data?.meta?.pagination.total); // const hasActiveStripeSubscriptions = false; //... // this.ghostPaths.url.api('/members/') + '?filter=status:paid&limit=0'; - NiceModal.show(ConfirmationModal, { + NiceModal.show(ConfirmationModal, { title: 'Are you sure you want to disconnect?', prompt: <> {hasActiveStripeSubscriptions &&

@@ -233,20 +233,20 @@ const Direct: React.FC<{onClose: () => void}> = ({onClose}) => { showToast({ type: 'pageError', message: 'Failed to save settings. Please check you copied both keys correctly.' - }) + }); return; } throw e; } - } + }; return (

Connect Stripe
- updateSetting('stripe_publishable_key', e.target.value)} /> - updateSetting('stripe_secret_key', e.target.value)} /> + updateSetting('stripe_publishable_key', e.target.value)} /> + updateSetting('stripe_secret_key', e.target.value)} />
@@ -256,7 +256,7 @@ const Direct: React.FC<{onClose: () => void}> = ({onClose}) => { const StripeConnectModal: React.FC = () => { const {config} = useGlobalData(); const {settings} = useSettings(); - const stripeConnectAccountId = getSettingValue(settings, 'stripe_connect_account_id') + const stripeConnectAccountId = getSettingValue(settings, 'stripe_connect_account_id'); const {updateRoute} = useRouting(); const [step, setStep] = useState<'start' | 'connect'>('start'); const mainModal = useModal(); diff --git a/apps/admin-x-settings/src/components/settings/membership/tiers/TierDetailModal.tsx b/apps/admin-x-settings/src/components/settings/membership/tiers/TierDetailModal.tsx index 8b668718a1..fbb33fa46c 100644 --- a/apps/admin-x-settings/src/components/settings/membership/tiers/TierDetailModal.tsx +++ b/apps/admin-x-settings/src/components/settings/membership/tiers/TierDetailModal.tsx @@ -3,8 +3,8 @@ import Form from '../../../../admin-x-ds/global/form/Form'; import Heading from '../../../../admin-x-ds/global/Heading'; import Icon from '../../../../admin-x-ds/global/Icon'; import Modal from '../../../../admin-x-ds/global/modal/Modal'; -import NiceModal, { useModal } from '@ebay/nice-modal-react'; -import React, { useState } from 'react'; +import NiceModal, {useModal} from '@ebay/nice-modal-react'; +import React, {useState} from 'react'; import Select from '../../../../admin-x-ds/global/form/Select'; import SortableList from '../../../../admin-x-ds/global/SortableList'; import TextField from '../../../../admin-x-ds/global/form/TextField'; @@ -14,12 +14,12 @@ import useForm from '../../../../hooks/useForm'; import useRouting from '../../../../hooks/useRouting'; import useSettingGroup from '../../../../hooks/useSettingGroup'; import useSortableIndexedList from '../../../../hooks/useSortableIndexedList'; -import { Tier } from '../../../../types/api'; -import { currencies, currencyFromDecimal, currencyGroups, currencyToDecimal, getSymbol } from '../../../../utils/currency'; -import { getSettingValues } from '../../../../utils/helpers'; -import { showToast } from '../../../../admin-x-ds/global/Toast'; -import { toast } from 'react-hot-toast'; -import { useAddTier, useEditTier } from '../../../../utils/api/tiers'; +import {Tier} from '../../../../types/api'; +import {currencies, currencyFromDecimal, currencyGroups, currencyToDecimal, getSymbol} from '../../../../utils/currency'; +import {getSettingValues} from '../../../../utils/helpers'; +import {showToast} from '../../../../admin-x-ds/global/Toast'; +import {toast} from 'react-hot-toast'; +import {useAddTier, useEditTier} from '../../../../utils/api/tiers'; interface TierDetailModalProps { tier?: Tier @@ -123,7 +123,7 @@ const TierDetailModal: React.FC = ({tier}) => { if (Object.values(validators).filter(validator => validator()).length) { showToast({ type: 'pageError', - message: "Can't save tier! One or more fields have errors, please doublecheck you filled all mandatory fields" + message: 'Can\'t save tier! One or more fields have errors, please doublecheck you filled all mandatory fields' }); return; } diff --git a/apps/admin-x-settings/src/components/settings/membership/tiers/TiersList.tsx b/apps/admin-x-settings/src/components/settings/membership/tiers/TiersList.tsx index 7870662d4b..c177965bc0 100644 --- a/apps/admin-x-settings/src/components/settings/membership/tiers/TiersList.tsx +++ b/apps/admin-x-settings/src/components/settings/membership/tiers/TiersList.tsx @@ -5,10 +5,10 @@ import NoValueLabel from '../../../../admin-x-ds/global/NoValueLabel'; import React from 'react'; import TierDetailModal from './TierDetailModal'; import useRouting from '../../../../hooks/useRouting'; -import { Tier } from '../../../../types/api'; -import { currencyToDecimal, getSymbol } from '../../../../utils/currency'; -import { numberWithCommas } from '../../../../utils/helpers'; -import { useEditTier } from '../../../../utils/api/tiers'; +import {Tier} from '../../../../types/api'; +import {currencyToDecimal, getSymbol} from '../../../../utils/currency'; +import {numberWithCommas} from '../../../../utils/helpers'; +import {useEditTier} from '../../../../utils/api/tiers'; interface TiersListProps { tab?: 'active-tiers' | 'archive-tiers' | 'free-tier'; diff --git a/apps/admin-x-settings/src/components/settings/site/DesignModal.tsx b/apps/admin-x-settings/src/components/settings/site/DesignModal.tsx index d028354ff5..70f9b4551d 100644 --- a/apps/admin-x-settings/src/components/settings/site/DesignModal.tsx +++ b/apps/admin-x-settings/src/components/settings/site/DesignModal.tsx @@ -1,21 +1,21 @@ -import BrandSettings, { BrandSettingValues } from './designAndBranding/BrandSettings'; +import BrandSettings, {BrandSettingValues} from './designAndBranding/BrandSettings'; // import Button from '../../../admin-x-ds/global/Button'; // import ChangeThemeModal from './ThemeModal'; import Icon from '../../../admin-x-ds/global/Icon'; -import NiceModal, { NiceModalHandler, useModal } from '@ebay/nice-modal-react'; -import React, { useEffect, useState } from 'react'; +import NiceModal, {NiceModalHandler, useModal} from '@ebay/nice-modal-react'; +import React, {useEffect, useState} from 'react'; import StickyFooter from '../../../admin-x-ds/global/StickyFooter'; -import TabView, { Tab } from '../../../admin-x-ds/global/TabView'; +import TabView, {Tab} from '../../../admin-x-ds/global/TabView'; import ThemePreview from './designAndBranding/ThemePreview'; import ThemeSettings from './designAndBranding/ThemeSettings'; import useForm from '../../../hooks/useForm'; import useRouting from '../../../hooks/useRouting'; import useSettings from '../../../hooks/useSettings'; -import { CustomThemeSetting, Setting, SettingValue } from '../../../types/api'; -import { PreviewModalContent } from '../../../admin-x-ds/global/modal/PreviewModal'; -import { getHomepageUrl, getSettingValues } from '../../../utils/helpers'; -import { useBrowseCustomThemeSettings, useEditCustomThemeSettings } from '../../../utils/api/customThemeSettings'; -import { useBrowsePosts } from '../../../utils/api/posts'; +import {CustomThemeSetting, Setting, SettingValue} from '../../../types/api'; +import {PreviewModalContent} from '../../../admin-x-ds/global/modal/PreviewModal'; +import {getHomepageUrl, getSettingValues} from '../../../utils/helpers'; +import {useBrowseCustomThemeSettings, useEditCustomThemeSettings} from '../../../utils/api/customThemeSettings'; +import {useBrowsePosts} from '../../../utils/api/posts'; const Sidebar: React.FC<{ brandSettings: BrandSettingValues diff --git a/apps/admin-x-settings/src/components/settings/site/ThemeModal.tsx b/apps/admin-x-settings/src/components/settings/site/ThemeModal.tsx index 271426e668..2a396fbb93 100644 --- a/apps/admin-x-settings/src/components/settings/site/ThemeModal.tsx +++ b/apps/admin-x-settings/src/components/settings/site/ThemeModal.tsx @@ -4,17 +4,17 @@ import Button from '../../../admin-x-ds/global/Button'; import ConfirmationModal from '../../../admin-x-ds/global/modal/ConfirmationModal'; import FileUpload from '../../../admin-x-ds/global/form/FileUpload'; import Modal from '../../../admin-x-ds/global/modal/Modal'; -import NiceModal, { NiceModalHandler, useModal } from '@ebay/nice-modal-react'; +import NiceModal, {NiceModalHandler, useModal} from '@ebay/nice-modal-react'; import OfficialThemes from './theme/OfficialThemes'; import PageHeader from '../../../admin-x-ds/global/layout/PageHeader'; -import React, { useState } from 'react'; +import React, {useState} from 'react'; import TabView from '../../../admin-x-ds/global/TabView'; import ThemeInstalledModal from './theme/ThemeInstalledModal'; import ThemePreview from './theme/ThemePreview'; import useRouting from '../../../hooks/useRouting'; -import { OfficialTheme } from '../../../models/themes'; -import { Theme } from '../../../types/api'; -import { useBrowseThemes, useInstallTheme, useUploadTheme } from '../../../utils/api/themes'; +import {OfficialTheme} from '../../../models/themes'; +import {Theme} from '../../../types/api'; +import {useBrowseThemes, useInstallTheme, useUploadTheme} from '../../../utils/api/themes'; interface ThemeToolbarProps { selectedTheme: OfficialTheme|null; diff --git a/apps/admin-x-settings/src/components/settings/site/designAndBranding/ThemeSettings.tsx b/apps/admin-x-settings/src/components/settings/site/designAndBranding/ThemeSettings.tsx index f33a6914f5..262ddbfbd6 100644 --- a/apps/admin-x-settings/src/components/settings/site/designAndBranding/ThemeSettings.tsx +++ b/apps/admin-x-settings/src/components/settings/site/designAndBranding/ThemeSettings.tsx @@ -6,9 +6,9 @@ import Select from '../../../../admin-x-ds/global/form/Select'; import SettingGroupContent from '../../../../admin-x-ds/settings/SettingGroupContent'; import TextField from '../../../../admin-x-ds/global/form/TextField'; import Toggle from '../../../../admin-x-ds/global/form/Toggle'; -import { CustomThemeSetting } from '../../../../types/api'; -import { getImageUrl, useUploadImage } from '../../../../utils/api/images'; -import { humanizeSettingKey } from '../../../../utils/helpers'; +import {CustomThemeSetting} from '../../../../types/api'; +import {getImageUrl, useUploadImage} from '../../../../utils/api/images'; +import {humanizeSettingKey} from '../../../../utils/helpers'; const ThemeSetting: React.FC<{ setting: CustomThemeSetting, @@ -78,7 +78,7 @@ const ThemeSetting: React.FC<{ const ThemeSettings: React.FC<{ settings: CustomThemeSetting[], updateSetting: (setting: CustomThemeSetting) => void }> = ({settings, updateSetting}) => { return ( - {settings.map(setting => updateSetting({...setting, value} as CustomThemeSetting)} setting={setting} />)} + {settings.map(setting => updateSetting({...setting, value} as CustomThemeSetting)} setting={setting} />)} ); }; diff --git a/apps/admin-x-settings/src/hooks/useForm.ts b/apps/admin-x-settings/src/hooks/useForm.ts index 5c120bd1b6..c702948a31 100644 --- a/apps/admin-x-settings/src/hooks/useForm.ts +++ b/apps/admin-x-settings/src/hooks/useForm.ts @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useState } from 'react'; +import {useCallback, useEffect, useState} from 'react'; export type Dirtyable = Data & { dirty?: boolean; diff --git a/apps/admin-x-settings/src/hooks/useSettings.tsx b/apps/admin-x-settings/src/hooks/useSettings.tsx index f59db94b2e..c2698d19cc 100644 --- a/apps/admin-x-settings/src/hooks/useSettings.tsx +++ b/apps/admin-x-settings/src/hooks/useSettings.tsx @@ -1,7 +1,7 @@ -import { Setting } from '../types/api'; -import { useCallback, useMemo } from 'react'; -import { useEditSettings } from '../utils/api/settings'; -import { useGlobalData } from '../components/providers/DataProvider'; +import {Setting} from '../types/api'; +import {useCallback, useMemo} from 'react'; +import {useEditSettings} from '../utils/api/settings'; +import {useGlobalData} from '../components/providers/DataProvider'; function serialiseSettingsData(settings: Setting[]): Setting[] { return settings.map((setting) => { diff --git a/apps/admin-x-settings/src/utils/api/customThemeSettings.ts b/apps/admin-x-settings/src/utils/api/customThemeSettings.ts index 40623ea20b..a029f5314c 100644 --- a/apps/admin-x-settings/src/utils/api/customThemeSettings.ts +++ b/apps/admin-x-settings/src/utils/api/customThemeSettings.ts @@ -1,5 +1,5 @@ -import { CustomThemeSetting, Setting } from '../../types/api'; -import { createMutation, createQuery } from '../apiRequests'; +import {CustomThemeSetting, Setting} from '../../types/api'; +import {createMutation, createQuery} from '../apiRequests'; export interface CustomThemeSettingsResponseType { custom_theme_settings: CustomThemeSetting[]; diff --git a/apps/admin-x-settings/src/utils/api/invites.ts b/apps/admin-x-settings/src/utils/api/invites.ts index 1e95f9f5df..d6f7a563d9 100644 --- a/apps/admin-x-settings/src/utils/api/invites.ts +++ b/apps/admin-x-settings/src/utils/api/invites.ts @@ -1,4 +1,4 @@ -import { Meta, createMutation, createQuery } from '../apiRequests'; +import {Meta, createMutation, createQuery} from '../apiRequests'; export interface UserInvite { created_at: string; diff --git a/apps/admin-x-settings/src/utils/api/members.ts b/apps/admin-x-settings/src/utils/api/members.ts index fbdf450f22..0bb12e13a5 100644 --- a/apps/admin-x-settings/src/utils/api/members.ts +++ b/apps/admin-x-settings/src/utils/api/members.ts @@ -1,5 +1,5 @@ -import { Member } from '../../types/api'; -import { Meta, createQuery } from '../apiRequests'; +import {Member} from '../../types/api'; +import {Meta, createQuery} from '../apiRequests'; export interface MembersResponseType { meta?: Meta diff --git a/apps/admin-x-settings/src/utils/api/newsletters.ts b/apps/admin-x-settings/src/utils/api/newsletters.ts index a99fd0d046..7ddacdf288 100644 --- a/apps/admin-x-settings/src/utils/api/newsletters.ts +++ b/apps/admin-x-settings/src/utils/api/newsletters.ts @@ -1,5 +1,5 @@ -import { Meta, createMutation, createQuery } from '../apiRequests'; -import { Newsletter } from '../../types/api'; +import {Meta, createMutation, createQuery} from '../apiRequests'; +import {Newsletter} from '../../types/api'; export interface NewslettersResponseType { meta?: Meta diff --git a/apps/admin-x-settings/src/utils/api/settings.ts b/apps/admin-x-settings/src/utils/api/settings.ts index a2b2209503..ed36559dbe 100644 --- a/apps/admin-x-settings/src/utils/api/settings.ts +++ b/apps/admin-x-settings/src/utils/api/settings.ts @@ -1,5 +1,5 @@ -import { Meta, createMutation, createQuery } from '../apiRequests'; -import { Setting } from '../../types/api'; +import {Meta, createMutation, createQuery} from '../apiRequests'; +import {Setting} from '../../types/api'; export type SettingsResponseMeta = Meta & { sent_email_verification?: boolean } diff --git a/apps/admin-x-settings/src/utils/api/themes.ts b/apps/admin-x-settings/src/utils/api/themes.ts index c1ec191f4b..f3bfb5bde2 100644 --- a/apps/admin-x-settings/src/utils/api/themes.ts +++ b/apps/admin-x-settings/src/utils/api/themes.ts @@ -1,5 +1,5 @@ -import { InstalledTheme, Theme } from '../../types/api'; -import { createMutation, createQuery } from '../apiRequests'; +import {InstalledTheme, Theme} from '../../types/api'; +import {createMutation, createQuery} from '../apiRequests'; export interface ThemesResponseType { themes: Theme[]; diff --git a/apps/admin-x-settings/src/utils/api/tiers.ts b/apps/admin-x-settings/src/utils/api/tiers.ts index 60ea560761..95d574ff05 100644 --- a/apps/admin-x-settings/src/utils/api/tiers.ts +++ b/apps/admin-x-settings/src/utils/api/tiers.ts @@ -1,5 +1,5 @@ -import { Meta, createMutation, createQuery } from '../apiRequests'; -import { Tier } from '../../types/api'; +import {Meta, createMutation, createQuery} from '../apiRequests'; +import {Tier} from '../../types/api'; export interface TiersResponseType { meta?: Meta diff --git a/apps/admin-x-settings/src/utils/api/users.ts b/apps/admin-x-settings/src/utils/api/users.ts index adb29b8e30..a5ca7c889e 100644 --- a/apps/admin-x-settings/src/utils/api/users.ts +++ b/apps/admin-x-settings/src/utils/api/users.ts @@ -1,5 +1,5 @@ -import { Meta, createMutation, createQuery } from '../apiRequests'; -import { User } from '../../types/api'; +import {Meta, createMutation, createQuery} from '../apiRequests'; +import {User} from '../../types/api'; export interface UsersResponseType { meta?: Meta; @@ -44,7 +44,7 @@ export const useBrowseUsers = createQuery({ export const useCurrentUser = createQuery({ dataType, path: '/users/me/', - returnData: (originalData) => (originalData as UsersResponseType).users?.[0] + returnData: originalData => (originalData as UsersResponseType).users?.[0] }); export const useEditUser = createMutation({ diff --git a/apps/admin-x-settings/src/utils/apiRequests.ts b/apps/admin-x-settings/src/utils/apiRequests.ts index 02cc62ae9a..24f09f2282 100644 --- a/apps/admin-x-settings/src/utils/apiRequests.ts +++ b/apps/admin-x-settings/src/utils/apiRequests.ts @@ -1,6 +1,6 @@ -import { QueryClient, UseQueryOptions, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; -import { getGhostPaths } from './helpers'; -import { useServices } from '../components/providers/ServiceProvider'; +import {QueryClient, UseQueryOptions, useMutation, useQuery, useQueryClient} from '@tanstack/react-query'; +import {getGhostPaths} from './helpers'; +import {useServices} from '../components/providers/ServiceProvider'; export interface Meta { pagination: { @@ -68,7 +68,7 @@ export const useFetchApi = () => { if (response.status > 299) { const data = response.headers.get('content-type')?.includes('application/json') ? await response.json() : undefined; - throw new ApiError(response, data) + throw new ApiError(response, data); } else if (response.status === 204) { return; } else { @@ -139,11 +139,11 @@ const mutate = ({fetchApi, path, payload, searchParams, o const url = apiUrl(path, searchParams || defaultSearchParams); const generatedBody = payload && body?.(payload); - let requestBody: string | FormData | undefined = undefined + let requestBody: string | FormData | undefined = undefined; if (generatedBody instanceof FormData) { - requestBody = generatedBody + requestBody = generatedBody; } else if (generatedBody) { - requestBody = JSON.stringify(generatedBody) + requestBody = JSON.stringify(generatedBody); } return fetchApi(url, { diff --git a/apps/admin-x-settings/test/e2e/membership/tiers.test.ts b/apps/admin-x-settings/test/e2e/membership/tiers.test.ts index b614737223..da2a546624 100644 --- a/apps/admin-x-settings/test/e2e/membership/tiers.test.ts +++ b/apps/admin-x-settings/test/e2e/membership/tiers.test.ts @@ -1,12 +1,12 @@ -import { expect, test } from '@playwright/test'; -import { mockApi, responseFixtures, updatedSettingsResponse } from '../../utils/e2e'; +import {expect, test} from '@playwright/test'; +import {mockApi, responseFixtures, updatedSettingsResponse} from '../../utils/e2e'; const settingsWithStripe = updatedSettingsResponse([ - { key: 'stripe_connect_publishable_key', value: 'pk_test_123' }, - { key: 'stripe_connect_secret_key', value: 'sk_test_123' }, - { key: 'stripe_connect_display_name', value: 'Dummy' }, - { key: 'stripe_connect_account_id', value: 'acct_123' } -]) + {key: 'stripe_connect_publishable_key', value: 'pk_test_123'}, + {key: 'stripe_connect_secret_key', value: 'sk_test_123'}, + {key: 'stripe_connect_display_name', value: 'Dummy'}, + {key: 'stripe_connect_account_id', value: 'acct_123'} +]); test.describe('Tier settings', async () => { test('Supports creating a new tier', async ({page}) => { @@ -47,13 +47,13 @@ test.describe('Tier settings', async () => { visibility: 'public', created_at: new Date().toISOString(), updated_at: new Date().toISOString() - } + }; const lastApiRequests = await mockApi({page, responses: { tiers: { - add: { tiers: [newTier] }, + add: {tiers: [newTier]}, // This request will be reloaded after the new tier is added - browse: { tiers: [...responseFixtures.tiers.tiers, newTier] } + browse: {tiers: [...responseFixtures.tiers.tiers, newTier]} } }}); diff --git a/apps/admin-x-settings/test/e2e/site/theme.test.ts b/apps/admin-x-settings/test/e2e/site/theme.test.ts index 333e0768f2..f1e5feb6c6 100644 --- a/apps/admin-x-settings/test/e2e/site/theme.test.ts +++ b/apps/admin-x-settings/test/e2e/site/theme.test.ts @@ -1,5 +1,5 @@ -import { expect, test } from '@playwright/test'; -import { mockApi, responseFixtures } from '../../utils/e2e'; +import {expect, test} from '@playwright/test'; +import {mockApi, responseFixtures} from '../../utils/e2e'; test.describe('Theme settings', async () => { test('Browsing and installing default themes', async ({page}) => { diff --git a/apps/admin-x-settings/test/utils/e2e.ts b/apps/admin-x-settings/test/utils/e2e.ts index 0c80ed784b..cb7c757465 100644 --- a/apps/admin-x-settings/test/utils/e2e.ts +++ b/apps/admin-x-settings/test/utils/e2e.ts @@ -1,18 +1,18 @@ -import { ConfigResponseType } from '../../src/utils/api/config' -import { CustomThemeSettingsResponseType } from '../../src/utils/api/customThemeSettings' -import { ImagesResponseType } from '../../src/utils/api/images' -import { InvitesResponseType } from '../../src/utils/api/invites' -import { LabelsResponseType } from '../../src/utils/api/labels' -import { OffersResponseType } from '../../src/utils/api/offers' -import { Page, Request } from '@playwright/test' -import { PostsResponseType } from '../../src/utils/api/posts' -import { RolesResponseType } from '../../src/utils/api/roles' -import { SettingsResponseType } from '../../src/utils/api/settings' -import { SiteResponseType } from '../../src/utils/api/site' -import { ThemesResponseType } from '../../src/utils/api/themes' -import { TiersResponseType } from '../../src/utils/api/tiers' -import { UsersResponseType } from '../../src/utils/api/users' -import { readFileSync } from 'fs' +import {ConfigResponseType} from '../../src/utils/api/config'; +import {CustomThemeSettingsResponseType} from '../../src/utils/api/customThemeSettings'; +import {ImagesResponseType} from '../../src/utils/api/images'; +import {InvitesResponseType} from '../../src/utils/api/invites'; +import {LabelsResponseType} from '../../src/utils/api/labels'; +import {OffersResponseType} from '../../src/utils/api/offers'; +import {Page, Request} from '@playwright/test'; +import {PostsResponseType} from '../../src/utils/api/posts'; +import {RolesResponseType} from '../../src/utils/api/roles'; +import {SettingsResponseType} from '../../src/utils/api/settings'; +import {SiteResponseType} from '../../src/utils/api/site'; +import {ThemesResponseType} from '../../src/utils/api/themes'; +import {TiersResponseType} from '../../src/utils/api/tiers'; +import {UsersResponseType} from '../../src/utils/api/users'; +import {readFileSync} from 'fs'; export const responseFixtures = { settings: JSON.parse(readFileSync(`${__dirname}/responses/settings.json`).toString()) as SettingsResponseType,