From 107feda4adb6ea1ce0e5b7cbec159350697a5e07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Gerhard=20Lindesva=CC=88rd?= Date: Thu, 2 Nov 2023 20:24:41 +0100 Subject: [PATCH] oh lord. prettier eslint and all that --- .vscode/settings.json | 16 +- apps/web/.eslintrc.cjs | 38 --- apps/web/Dockerfile | 15 +- apps/web/next.config.mjs | 4 +- apps/web/package.json | 10 +- apps/web/prettier.config.mjs | 6 - apps/web/src/components/AutoSizer.tsx | 4 +- apps/web/src/components/ButtonContainer.tsx | 11 +- apps/web/src/components/Card.tsx | 12 +- apps/web/src/components/ColorSquare.tsx | 8 +- apps/web/src/components/Container.tsx | 11 +- apps/web/src/components/Content.tsx | 14 +- apps/web/src/components/DataTable.tsx | 16 +- apps/web/src/components/Dropdown.tsx | 20 +- apps/web/src/components/PageTitle.tsx | 2 +- apps/web/src/components/Pagination.tsx | 9 +- apps/web/src/components/Syntax.tsx | 12 +- apps/web/src/components/WithSidebar.tsx | 24 +- .../src/components/clients/ClientActions.tsx | 37 ++- apps/web/src/components/clients/table.tsx | 29 +- .../web/src/components/events/EventsTable.tsx | 72 ++-- apps/web/src/components/forms/InputError.tsx | 4 +- .../src/components/forms/InputWithLabel.tsx | 30 +- .../web/src/components/layouts/MainLayout.tsx | 17 +- .../src/components/layouts/SettingsLayout.tsx | 42 +-- .../src/components/navbar/NavbarCreate.tsx | 10 +- apps/web/src/components/navbar/NavbarMenu.tsx | 21 +- .../components/navbar/NavbarUserDropdown.tsx | 12 +- .../components/projects/ProjectActions.tsx | 37 ++- apps/web/src/components/projects/table.tsx | 21 +- .../src/components/report/ReportChartType.tsx | 13 +- .../src/components/report/ReportDateRange.tsx | 15 +- .../components/report/chart/ChartProvider.tsx | 26 +- .../report/chart/ReportBarChart.tsx | 72 ++-- .../report/chart/ReportLineChart.tsx | 29 +- .../report/chart/ReportLineChartTooltip.tsx | 8 +- .../components/report/chart/ReportTable.tsx | 44 +-- .../web/src/components/report/chart/index.tsx | 121 +++---- apps/web/src/components/report/reportSlice.ts | 17 +- .../report/sidebar/ReportBreakdownMore.tsx | 65 ++-- .../report/sidebar/ReportBreakdowns.tsx | 33 +- .../report/sidebar/ReportEventFilters.tsx | 83 ++--- .../report/sidebar/ReportEventMore.tsx | 87 ++--- .../report/sidebar/ReportEvents.tsx | 66 ++-- .../report/sidebar/ReportSaveButton.tsx | 44 ++- .../report/sidebar/ReportSidebar.tsx | 6 +- apps/web/src/components/ui/RenderDots.tsx | 25 +- apps/web/src/components/ui/alert-dialog.tsx | 65 ++-- apps/web/src/components/ui/aspect-ratio.tsx | 6 +- apps/web/src/components/ui/avatar.tsx | 27 +- apps/web/src/components/ui/badge.tsx | 26 +- apps/web/src/components/ui/button.tsx | 61 ++-- apps/web/src/components/ui/checkbox.tsx | 19 +- apps/web/src/components/ui/combobox-multi.tsx | 98 +++--- apps/web/src/components/ui/combobox.tsx | 53 +-- apps/web/src/components/ui/command.tsx | 69 ++-- apps/web/src/components/ui/dialog.tsx | 55 ++- apps/web/src/components/ui/dropdown-menu.tsx | 91 +++-- apps/web/src/components/ui/input.tsx | 17 +- apps/web/src/components/ui/label.tsx | 20 +- apps/web/src/components/ui/popover.tsx | 21 +- apps/web/src/components/ui/radio-group.tsx | 47 ++- apps/web/src/components/ui/table.tsx | 72 ++-- apps/web/src/components/ui/toast.tsx | 66 ++-- apps/web/src/components/ui/toaster.tsx | 10 +- apps/web/src/components/ui/tooltip.tsx | 21 +- apps/web/src/components/ui/use-toast.ts | 2 +- .../src/components/user/ChangePassword.tsx | 62 ++-- apps/web/src/hooks/useFormatDateInterval.ts | 2 +- apps/web/src/hooks/useQueryParams.ts | 2 +- apps/web/src/modals/AddClient.tsx | 53 +-- apps/web/src/modals/AddProject.tsx | 47 +-- apps/web/src/modals/Confirm.tsx | 17 +- apps/web/src/modals/EditClient.tsx | 51 +-- apps/web/src/modals/EditProject.tsx | 53 +-- apps/web/src/modals/Modal/Container.tsx | 15 +- apps/web/src/modals/SaveReport.tsx | 69 ++-- apps/web/src/modals/index.tsx | 39 ++- .../[organization]/[project]/[dashboard].tsx | 30 +- .../pages/[organization]/[project]/events.tsx | 19 +- .../pages/[organization]/[project]/index.tsx | 45 +-- .../[project]/profiles/[profileId].tsx | 25 +- .../[project]/profiles/index.tsx | 62 ++-- apps/web/src/pages/[organization]/index.tsx | 34 +- .../[organization]/reports/[reportId].tsx | 6 +- .../pages/[organization]/reports/index.tsx | 49 +-- .../pages/[organization]/settings/clients.tsx | 22 +- .../[organization]/settings/organization.tsx | 55 +-- .../pages/[organization]/settings/profile.tsx | 59 ++-- .../[organization]/settings/projects.tsx | 26 +- apps/web/src/pages/_app.tsx | 4 +- apps/web/src/pages/api/sdk/events.ts | 4 +- .../api/sdk/profiles/[profileId]/decrement.ts | 2 +- .../api/sdk/profiles/[profileId]/increment.ts | 2 +- .../api/sdk/profiles/[profileId]/index.ts | 2 +- apps/web/src/pages/api/setup.ts | 2 +- apps/web/src/redux/index.ts | 2 +- apps/web/src/server/api/routers/chart.ts | 10 +- apps/web/src/server/api/routers/report.ts | 14 +- apps/web/src/server/api/trpc.ts | 4 +- apps/web/src/server/auth.ts | 9 +- apps/web/src/server/exceptions.ts | 6 +- apps/web/src/server/getServerSideProps.ts | 5 +- apps/web/src/types/index.ts | 26 +- apps/web/src/utils/api.ts | 7 +- apps/web/src/utils/cn.ts | 3 +- apps/web/src/utils/getRangeLabel.ts | 2 +- apps/web/src/utils/theme.ts | 7 +- apps/web/tailwind.config.ts | 1 - apps/web/tsconfig.json | 34 +- package.json | 11 +- packages/sdk/package.json | 4 +- packages/types/package.json | 4 +- pnpm-lock.yaml | 313 ++++++++++-------- tooling/eslint/base.js | 8 +- tooling/eslint/nextjs.js | 9 + tooling/eslint/package.json | 8 +- tooling/eslint/react.js | 2 + tooling/prettier/index.mjs | 8 +- tooling/prettier/package.json | 7 +- tooling/publish/package.json | 14 +- 121 files changed, 1856 insertions(+), 1684 deletions(-) delete mode 100644 apps/web/.eslintrc.cjs delete mode 100644 apps/web/prettier.config.mjs create mode 100644 tooling/eslint/nextjs.js diff --git a/.vscode/settings.json b/.vscode/settings.json index 459d5a75..2057e4ba 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,11 +2,7 @@ "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true, - "[handlebars]": { - "editor.formatOnSave": false, - "editor.codeActionsOnSave": { "source.fixAll.eslint": false } - }, - "files.associations": { "*.hbs": "handlebars" }, + "eslint.rules.customizations": [{ "rule": "*", "severity": "warn" }], "eslint.workingDirectories": [ { "pattern": "apps/*/" }, { "pattern": "packages/*/" }, @@ -14,10 +10,8 @@ ], "typescript.enablePromptUseWorkspaceTsdk": true, "typescript.tsdk": "node_modules/typescript/lib", - "[yaml]": { - "editor.insertSpaces": true, - "editor.tabSize": 2, - "editor.autoIndent": "advanced" - }, - "editor.inlineSuggest.enabled": true + "typescript.preferences.autoImportFileExcludePatterns": [ + "next/router.d.ts", + "next/dist/client/router.d.ts" + ] } diff --git a/apps/web/.eslintrc.cjs b/apps/web/.eslintrc.cjs deleted file mode 100644 index 3898ad56..00000000 --- a/apps/web/.eslintrc.cjs +++ /dev/null @@ -1,38 +0,0 @@ -/** @type {import("eslint").Linter.Config} */ -const config = { - parser: "@typescript-eslint/parser", - parserOptions: { - project: true, - }, - plugins: ["@typescript-eslint"], - extends: [ - "next/core-web-vitals", - "plugin:@typescript-eslint/recommended-type-checked", - "plugin:@typescript-eslint/stylistic-type-checked", - ], - rules: { - // These opinionated rules are enabled in stylistic-type-checked above. - // Feel free to reconfigure them to your own preference. - "@typescript-eslint/array-type": "off", - "@typescript-eslint/consistent-type-definitions": "off", - "@typescript-eslint/ban-ts-comment": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-unsafe-assignment": "off", - "@typescript-eslint/no-unsafe-member-access": "off", - "@typescript-eslint/no-unsafe-argument": "off", - "@typescript-eslint/no-unsafe-return": "off", - "@typescript-eslint/no-unsafe-call": "off", - "@typescript-eslint/no-misused-promises": "off", - "@typescript-eslint/no-floating-promises": "off", - "@typescript-eslint/consistent-type-imports": [ - "warn", - { - prefer: "type-imports", - fixStyle: "inline-type-imports", - }, - ], - "@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }], - }, -}; - -module.exports = config; diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile index f95021ff..5eec8dcd 100644 --- a/apps/web/Dockerfile +++ b/apps/web/Dockerfile @@ -24,17 +24,25 @@ RUN apt update \ && rm n \ && npm install -g n +WORKDIR /app + +COPY package.json package.json +COPY pnpm-lock.yaml pnpm-lock.yaml +COPY pnpm-workspace.yaml pnpm-workspace.yaml +COPY apps/web/package.json apps/web/package.json +COPY packages/types/package.json packages/types/package.json + FROM base AS build -COPY . /app WORKDIR /app/apps/web RUN pnpm install --frozen-lockfile --ignore-scripts +COPY . /app RUN pnpm dlx prisma generate RUN pnpm run build FROM base AS prod -COPY . /app -WORKDIR /app +WORKDIR /app/apps/web RUN pnpm install --frozen-lockfile --prod --ignore-scripts +RUN pnpm dlx prisma generate FROM base AS runner COPY --from=build /app/package.json /app/package.json @@ -42,6 +50,5 @@ COPY --from=prod /app/node_modules /app/node_modules COPY --from=build /app/apps/web /app/apps/web COPY --from=prod /app/apps/web/node_modules /app/apps/web/node_modules WORKDIR /app/apps/web -RUN pnpm dlx prisma generate EXPOSE 3000 CMD [ "pnpm", "start" ] \ No newline at end of file diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjs index bee6f3e3..959ac96c 100644 --- a/apps/web/next.config.mjs +++ b/apps/web/next.config.mjs @@ -7,7 +7,9 @@ await import('./src/env.mjs'); /** @type {import("next").NextConfig} */ const config = { reactStrictMode: true, - + transpilePackages: [], + eslint: { ignoreDuringBuilds: true }, + typescript: { ignoreBuildErrors: true }, /** * If you are using `appDir` then you must comment the below `i18n` config out. * diff --git a/apps/web/package.json b/apps/web/package.json index e6e1bdb2..acd01be0 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -8,7 +8,7 @@ "build": "next build", "start": "next start", "lint": "eslint .", - "format": "prettier --check \"**/*.{mjs,ts,md,json}\"", + "format": "prettier --write \"**/*.{tsx,mjs,ts,md,json}\"", "typecheck": "tsc --noEmit" }, "dependencies": { @@ -62,20 +62,23 @@ "devDependencies": { "@mixan/eslint-config": "workspace:*", "@mixan/prettier-config": "workspace:*", + "@mixan/tsconfig": "workspace:*", "@types/bcrypt": "^5.0.0", "@types/node": "^18.16.0", "@types/ramda": "^0.29.6", "@types/react": "^18.2.20", "@types/react-dom": "^18.2.7", "@types/react-syntax-highlighter": "^15.5.9", + "@typescript-eslint/eslint-plugin": "^6.6.0", + "@typescript-eslint/parser": "^6.6.0", "autoprefixer": "^10.4.14", "eslint": "^8.48.0", - "eslint-config-next": "^13.5.4", "postcss": "^8.4.27", + "prettier": "^3.0.3", "prettier-plugin-tailwindcss": "^0.5.1", "prisma": "^5.1.1", "tailwindcss": "^3.3.3", - "typescript": "^5.2.0" + "typescript": "^5.2.2" }, "ct3aMetadata": { "initVersion": "7.21.0" @@ -84,6 +87,7 @@ "root": true, "extends": [ "@mixan/eslint-config/base", + "@mixan/eslint-config/nextjs", "@mixan/eslint-config/react" ] }, diff --git a/apps/web/prettier.config.mjs b/apps/web/prettier.config.mjs deleted file mode 100644 index eee0f31f..00000000 --- a/apps/web/prettier.config.mjs +++ /dev/null @@ -1,6 +0,0 @@ -/** @type {import('prettier').Config & import('prettier-plugin-tailwindcss').options} */ -const config = { - plugins: ['prettier-plugin-tailwindcss'], -}; - -export default config; diff --git a/apps/web/src/components/AutoSizer.tsx b/apps/web/src/components/AutoSizer.tsx index 68cd692a..1dcb7724 100644 --- a/apps/web/src/components/AutoSizer.tsx +++ b/apps/web/src/components/AutoSizer.tsx @@ -1,3 +1,3 @@ -import AutoSizer from "react-virtualized-auto-sizer"; +import AutoSizer from 'react-virtualized-auto-sizer'; -export { AutoSizer } +export { AutoSizer }; diff --git a/apps/web/src/components/ButtonContainer.tsx b/apps/web/src/components/ButtonContainer.tsx index d8bd6c71..2ec18841 100644 --- a/apps/web/src/components/ButtonContainer.tsx +++ b/apps/web/src/components/ButtonContainer.tsx @@ -1,8 +1,11 @@ -import { type HtmlProps } from "@/types"; -import { cn } from "@/utils/cn"; +import type { HtmlProps } from '@/types'; +import { cn } from '@/utils/cn'; -export function ButtonContainer({className,...props}: HtmlProps) { +export function ButtonContainer({ + className, + ...props +}: HtmlProps) { return ( -
+
); } diff --git a/apps/web/src/components/Card.tsx b/apps/web/src/components/Card.tsx index 67ba3155..1ba4d41d 100644 --- a/apps/web/src/components/Card.tsx +++ b/apps/web/src/components/Card.tsx @@ -1,9 +1,5 @@ -import { type HtmlProps } from "@/types"; +import type { HtmlProps } from '@/types'; -export function Card({children}: HtmlProps) { - return ( -
- {children} -
- ) -} \ No newline at end of file +export function Card({ children }: HtmlProps) { + return
{children}
; +} diff --git a/apps/web/src/components/ColorSquare.tsx b/apps/web/src/components/ColorSquare.tsx index a111123c..e0015dab 100644 --- a/apps/web/src/components/ColorSquare.tsx +++ b/apps/web/src/components/ColorSquare.tsx @@ -1,5 +1,5 @@ -import { type HtmlProps } from "@/types"; -import { cn } from "@/utils/cn"; +import type { HtmlProps } from '@/types'; +import { cn } from '@/utils/cn'; type ColorSquareProps = HtmlProps; @@ -7,8 +7,8 @@ export function ColorSquare({ children, className }: ColorSquareProps) { return (
{children} diff --git a/apps/web/src/components/Container.tsx b/apps/web/src/components/Container.tsx index 2647fb52..2f40b42b 100644 --- a/apps/web/src/components/Container.tsx +++ b/apps/web/src/components/Container.tsx @@ -1,8 +1,11 @@ -import { type HtmlProps } from "@/types"; -import { cn } from "@/utils/cn"; +import type { HtmlProps } from '@/types'; +import { cn } from '@/utils/cn'; -export function Container({className,...props}: HtmlProps) { +export function Container({ className, ...props }: HtmlProps) { return ( -
+
); } diff --git a/apps/web/src/components/Content.tsx b/apps/web/src/components/Content.tsx index 6ce3164c..73dfe370 100644 --- a/apps/web/src/components/Content.tsx +++ b/apps/web/src/components/Content.tsx @@ -1,10 +1,10 @@ -import { cn } from "@/utils/cn"; +import { cn } from '@/utils/cn'; -type ContentHeaderProps = { +interface ContentHeaderProps { title: string; text: string; children?: React.ReactNode; -}; +} export function ContentHeader({ title, text, children }: ContentHeaderProps) { return ( @@ -18,12 +18,12 @@ export function ContentHeader({ title, text, children }: ContentHeaderProps) { ); } -type ContentSectionProps = { +interface ContentSectionProps { title: string; text?: string | React.ReactNode; children: React.ReactNode; asCol?: boolean; -}; +} export function ContentSection({ title, @@ -34,8 +34,8 @@ export function ContentSection({ return (
{title && ( diff --git a/apps/web/src/components/DataTable.tsx b/apps/web/src/components/DataTable.tsx index 7a488188..385dffd0 100644 --- a/apps/web/src/components/DataTable.tsx +++ b/apps/web/src/components/DataTable.tsx @@ -1,9 +1,10 @@ import { - type ColumnDef, flexRender, getCoreRowModel, useReactTable, -} from "@tanstack/react-table"; +} from '@tanstack/react-table'; +import type { ColumnDef } from '@tanstack/react-table'; + import { Table, TableBody, @@ -11,17 +12,14 @@ import { TableHead, TableHeader, TableRow, -} from "./ui/table"; +} from './ui/table'; interface DataTableProps { columns: ColumnDef[]; data: TData[]; } -export function DataTable({ - columns, - data, -}: DataTableProps) { +export function DataTable({ columns, data }: DataTableProps) { const table = useReactTable({ data, columns, @@ -40,7 +38,7 @@ export function DataTable({ ? null : flexRender( header.column.columnDef.header, - header.getContext(), + header.getContext() )} ); @@ -53,7 +51,7 @@ export function DataTable({ table.getRowModel().rows.map((row) => ( {row.getVisibleCells().map((cell) => ( diff --git a/apps/web/src/components/Dropdown.tsx b/apps/web/src/components/Dropdown.tsx index a9f34cc4..1cb8ffe7 100644 --- a/apps/web/src/components/Dropdown.tsx +++ b/apps/web/src/components/Dropdown.tsx @@ -1,4 +1,5 @@ -import { cloneElement } from "react"; +import { cloneElement } from 'react'; + import { DropdownMenu, DropdownMenuContent, @@ -7,19 +8,24 @@ import { DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, -} from "./ui/dropdown-menu"; +} from './ui/dropdown-menu'; -type DropdownProps = { +interface DropdownProps { children: React.ReactNode; label?: string; - items: Array<{ + items: { label: string; value: Value; - }>; + }[]; onChange?: (value: Value) => void; -}; +} -export function Dropdown({ children, label, items, onChange }: DropdownProps) { +export function Dropdown({ + children, + label, + items, + onChange, +}: DropdownProps) { return ( {children} diff --git a/apps/web/src/components/PageTitle.tsx b/apps/web/src/components/PageTitle.tsx index 23470338..bcab27bf 100644 --- a/apps/web/src/components/PageTitle.tsx +++ b/apps/web/src/components/PageTitle.tsx @@ -1,4 +1,4 @@ -import { type HtmlProps } from "@/types"; +import type { HtmlProps } from '@/types'; type PageTitleProps = HtmlProps; diff --git a/apps/web/src/components/Pagination.tsx b/apps/web/src/components/Pagination.tsx index fed6e2b2..a2fc8efe 100644 --- a/apps/web/src/components/Pagination.tsx +++ b/apps/web/src/components/Pagination.tsx @@ -1,5 +1,6 @@ -import { useMemo, useState } from "react"; -import { Button } from "./ui/button"; +import { useMemo, useState } from 'react'; + +import { Button } from './ui/button'; export function usePagination(take = 100) { const [skip, setSkip] = useState(0); @@ -12,11 +13,11 @@ export function usePagination(take = 100) { canPrev: skip > 0, canNext: true, }), - [skip, setSkip, take], + [skip, setSkip, take] ); } -export type PaginationProps = ReturnType +export type PaginationProps = ReturnType; export function Pagination(props: PaginationProps) { return ( diff --git a/apps/web/src/components/Syntax.tsx b/apps/web/src/components/Syntax.tsx index 9df05e13..c353bddc 100644 --- a/apps/web/src/components/Syntax.tsx +++ b/apps/web/src/components/Syntax.tsx @@ -1,12 +1,12 @@ -import { Light as SyntaxHighlighter } from "react-syntax-highlighter"; -import ts from "react-syntax-highlighter/dist/cjs/languages/hljs/typescript"; -import docco from "react-syntax-highlighter/dist/cjs/styles/hljs/docco"; +import { Light as SyntaxHighlighter } from 'react-syntax-highlighter'; +import ts from 'react-syntax-highlighter/dist/cjs/languages/hljs/typescript'; +import docco from 'react-syntax-highlighter/dist/cjs/styles/hljs/docco'; -SyntaxHighlighter.registerLanguage("typescript", ts); +SyntaxHighlighter.registerLanguage('typescript', ts); -type SyntaxProps = { +interface SyntaxProps { code: string; -}; +} export default function Syntax({ code }: SyntaxProps) { return {code}; diff --git a/apps/web/src/components/WithSidebar.tsx b/apps/web/src/components/WithSidebar.tsx index e566d83f..cd43d64c 100644 --- a/apps/web/src/components/WithSidebar.tsx +++ b/apps/web/src/components/WithSidebar.tsx @@ -1,21 +1,15 @@ -import { type HtmlProps } from "@/types"; +import type { HtmlProps } from '@/types'; -type WithSidebarProps = HtmlProps +type WithSidebarProps = HtmlProps; -export function WithSidebar({children}: WithSidebarProps) { +export function WithSidebar({ children }: WithSidebarProps) { return ( -
- {children} -
- ) +
{children}
+ ); } -type SidebarProps = HtmlProps +type SidebarProps = HtmlProps; -export function Sidebar({children}: SidebarProps) { - return ( -
- {children} -
- ) -} \ No newline at end of file +export function Sidebar({ children }: SidebarProps) { + return
{children}
; +} diff --git a/apps/web/src/components/clients/ClientActions.tsx b/apps/web/src/components/clients/ClientActions.tsx index dba20f84..3198ec01 100644 --- a/apps/web/src/components/clients/ClientActions.tsx +++ b/apps/web/src/components/clients/ClientActions.tsx @@ -1,3 +1,11 @@ +import { useRefetchActive } from '@/hooks/useRefetchActive'; +import { pushModal, showConfirm } from '@/modals'; +import type { IClientWithProject } from '@/types'; +import { api } from '@/utils/api'; +import { clipboard } from '@/utils/clipboard'; +import { MoreHorizontal } from 'lucide-react'; + +import { Button } from '../ui/button'; import { DropdownMenu, DropdownMenuContent, @@ -5,27 +13,20 @@ import { DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, -} from "../ui/dropdown-menu"; -import { Button } from "../ui/button"; -import { MoreHorizontal } from "lucide-react"; -import { pushModal, showConfirm } from "@/modals"; -import { type IClientWithProject } from "@/types"; -import { clipboard } from "@/utils/clipboard"; -import { api } from "@/utils/api"; -import { useRefetchActive } from "@/hooks/useRefetchActive"; -import { toast } from "../ui/use-toast"; +} from '../ui/dropdown-menu'; +import { toast } from '../ui/use-toast'; export function ClientActions({ id }: IClientWithProject) { - const refetch = useRefetchActive() + const refetch = useRefetchActive(); const deletion = api.client.remove.useMutation({ onSuccess() { toast({ title: 'Success', description: 'Client revoked, incoming requests will be rejected.', - }) - refetch() - } - }) + }); + refetch(); + }, + }); return ( @@ -41,7 +42,7 @@ export function ClientActions({ id }: IClientWithProject) { { - pushModal("EditClient", { id }); + pushModal('EditClient', { id }); }} > Edit @@ -56,9 +57,9 @@ export function ClientActions({ id }: IClientWithProject) { onConfirm() { deletion.mutate({ id, - }) - } - }) + }); + }, + }); }} > Revoke diff --git a/apps/web/src/components/clients/table.tsx b/apps/web/src/components/clients/table.tsx index 16adabb1..440e8dbb 100644 --- a/apps/web/src/components/clients/table.tsx +++ b/apps/web/src/components/clients/table.tsx @@ -1,12 +1,13 @@ -import { formatDate } from "@/utils/date"; -import { type ColumnDef } from "@tanstack/react-table"; -import { type IClientWithProject } from "@/types"; -import { ClientActions } from "./ClientActions"; +import type { IClientWithProject } from '@/types'; +import { formatDate } from '@/utils/date'; +import type { ColumnDef } from '@tanstack/react-table'; + +import { ClientActions } from './ClientActions'; export const columns: ColumnDef[] = [ { - accessorKey: "name", - header: "Name", + accessorKey: 'name', + header: 'Name', cell: ({ row }) => { return (
@@ -19,25 +20,25 @@ export const columns: ColumnDef[] = [ }, }, { - accessorKey: "id", - header: "Client ID", + accessorKey: 'id', + header: 'Client ID', }, { - accessorKey: "secret", - header: "Secret", + accessorKey: 'secret', + header: 'Secret', cell: () =>
Hidden
, }, { - accessorKey: "createdAt", - header: "Created at", + accessorKey: 'createdAt', + header: 'Created at', cell({ row }) { const date = row.original.createdAt; return
{formatDate(date)}
; }, }, { - id: "actions", - header: "Actions", + id: 'actions', + header: 'Actions', cell: ({ row }) => , }, ]; diff --git a/apps/web/src/components/events/EventsTable.tsx b/apps/web/src/components/events/EventsTable.tsx index b8024c3d..6d91f06b 100644 --- a/apps/web/src/components/events/EventsTable.tsx +++ b/apps/web/src/components/events/EventsTable.tsx @@ -1,66 +1,70 @@ -import { useMemo } from "react"; -import { DataTable } from "@/components/DataTable"; -import { type PaginationProps, Pagination } from "@/components/Pagination"; -import { Avatar, AvatarFallback } from "@/components/ui/avatar"; -import { Table, TableBody, TableCell, TableRow } from "@/components/ui/table"; -import { type RouterOutputs } from "@/utils/api"; -import { formatDateTime } from "@/utils/date"; -import { toDots } from "@/utils/object"; -import { AvatarImage } from "@radix-ui/react-avatar"; -import { createColumnHelper } from "@tanstack/react-table"; -import Link from "next/link"; -import { useOrganizationParams } from "@/hooks/useOrganizationParams"; +import { useMemo } from 'react'; +import { DataTable } from '@/components/DataTable'; +import { Pagination } from '@/components/Pagination'; +import type { PaginationProps } from '@/components/Pagination'; +import { Avatar, AvatarFallback } from '@/components/ui/avatar'; +import { Table, TableBody, TableCell, TableRow } from '@/components/ui/table'; +import { useOrganizationParams } from '@/hooks/useOrganizationParams'; +import type { RouterOutputs } from '@/utils/api'; +import { formatDateTime } from '@/utils/date'; +import { toDots } from '@/utils/object'; +import { AvatarImage } from '@radix-ui/react-avatar'; +import { createColumnHelper } from '@tanstack/react-table'; +import Link from 'next/link'; const columnHelper = - createColumnHelper(); + createColumnHelper(); -type EventsTableProps = { - data: RouterOutputs["event"]["list"]; +interface EventsTableProps { + data: RouterOutputs['event']['list']; pagination: PaginationProps; -}; +} export function EventsTable({ data, pagination }: EventsTableProps) { - const params = useOrganizationParams() + const params = useOrganizationParams(); const columns = useMemo(() => { return [ columnHelper.accessor((row) => row.createdAt, { - id: "createdAt", - header: () => "Created At", + id: 'createdAt', + header: () => 'Created At', cell(info) { return formatDateTime(info.getValue()); }, - footer: () => "Created At", + footer: () => 'Created At', }), columnHelper.accessor((row) => row.name, { - id: "event", - header: () => "Event", + id: 'event', + header: () => 'Event', cell(info) { return {info.getValue()}; }, - footer: () => "Created At", + footer: () => 'Created At', }), columnHelper.accessor((row) => row.profile, { - id: "profile", - header: () => "Profile", + id: 'profile', + header: () => 'Profile', cell(info) { const profile = info.getValue(); return ( - + {profile?.avatar && } {profile?.first_name?.at(0)} - {`${profile?.first_name} ${profile?.last_name ?? ""}`} + {`${profile?.first_name} ${profile?.last_name ?? ''}`} ); }, - footer: () => "Created At", + footer: () => 'Created At', }), columnHelper.accessor((row) => row.properties, { - id: "properties", - header: () => "Properties", + id: 'properties', + header: () => 'Properties', cell(info) { const dots = toDots(info.getValue() as Record); return ( @@ -71,10 +75,10 @@ export function EventsTable({ data, pagination }: EventsTableProps) { {key} - {typeof dots[key] === "boolean" + {typeof dots[key] === 'boolean' ? dots[key] - ? "true" - : "false" + ? 'true' + : 'false' : dots[key]} @@ -84,7 +88,7 @@ export function EventsTable({ data, pagination }: EventsTableProps) { ); }, - footer: () => "Created At", + footer: () => 'Created At', }), ]; }, []); diff --git a/apps/web/src/components/forms/InputError.tsx b/apps/web/src/components/forms/InputError.tsx index fcf0744f..c68292e0 100644 --- a/apps/web/src/components/forms/InputError.tsx +++ b/apps/web/src/components/forms/InputError.tsx @@ -1,4 +1,6 @@ -type InputErrorProps = { message?: string }; +interface InputErrorProps { + message?: string; +} export function InputError({ message }: InputErrorProps) { if (!message) { diff --git a/apps/web/src/components/forms/InputWithLabel.tsx b/apps/web/src/components/forms/InputWithLabel.tsx index 2a89fcaa..e9f0c461 100644 --- a/apps/web/src/components/forms/InputWithLabel.tsx +++ b/apps/web/src/components/forms/InputWithLabel.tsx @@ -1,18 +1,24 @@ -import { forwardRef } from "react"; -import { Input, type InputProps } from "../ui/input"; -import { Label } from "../ui/label"; +import { forwardRef } from 'react'; + +import { Input } from '../ui/input'; +import type { InputProps } from '../ui/input'; +import { Label } from '../ui/label'; type InputWithLabelProps = InputProps & { label: string; }; -export const InputWithLabel = forwardRef(({ label, ...props }, ref) => { - return ( -
- - -
- ); -}); +export const InputWithLabel = forwardRef( + ({ label, ...props }, ref) => { + return ( +
+ + +
+ ); + } +); -InputWithLabel.displayName = "InputWithLabel"; +InputWithLabel.displayName = 'InputWithLabel'; diff --git a/apps/web/src/components/layouts/MainLayout.tsx b/apps/web/src/components/layouts/MainLayout.tsx index 8739ecf4..5caa2a81 100644 --- a/apps/web/src/components/layouts/MainLayout.tsx +++ b/apps/web/src/components/layouts/MainLayout.tsx @@ -1,12 +1,13 @@ -import { NavbarUserDropdown } from "../navbar/NavbarUserDropdown"; -import { NavbarMenu } from "../navbar/NavbarMenu"; -import { Container } from "../Container"; -import Link from "next/link"; +import Link from 'next/link'; -type MainLayoutProps = { +import { Container } from '../Container'; +import { NavbarMenu } from '../navbar/NavbarMenu'; +import { NavbarUserDropdown } from '../navbar/NavbarUserDropdown'; + +interface MainLayoutProps { children: React.ReactNode; className?: string; -}; +} export function MainLayout({ children, className }: MainLayoutProps) { return ( @@ -14,7 +15,9 @@ export function MainLayout({ children, className }: MainLayoutProps) {