From 71ea41695f8f6d33cf8c5c6c1e88acb88a416ae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20LUDWIG?= Date: Mon, 23 Oct 2023 23:33:39 +0200 Subject: [PATCH] chore: better Prettier config for easier reviews --- .devcontainer/compose.yaml | 10 +- .github/ISSUE_TEMPLATE/BUG.md | 8 +- .github/ISSUE_TEMPLATE/DOCUMENTATION.md | 8 +- .github/ISSUE_TEMPLATE/FEATURE_REQUEST.md | 8 +- .github/ISSUE_TEMPLATE/IMPROVEMENT.md | 8 +- .github/ISSUE_TEMPLATE/QUESTION.md | 8 +- .github/workflows/analyze.yml | 16 +- .github/workflows/build.yml | 22 +- .github/workflows/lint.yml | 36 +- .github/workflows/release.yml | 26 +- .github/workflows/test.yml | 50 +- .prettierrc.json | 5 +- Dockerfile | 6 +- components/Application/Application.tsx | 122 +- .../ChannelSettings/ChannelSettings.tsx | 98 +- .../Application/ChannelSettings/index.ts | 2 +- components/Application/Channels/Channel.tsx | 32 +- components/Application/Channels/Channels.tsx | 18 +- components/Application/Channels/index.ts | 2 +- .../Application/ConfirmPopup/ConfirmPopup.tsx | 44 +- components/Application/ConfirmPopup/index.ts | 2 +- .../CreateChannel/CreateChannel.tsx | 56 +- components/Application/CreateChannel/index.ts | 2 +- .../Application/CreateGuild/CreateGuild.tsx | 60 +- components/Application/CreateGuild/index.ts | 2 +- .../GuildLeftSidebar/GuildLeftSidebar.tsx | 30 +- .../Application/GuildLeftSidebar/index.ts | 2 +- .../GuildSettings/GuildSettings.tsx | 162 +- components/Application/GuildSettings/index.ts | 2 +- components/Application/Guilds/Guild.tsx | 18 +- components/Application/Guilds/Guilds.tsx | 20 +- components/Application/Guilds/index.ts | 2 +- .../JoinGuildsPublic/GuildPublic.tsx | 66 +- .../JoinGuildsPublic/JoinGuildsPublic.tsx | 50 +- .../Application/JoinGuildsPublic/index.ts | 2 +- components/Application/Members/Member.tsx | 26 +- components/Application/Members/Members.tsx | 22 +- components/Application/Members/index.ts | 2 +- .../Message/EditMessage/EditMessage.tsx | 20 +- .../Messages/Message/EditMessage/index.ts | 2 +- .../Application/Messages/Message/Message.tsx | 62 +- .../Messages/Message/MessageFile/FileIcon.tsx | 14 +- .../Message/MessageFile/MessageFile.tsx | 48 +- .../Messages/Message/MessageFile/index.ts | 2 +- .../Message/MessageOptions/MessageOptions.tsx | 24 +- .../Messages/Message/MessageOptions/index.ts | 2 +- .../Message/MessageText/MessageText.tsx | 36 +- .../Messages/Message/MessageText/index.ts | 2 +- .../Application/Messages/Message/index.ts | 2 +- components/Application/Messages/Messages.tsx | 28 +- components/Application/Messages/index.ts | 2 +- .../Application/PopupGuild/PopupGuild.tsx | 40 +- .../Application/PopupGuild/PopupGuildCard.tsx | 14 +- components/Application/PopupGuild/index.ts | 2 +- .../Application/SendMessage/SendMessage.tsx | 82 +- components/Application/SendMessage/index.ts | 2 +- components/Application/Sidebar/Sidebar.tsx | 28 +- components/Application/Sidebar/index.ts | 2 +- .../Application/UserProfile/UserProfile.tsx | 76 +- components/Application/UserProfile/index.ts | 2 +- .../Application/UserSettings/UserSettings.tsx | 272 +-- components/Application/UserSettings/index.ts | 2 +- components/Application/index.ts | 2 +- components/Authentication/Authentication.tsx | 132 +- .../Authentication/AuthenticationForm.tsx | 8 +- .../AuthenticationSocialMedia.tsx | 26 +- components/Authentication/index.ts | 4 +- components/Emoji/Emoji.tsx | 4 +- components/Emoji/EmojiPicker/EmojiPicker.tsx | 14 +- components/Emoji/EmojiPicker/index.ts | 2 +- components/Emoji/emojiPlugin.ts | 34 +- components/Emoji/index.ts | 8 +- components/ErrorPage.tsx | 32 +- components/Footer/Footer.tsx | 24 +- components/Footer/VersionLink.tsx | 8 +- components/Footer/index.ts | 2 +- components/Head.tsx | 44 +- components/Header/Header.tsx | 24 +- components/Header/Language/Arrow.tsx | 14 +- components/Header/Language/Language.tsx | 30 +- components/Header/Language/LanguageFlag.tsx | 4 +- components/Header/Language/index.ts | 2 +- components/Header/SwitchTheme.tsx | 58 +- components/Header/index.ts | 2 +- components/design/Button/Button.tsx | 36 +- components/design/Button/index.ts | 2 +- components/design/Checkbox/Checkbox.tsx | 12 +- components/design/Checkbox/index.ts | 2 +- components/design/Divider/Divider.tsx | 4 +- components/design/Divider/index.ts | 2 +- components/design/FormState/FormState.tsx | 28 +- components/design/FormState/index.ts | 2 +- components/design/IconButton/IconButton.tsx | 8 +- components/design/IconButton/index.ts | 2 +- components/design/IconLink/IconLink.tsx | 18 +- components/design/IconLink/index.ts | 2 +- components/design/Input/Input.tsx | 50 +- components/design/Input/index.ts | 2 +- components/design/Loader/Loader.tsx | 22 +- components/design/Loader/index.ts | 2 +- components/design/Main/Main.tsx | 6 +- components/design/Main/index.ts | 2 +- .../SocialMediaButton/SocialMediaButton.tsx | 40 +- components/design/SocialMediaButton/index.ts | 2 +- components/design/Textarea/Textarea.tsx | 16 +- components/design/Textarea/index.ts | 2 +- compose.yaml | 10 +- contexts/Channels.tsx | 38 +- contexts/GuildMember.tsx | 34 +- contexts/Guilds.tsx | 30 +- contexts/Members.tsx | 40 +- contexts/Messages.tsx | 38 +- cypress.config.ts | 44 +- .../Emoji/isStringWithOnlyOneEmoji.cy.ts | 22 +- cypress/component/components/Footer.cy.tsx | 20 +- .../components/design/FormState.cy.tsx | 44 +- .../component/components/design/Input.cy.tsx | 58 +- .../component/tools/utils/capitalize.cy.ts | 14 +- cypress/e2e/common/Header.cy.ts | 72 +- .../common/application/authentication.cy.ts | 44 +- cypress/e2e/pages/400.cy.ts | 8 +- cypress/e2e/pages/500.cy.ts | 8 +- .../[guildId]/[channelId]/index.cy.ts | 326 +-- .../[guildId]/[channelId]/settings.cy.ts | 144 +- .../[guildId]/channels/create.cy.ts | 88 +- .../application/[guildId]/settings.cy.ts | 126 +- .../e2e/pages/application/guilds/create.cy.ts | 60 +- .../e2e/pages/application/guilds/join.cy.ts | 98 +- cypress/e2e/pages/application/index.cy.ts | 32 +- .../application/users/[userId]/index.cy.ts | 40 +- .../authentication/forgot-password.cy.ts | 50 +- .../pages/authentication/reset-password.cy.ts | 64 +- cypress/e2e/pages/authentication/signin.cy.ts | 76 +- cypress/e2e/pages/authentication/signup.cy.ts | 130 +- cypress/e2e/pages/index.cy.ts | 10 +- .../fixtures/channels/[channelId]/delete.ts | 12 +- cypress/fixtures/channels/[channelId]/get.ts | 20 +- .../channels/[channelId]/messages/get.ts | 16 +- cypress/fixtures/channels/[channelId]/put.ts | 14 +- cypress/fixtures/channels/channel.ts | 8 +- .../fixtures/guilds/[guildId]/channels/get.ts | 12 +- .../guilds/[guildId]/channels/post.ts | 14 +- cypress/fixtures/guilds/[guildId]/delete.ts | 12 +- cypress/fixtures/guilds/[guildId]/get.ts | 24 +- .../fixtures/guilds/[guildId]/members/get.ts | 12 +- .../fixtures/guilds/[guildId]/members/join.ts | 18 +- .../guilds/[guildId]/members/leave.ts | 14 +- cypress/fixtures/guilds/get.ts | 14 +- cypress/fixtures/guilds/guild.ts | 10 +- cypress/fixtures/guilds/post.ts | 20 +- cypress/fixtures/guilds/public/get.ts | 30 +- cypress/fixtures/handler.ts | 8 +- cypress/fixtures/members/member.ts | 8 +- cypress/fixtures/messages/message.ts | 46 +- cypress/fixtures/uploads/messages/get.ts | 30 +- cypress/fixtures/users/[userId]/get.ts | 14 +- cypress/fixtures/users/current/get.ts | 18 +- cypress/fixtures/users/refresh-token/post.ts | 14 +- cypress/fixtures/users/reset-password/post.ts | 10 +- cypress/fixtures/users/reset-password/put.ts | 22 +- cypress/fixtures/users/signin/post.ts | 28 +- cypress/fixtures/users/signup/post.ts | 28 +- cypress/fixtures/users/user.ts | 30 +- cypress/support/component.ts | 8 +- generators/component/index.js | 32 +- generators/language/index.js | 36 +- hooks/useClickOutsideAlerter.ts | 8 +- hooks/useFormTranslation.ts | 30 +- hooks/usePagination.ts | 34 +- models/Channel.ts | 12 +- models/Guild.ts | 22 +- models/Member.ts | 10 +- models/Message.ts | 20 +- models/OAuth.ts | 10 +- models/RefreshToken.ts | 6 +- models/User.ts | 36 +- models/UserSettings.ts | 16 +- models/utils.ts | 14 +- next.config.js | 16 +- package-lock.json | 2126 ++++++++--------- package.json | 56 +- pages/404.tsx | 16 +- pages/500.tsx | 18 +- pages/_app.tsx | 36 +- .../[guildId]/[channelId]/index.tsx | 46 +- .../[guildId]/[channelId]/settings.tsx | 46 +- .../application/[guildId]/channels/create.tsx | 36 +- pages/application/[guildId]/settings.tsx | 36 +- pages/application/guilds/create.tsx | 28 +- pages/application/guilds/join.tsx | 28 +- pages/application/index.tsx | 22 +- pages/application/users/[userId]/index.tsx | 28 +- pages/application/users/settings.tsx | 26 +- pages/authentication/forgot-password.tsx | 76 +- pages/authentication/reset-password.tsx | 72 +- pages/authentication/signin.tsx | 24 +- pages/authentication/signup.tsx | 24 +- pages/index.tsx | 66 +- plopfile.js | 10 +- postcss.config.js | 4 +- tailwind.config.js | 36 +- tools/api.ts | 12 +- tools/authentication/Authentication.ts | 60 +- .../authentication/AuthenticationContext.tsx | 22 +- .../authenticationFromServerSide.ts | 48 +- tools/authentication/index.ts | 18 +- tools/cache.ts | 14 +- tools/cookies.ts | 8 +- tools/handleSocketData.ts | 20 +- 209 files changed, 4093 insertions(+), 4114 deletions(-) diff --git a/.devcontainer/compose.yaml b/.devcontainer/compose.yaml index 727b3a2..7ec0792 100644 --- a/.devcontainer/compose.yaml +++ b/.devcontainer/compose.yaml @@ -1,9 +1,9 @@ services: workspace: build: - context: './' - dockerfile: './Dockerfile' + context: "./" + dockerfile: "./Dockerfile" volumes: - - '..:/workspace:cached' - command: 'sleep infinity' - network_mode: 'host' + - "..:/workspace:cached" + command: "sleep infinity" + network_mode: "host" diff --git a/.github/ISSUE_TEMPLATE/BUG.md b/.github/ISSUE_TEMPLATE/BUG.md index e1fc7e7..d47b126 100644 --- a/.github/ISSUE_TEMPLATE/BUG.md +++ b/.github/ISSUE_TEMPLATE/BUG.md @@ -1,8 +1,8 @@ --- -name: '🐛 Bug Report' -about: 'Report an unexpected problem or unintended behavior.' -title: '[Bug]' -labels: 'bug' +name: "🐛 Bug Report" +about: "Report an unexpected problem or unintended behavior." +title: "[Bug]" +labels: "bug" --- diff --git a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md index 3307418..dc9a49c 100644 --- a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md +++ b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md @@ -1,8 +1,8 @@ --- -name: '✨ Feature Request' -about: 'Suggest a new feature idea.' -title: '[Feature]' -labels: 'feature request' +name: "✨ Feature Request" +about: "Suggest a new feature idea." +title: "[Feature]" +labels: "feature request" --- diff --git a/.github/ISSUE_TEMPLATE/IMPROVEMENT.md b/.github/ISSUE_TEMPLATE/IMPROVEMENT.md index b5bdbb7..e50e289 100644 --- a/.github/ISSUE_TEMPLATE/IMPROVEMENT.md +++ b/.github/ISSUE_TEMPLATE/IMPROVEMENT.md @@ -1,8 +1,8 @@ --- -name: '🔧 Improvement' -about: 'Improve structure/format/performance/refactor/tests of the code.' -title: '[Improvement]' -labels: 'improvement' +name: "🔧 Improvement" +about: "Improve structure/format/performance/refactor/tests of the code." +title: "[Improvement]" +labels: "improvement" --- diff --git a/.github/ISSUE_TEMPLATE/QUESTION.md b/.github/ISSUE_TEMPLATE/QUESTION.md index c18eaa3..df6acdc 100644 --- a/.github/ISSUE_TEMPLATE/QUESTION.md +++ b/.github/ISSUE_TEMPLATE/QUESTION.md @@ -1,8 +1,8 @@ --- -name: '🙋 Question' -about: 'Further information is requested.' -title: '[Question]' -labels: 'question' +name: "🙋 Question" +about: "Further information is requested." +title: "[Question]" +labels: "question" --- ### Question diff --git a/.github/workflows/analyze.yml b/.github/workflows/analyze.yml index 21bc1b7..a2e339f 100644 --- a/.github/workflows/analyze.yml +++ b/.github/workflows/analyze.yml @@ -1,4 +1,4 @@ -name: 'Analyze' +name: "Analyze" on: push: @@ -8,20 +8,20 @@ on: jobs: analyze: - runs-on: 'ubuntu-latest' + runs-on: "ubuntu-latest" strategy: fail-fast: false matrix: - language: ['javascript'] + language: ["javascript"] steps: - - uses: 'actions/checkout@v4.0.0' + - uses: "actions/checkout@v4.0.0" - - name: 'Initialize CodeQL' - uses: 'github/codeql-action/init@v2' + - name: "Initialize CodeQL" + uses: "github/codeql-action/init@v2" with: languages: ${{ matrix.language }} - - name: 'Perform CodeQL Analysis' - uses: 'github/codeql-action/analyze@v2' + - name: "Perform CodeQL Analysis" + uses: "github/codeql-action/analyze@v2" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 044f75d..855162b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: 'Build' +name: "Build" on: push: @@ -8,18 +8,18 @@ on: jobs: build: - runs-on: 'ubuntu-latest' + runs-on: "ubuntu-latest" steps: - - uses: 'actions/checkout@v4.0.0' + - uses: "actions/checkout@v4.0.0" - - name: 'Setup Node.js' - uses: 'actions/setup-node@v3.8.1' + - name: "Setup Node.js" + uses: "actions/setup-node@v3.8.1" with: - node-version: '20.x' - cache: 'npm' + node-version: "20.x" + cache: "npm" - - name: 'Install dependencies' - run: 'npm clean-install' + - name: "Install dependencies" + run: "npm clean-install" - - name: 'Build' - run: 'npm run build' + - name: "Build" + run: "npm run build" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 82c680e..50c0363 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -name: 'Lint' +name: "Lint" on: push: @@ -8,30 +8,30 @@ on: jobs: lint: - runs-on: 'ubuntu-latest' + runs-on: "ubuntu-latest" steps: - - uses: 'actions/checkout@v4.0.0' + - uses: "actions/checkout@v4.0.0" - - name: 'Setup Node.js' - uses: 'actions/setup-node@v3.8.1' + - name: "Setup Node.js" + uses: "actions/setup-node@v3.8.1" with: - node-version: '20.x' - cache: 'npm' + node-version: "20.x" + cache: "npm" - - name: 'Install dependencies' - run: 'npm clean-install' + - name: "Install dependencies" + run: "npm clean-install" - - name: 'lint:commit' + - name: "lint:commit" run: 'npm run lint:commit -- --to "${{ github.sha }}"' - - name: 'lint:editorconfig' - run: 'npm run lint:editorconfig' + - name: "lint:editorconfig" + run: "npm run lint:editorconfig" - - name: 'lint:markdown' - run: 'npm run lint:markdown' + - name: "lint:markdown" + run: "npm run lint:markdown" - - name: 'lint:eslint' - run: 'npm run lint:eslint' + - name: "lint:eslint" + run: "npm run lint:eslint" - - name: 'lint:prettier' - run: 'npm run lint:prettier' + - name: "lint:prettier" + run: "npm run lint:prettier" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bfa4537..fe1aa96 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: 'Release' +name: "Release" on: push: @@ -6,31 +6,31 @@ on: jobs: release: - runs-on: 'ubuntu-latest' + runs-on: "ubuntu-latest" steps: - - uses: 'actions/checkout@v4.0.0' + - uses: "actions/checkout@v4.0.0" with: fetch-depth: 0 persist-credentials: false - - name: 'Import GPG key' - uses: 'crazy-max/ghaction-import-gpg@v6.0.0' + - name: "Import GPG key" + uses: "crazy-max/ghaction-import-gpg@v6.0.0" with: gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} git_user_signingkey: true git_commit_gpgsign: true - - name: 'Setup Node.js' - uses: 'actions/setup-node@v3.8.1' + - name: "Setup Node.js" + uses: "actions/setup-node@v3.8.1" with: - node-version: '20.x' - cache: 'npm' + node-version: "20.x" + cache: "npm" - - name: 'Install dependencies' - run: 'npm clean-install' + - name: "Install dependencies" + run: "npm clean-install" - - name: 'Release' - run: 'npm run release' + - name: "Release" + run: "npm run release" env: GH_TOKEN: ${{ secrets.GH_TOKEN }} GIT_COMMITTER_NAME: ${{ secrets.GIT_NAME }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 82d54c7..7635655 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: 'Test' +name: "Test" on: push: @@ -8,41 +8,41 @@ on: jobs: test-unit: - runs-on: 'ubuntu-latest' + runs-on: "ubuntu-latest" steps: - - uses: 'actions/checkout@v4.0.0' + - uses: "actions/checkout@v4.0.0" - - name: 'Setup Node.js' - uses: 'actions/setup-node@v3.8.1' + - name: "Setup Node.js" + uses: "actions/setup-node@v3.8.1" with: - node-version: '20.x' - cache: 'npm' + node-version: "20.x" + cache: "npm" - - name: 'Install dependencies' - run: 'npm clean-install' + - name: "Install dependencies" + run: "npm clean-install" - - name: 'Unit Test' - run: 'npm run test:unit' + - name: "Unit Test" + run: "npm run test:unit" test-e2e: - runs-on: 'ubuntu-latest' + runs-on: "ubuntu-latest" steps: - - uses: 'actions/checkout@v4.0.0' + - uses: "actions/checkout@v4.0.0" - - name: 'Setup Node.js' - uses: 'actions/setup-node@v3.8.1' + - name: "Setup Node.js" + uses: "actions/setup-node@v3.8.1" with: - node-version: '20.x' - cache: 'npm' + node-version: "20.x" + cache: "npm" - - name: 'Install dependencies' - run: 'npm clean-install' + - name: "Install dependencies" + run: "npm clean-install" - - name: 'Build' - run: 'npm run build' + - name: "Build" + run: "npm run build" - - name: 'html-w3c-validator' - run: 'npm run test:html-w3c-validator' + - name: "html-w3c-validator" + run: "npm run test:html-w3c-validator" - - name: 'End To End (e2e) Test' - run: 'npm run test:e2e' + - name: "End To End (e2e) Test" + run: "npm run test:e2e" diff --git a/.prettierrc.json b/.prettierrc.json index 83ef1ce..cce9d3c 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,6 +1,3 @@ { - "singleQuote": true, - "jsxSingleQuote": true, - "semi": false, - "trailingComma": "none" + "semi": false } diff --git a/Dockerfile b/Dockerfile index 7858a45..84b843b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,16 @@ -FROM node:20.6.1 AS builder-dependencies +FROM node:20.9.0 AS builder-dependencies WORKDIR /usr/src/application COPY ./.npmrc ./ COPY ./package*.json ./ RUN npm clean-install -FROM node:20.6.1 AS builder +FROM node:20.9.0 AS builder WORKDIR /usr/src/application COPY --from=builder-dependencies /usr/src/application/node_modules ./node_modules COPY ./ ./ RUN npm run build -FROM gcr.io/distroless/nodejs20-debian11:latest AS runner +FROM gcr.io/distroless/nodejs20-debian12:latest AS runner WORKDIR /usr/src/application ENV NODE_ENV=production ENV HOSTNAME=0.0.0.0 diff --git a/components/Application/Application.tsx b/components/Application/Application.tsx index 30f4897..7ef5d86 100644 --- a/components/Application/Application.tsx +++ b/components/Application/Application.tsx @@ -1,18 +1,18 @@ -import { useState, useEffect } from 'react' -import Image from 'next/image' -import { PlusIcon, MenuIcon, UsersIcon, XIcon } from '@heroicons/react/solid' -import classNames from 'clsx' -import { useMediaQuery } from 'react-responsive' -import { useSwipeable } from 'react-swipeable' +import { useState, useEffect } from "react" +import Image from "next/image" +import { PlusIcon, MenuIcon, UsersIcon, XIcon } from "@heroicons/react/solid" +import classNames from "clsx" +import { useMediaQuery } from "react-responsive" +import { useSwipeable } from "react-swipeable" -import type { DirectionSidebar } from './Sidebar' -import { Sidebar } from './Sidebar' -import { IconButton } from '../design/IconButton' -import { IconLink } from '../design/IconLink' -import { Guilds } from './Guilds/Guilds' -import { Divider } from '../design/Divider' -import { Members } from './Members' -import { useAuthentication } from '../../tools/authentication' +import type { DirectionSidebar } from "./Sidebar" +import { Sidebar } from "./Sidebar" +import { IconButton } from "../design/IconButton" +import { IconLink } from "../design/IconLink" +import { Guilds } from "./Guilds/Guilds" +import { Divider } from "../design/Divider" +import { Members } from "./Members" +import { useAuthentication } from "../../tools/authentication" export interface ChannelsPath { channelId: number @@ -27,9 +27,9 @@ const isGuildsChannelsPath = (path: any): path is GuildsChannelsPath => { } export type ApplicationPath = - | '/application' - | '/application/guilds/join' - | '/application/guilds/create' + | "/application" + | "/application/guilds/join" + | "/application/guilds/create" | `/application/users/${number}` | `/application/users/settings` | GuildsChannelsPath @@ -51,51 +51,51 @@ export const Application: React.FC< const [mounted, setMounted] = useState(false) const isMobile = useMediaQuery({ - query: '(max-width: 900px)' + query: "(max-width: 900px)", }) const [visibleSidebars, setVisibleSidebars] = useState({ left: !isMobile, - right: false + right: false, }) const handleToggleSidebars = (direction: DirectionSidebar): void => { if (!isMobile) { - if (direction === 'left') { + if (direction === "left") { return setVisibleSidebars({ ...visibleSidebars, - left: !visibleSidebars.left + left: !visibleSidebars.left, }) } - if (direction === 'right') { + if (direction === "right") { return setVisibleSidebars({ ...visibleSidebars, - right: !visibleSidebars.right + right: !visibleSidebars.right, }) } } else { - if (direction === 'right' && visibleSidebars.left) { + if (direction === "right" && visibleSidebars.left) { return setVisibleSidebars({ left: false, - right: true + right: true, }) } - if (direction === 'left' && visibleSidebars.right) { + if (direction === "left" && visibleSidebars.right) { return setVisibleSidebars({ left: true, - right: false + right: false, }) } - if (direction === 'left' && !visibleSidebars.right) { + if (direction === "left" && !visibleSidebars.right) { return setVisibleSidebars({ ...visibleSidebars, - left: !visibleSidebars.left + left: !visibleSidebars.left, }) } - if (direction === 'right' && !visibleSidebars.left) { + if (direction === "right" && !visibleSidebars.left) { return setVisibleSidebars({ ...visibleSidebars, - right: !visibleSidebars.right + right: !visibleSidebars.right, }) } } @@ -105,7 +105,7 @@ export const Application: React.FC< if (isMobile && (visibleSidebars.left || visibleSidebars.right)) { return setVisibleSidebars({ left: false, - right: false + right: false, }) } } @@ -120,7 +120,7 @@ export const Application: React.FC< } setVisibleSidebars({ ...visibleSidebars, - left: true + left: true, }) }, onSwipedLeft: () => { @@ -130,10 +130,10 @@ export const Application: React.FC< } setVisibleSidebars({ ...visibleSidebars, - right: true + right: true, }) } - } + }, }) useEffect(() => { @@ -146,28 +146,28 @@ export const Application: React.FC< return ( <> -
+
{ - return handleToggleSidebars('left') + return handleToggleSidebars("left") }} > {!visibleSidebars.left ? : }
{title}
-
- {title.startsWith('#') && ( +
+ {title.startsWith("#") && ( { - return handleToggleSidebars('right') + return handleToggleSidebars("right") }} > {!visibleSidebars.right ? : } @@ -177,26 +177,26 @@ export const Application: React.FC<
-
+
{"Users's - + @@ -219,14 +219,14 @@ export const Application: React.FC<
{children} @@ -234,7 +234,7 @@ export const Application: React.FC< {isGuildsChannelsPath(path) && ( diff --git a/components/Application/ChannelSettings/ChannelSettings.tsx b/components/Application/ChannelSettings/ChannelSettings.tsx index 6d24694..a22c224 100644 --- a/components/Application/ChannelSettings/ChannelSettings.tsx +++ b/components/Application/ChannelSettings/ChannelSettings.tsx @@ -1,26 +1,26 @@ -import { useRouter } from 'next/router' -import { useState } from 'react' -import { Form, useForm } from 'react-component-form' -import useTranslation from 'next-translate/useTranslation' -import classNames from 'clsx' -import axios from 'axios' -import type { HandleUseFormCallback } from 'react-component-form' +import { useRouter } from "next/router" +import { useState } from "react" +import { Form, useForm } from "react-component-form" +import useTranslation from "next-translate/useTranslation" +import classNames from "clsx" +import axios from "axios" +import type { HandleUseFormCallback } from "react-component-form" -import { FormState } from '../../design/FormState' -import { useGuildMember } from '../../../contexts/GuildMember' -import { Input } from '../../design/Input' -import { Button } from '../../design/Button' -import { useAuthentication } from '../../../tools/authentication' +import { FormState } from "../../design/FormState" +import { useGuildMember } from "../../../contexts/GuildMember" +import { Input } from "../../design/Input" +import { Button } from "../../design/Button" +import { useAuthentication } from "../../../tools/authentication" import type { Channel, - ChannelWithDefaultChannelId -} from '../../../models/Channel' -import { channelSchema } from '../../../models/Channel' -import { ConfirmPopup } from '../ConfirmPopup' -import { useFormTranslation } from '../../../hooks/useFormTranslation' + ChannelWithDefaultChannelId, +} from "../../../models/Channel" +import { channelSchema } from "../../../models/Channel" +import { ConfirmPopup } from "../ConfirmPopup" +import { useFormTranslation } from "../../../hooks/useFormTranslation" const schema = { - name: channelSchema.name + name: channelSchema.name, } export interface ChannelSettingsProps { @@ -36,7 +36,7 @@ export const ChannelSettings: React.FC = (props) => { const { channel } = props const [inputValues, setInputValues] = useState({ - name: channel.name + name: channel.name, }) const [confirmation, setConfirmation] = useState(false) @@ -51,7 +51,7 @@ export const ChannelSettings: React.FC = (props) => { message, errors, setFetchState, - setMessage + setMessage, } = useForm(schema) const { getFirstErrorTranslation } = useFormTranslation() @@ -63,8 +63,8 @@ export const ChannelSettings: React.FC = (props) => { return null } catch (error) { return { - type: 'error', - message: 'errors:server-error' + type: "error", + message: "errors:server-error", } } } @@ -75,7 +75,7 @@ export const ChannelSettings: React.FC = (props) => { setInputValues((oldInputValues) => { return { ...oldInputValues, - [event.target.name]: event.target.value + [event.target.name]: event.target.value, } }) } @@ -84,15 +84,15 @@ export const ChannelSettings: React.FC = (props) => { try { const { data } = await authentication.api.delete( - `/channels/${channel.id}` + `/channels/${channel.id}`, ) await router.push(`/application/${guild.id}/${data.defaultChannelId}`) } catch (error) { - setFetchState('error') + setFetchState("error") if (axios.isAxiosError(error) && error.response?.status === 400) { - setMessage('application:delete-channel-only-one') + setMessage("application:delete-channel-only-one") } else { - setMessage('errors:server-error') + setMessage("errors:server-error") } } } @@ -101,37 +101,37 @@ export const ChannelSettings: React.FC = (props) => { <>
-
-
-
+
+
+
-
-
-
@@ -139,17 +139,17 @@ export const ChannelSettings: React.FC = (props) => {
diff --git a/components/Application/ChannelSettings/index.ts b/components/Application/ChannelSettings/index.ts index 8bfe23a..105d5ef 100644 --- a/components/Application/ChannelSettings/index.ts +++ b/components/Application/ChannelSettings/index.ts @@ -1 +1 @@ -export * from './ChannelSettings' +export * from "./ChannelSettings" diff --git a/components/Application/Channels/Channel.tsx b/components/Application/Channels/Channel.tsx index c31b3d2..331c2d4 100644 --- a/components/Application/Channels/Channel.tsx +++ b/components/Application/Channels/Channel.tsx @@ -1,13 +1,13 @@ -import { memo } from 'react' -import classNames from 'clsx' -import Link from 'next/link' -import { useRouter } from 'next/router' -import { CogIcon } from '@heroicons/react/solid' +import { memo } from "react" +import classNames from "clsx" +import Link from "next/link" +import { useRouter } from "next/router" +import { CogIcon } from "@heroicons/react/solid" -import type { GuildsChannelsPath } from '../Application' -import type { Channel as ChannelType } from '../../../models/Channel' -import { useGuildMember } from '../../../contexts/GuildMember' -import { IconButton } from '../../design/IconButton' +import type { GuildsChannelsPath } from "../Application" +import type { Channel as ChannelType } from "../../../models/Channel" +import { useGuildMember } from "../../../contexts/GuildMember" +import { IconButton } from "../../design/IconButton" export interface ChannelProps { path: GuildsChannelsPath @@ -25,24 +25,24 @@ const ChannelMemo: React.FC = (props) => { - + # {channel.name} {member.isOwner && ( { await router.push( - `/application/${channel.guildId}/${channel.id}/settings` + `/application/${channel.guildId}/${channel.id}/settings`, ) }} - className='bg-unherit absolute -right-10 h-full w-8 transition-all group-hover:right-0 group-hover:shadow-lg dark:group-hover:bg-gray-600' - title='Settings' + className="bg-unherit absolute -right-10 h-full w-8 transition-all group-hover:right-0 group-hover:shadow-lg dark:group-hover:bg-gray-600" + title="Settings" > diff --git a/components/Application/Channels/Channels.tsx b/components/Application/Channels/Channels.tsx index 00968b2..f6a9e22 100644 --- a/components/Application/Channels/Channels.tsx +++ b/components/Application/Channels/Channels.tsx @@ -1,9 +1,9 @@ -import InfiniteScroll from 'react-infinite-scroll-component' +import InfiniteScroll from "react-infinite-scroll-component" -import { useChannels } from '../../../contexts/Channels' -import type { GuildsChannelsPath } from '../Application' -import { Loader } from '../../design/Loader' -import { Channel } from './Channel' +import { useChannels } from "../../../contexts/Channels" +import type { GuildsChannelsPath } from "../Application" +import { Loader } from "../../design/Loader" +import { Channel } from "./Channel" export interface ChannelsProps { path: GuildsChannelsPath @@ -16,12 +16,12 @@ export const Channels: React.FC = (props) => { return (
= ({ ...props }) => {
Illustration -
-

{props.title}

-
+
+

{props.title}

+
diff --git a/components/Application/ConfirmPopup/index.ts b/components/Application/ConfirmPopup/index.ts index 5dcf1f2..37c02a5 100644 --- a/components/Application/ConfirmPopup/index.ts +++ b/components/Application/ConfirmPopup/index.ts @@ -1 +1 @@ -export * from './ConfirmPopup' +export * from "./ConfirmPopup" diff --git a/components/Application/CreateChannel/CreateChannel.tsx b/components/Application/CreateChannel/CreateChannel.tsx index 0f43901..d8dd1b6 100644 --- a/components/Application/CreateChannel/CreateChannel.tsx +++ b/components/Application/CreateChannel/CreateChannel.tsx @@ -1,20 +1,20 @@ -import { useRouter } from 'next/router' -import useTranslation from 'next-translate/useTranslation' -import { Form, useForm } from 'react-component-form' -import type { HandleUseFormCallback } from 'react-component-form' +import { useRouter } from "next/router" +import useTranslation from "next-translate/useTranslation" +import { Form, useForm } from "react-component-form" +import type { HandleUseFormCallback } from "react-component-form" -import { useAuthentication } from '../../../tools/authentication' -import { Input } from '../../design/Input' -import { Main } from '../../design/Main' -import { Button } from '../../design/Button' -import { FormState } from '../../design/FormState' -import type { Channel } from '../../../models/Channel' -import { channelSchema } from '../../../models/Channel' -import { useGuildMember } from '../../../contexts/GuildMember' -import { useFormTranslation } from '../../../hooks/useFormTranslation' +import { useAuthentication } from "../../../tools/authentication" +import { Input } from "../../design/Input" +import { Main } from "../../design/Main" +import { Button } from "../../design/Button" +import { FormState } from "../../design/FormState" +import type { Channel } from "../../../models/Channel" +import { channelSchema } from "../../../models/Channel" +import { useGuildMember } from "../../../contexts/GuildMember" +import { useFormTranslation } from "../../../hooks/useFormTranslation" const schema = { - name: channelSchema.name + name: channelSchema.name, } export const CreateChannel: React.FC = () => { @@ -31,38 +31,38 @@ export const CreateChannel: React.FC = () => { try { const { data: channel } = await authentication.api.post( `/guilds/${guild.id}/channels`, - formData + formData, ) await router.push(`/application/${guild.id}/${channel.id}`) return null } catch (error) { return { - type: 'error', - message: 'errors:server-error' + type: "error", + message: "errors:server-error", } } } return (
-
+
- +
) } diff --git a/components/Application/CreateChannel/index.ts b/components/Application/CreateChannel/index.ts index b4a5a4f..02a8060 100644 --- a/components/Application/CreateChannel/index.ts +++ b/components/Application/CreateChannel/index.ts @@ -1 +1 @@ -export * from './CreateChannel' +export * from "./CreateChannel" diff --git a/components/Application/CreateGuild/CreateGuild.tsx b/components/Application/CreateGuild/CreateGuild.tsx index 84b203c..4459a89 100644 --- a/components/Application/CreateGuild/CreateGuild.tsx +++ b/components/Application/CreateGuild/CreateGuild.tsx @@ -1,22 +1,22 @@ -import { useRouter } from 'next/router' -import useTranslation from 'next-translate/useTranslation' -import { Form, useForm } from 'react-component-form' -import type { AxiosResponse } from 'axios' -import type { HandleUseFormCallback } from 'react-component-form' +import { useRouter } from "next/router" +import useTranslation from "next-translate/useTranslation" +import { Form, useForm } from "react-component-form" +import type { AxiosResponse } from "axios" +import type { HandleUseFormCallback } from "react-component-form" -import { useAuthentication } from '../../../tools/authentication' -import type { GuildComplete } from '../../../models/Guild' -import { guildSchema } from '../../../models/Guild' -import { Input } from '../../design/Input' -import { Main } from '../../design/Main' -import { Button } from '../../design/Button' -import { FormState } from '../../design/FormState' -import { Textarea } from '../../design/Textarea' -import { useFormTranslation } from '../../../hooks/useFormTranslation' +import { useAuthentication } from "../../../tools/authentication" +import type { GuildComplete } from "../../../models/Guild" +import { guildSchema } from "../../../models/Guild" +import { Input } from "../../design/Input" +import { Main } from "../../design/Main" +import { Button } from "../../design/Button" +import { FormState } from "../../design/FormState" +import { Textarea } from "../../design/Textarea" +import { useFormTranslation } from "../../../hooks/useFormTranslation" const schema = { name: guildSchema.name, - description: guildSchema.description + description: guildSchema.description, } export const CreateGuild: React.FC = () => { @@ -33,44 +33,44 @@ export const CreateGuild: React.FC = () => { const { data } = await authentication.api.post< any, AxiosResponse<{ guild: GuildComplete }> - >('/guilds', { name: formData.name, description: formData.description }) + >("/guilds", { name: formData.name, description: formData.description }) const guildId = data.guild.id const channel = data.guild.channels[0] if (channel == null) { - throw new Error('No channel found') + throw new Error("No channel found") } const channelId = channel.id await router.push(`/application/${guildId}/${channelId}`) return null } catch (error) { return { - type: 'error', - message: 'errors:server-error' + type: "error", + message: "errors:server-error", } } } return (
-
+