Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
c96385edd5 | |||
cd1a477324 | |||
b5089f7f0b | |||
67a1699102 | |||
e8a9ce4e69 | |||
8f5bc2fe21 | |||
109da1be71 | |||
1ea78821b0 | |||
12ceefd650 | |||
734357b396 | |||
ccaf5234ed | |||
5d350e8db9 | |||
cd164538de | |||
d51de554d6 | |||
a068d31d14 | |||
3d185bf044 | |||
6cfee0f6a3 |
@ -1,2 +1 @@
|
||||
ARG VARIANT="16"
|
||||
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}
|
||||
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:18
|
||||
|
@ -10,8 +10,6 @@
|
||||
"editorconfig.editorconfig",
|
||||
"esbenp.prettier-vscode",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"divlo.vscode-styled-jsx-syntax",
|
||||
"divlo.vscode-styled-jsx-languageserver",
|
||||
"bradlc.vscode-tailwindcss",
|
||||
"mikestead.dotenv",
|
||||
"davidanson.vscode-markdownlint",
|
||||
|
@ -1,12 +1,5 @@
|
||||
.vscode
|
||||
.git
|
||||
.env
|
||||
.*
|
||||
!.npmrc
|
||||
build
|
||||
.next
|
||||
coverage
|
||||
node_modules
|
||||
tmp
|
||||
temp
|
||||
.DS_Store
|
||||
.lighthouseci
|
||||
.vercel
|
||||
|
@ -1,3 +1,3 @@
|
||||
COMPOSE_PROJECT_NAME=thream-website
|
||||
NEXT_PUBLIC_API_URL=http://localhost:8080
|
||||
NEXT_PUBLIC_API_URL=http://127.0.0.1:8080
|
||||
PORT=3000
|
||||
|
6
.github/workflows/analyze.yml
vendored
6
.github/workflows/analyze.yml
vendored
@ -16,12 +16,12 @@ jobs:
|
||||
language: ['javascript']
|
||||
|
||||
steps:
|
||||
- uses: 'actions/checkout@v3.0.0'
|
||||
- uses: 'actions/checkout@v3.3.0'
|
||||
|
||||
- name: 'Initialize CodeQL'
|
||||
uses: 'github/codeql-action/init@v1'
|
||||
uses: 'github/codeql-action/init@v2'
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
|
||||
- name: 'Perform CodeQL Analysis'
|
||||
uses: 'github/codeql-action/analyze@v1'
|
||||
uses: 'github/codeql-action/analyze@v2'
|
||||
|
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
@ -10,12 +10,12 @@ jobs:
|
||||
build:
|
||||
runs-on: 'ubuntu-latest'
|
||||
steps:
|
||||
- uses: 'actions/checkout@v3.0.0'
|
||||
- uses: 'actions/checkout@v3.3.0'
|
||||
|
||||
- name: 'Use Node.js'
|
||||
uses: 'actions/setup-node@v3.0.0'
|
||||
uses: 'actions/setup-node@v3.6.0'
|
||||
with:
|
||||
node-version: '16.x'
|
||||
node-version: '18.x'
|
||||
cache: 'npm'
|
||||
|
||||
- name: 'Install'
|
||||
|
15
.github/workflows/lint.yml
vendored
15
.github/workflows/lint.yml
vendored
@ -10,12 +10,12 @@ jobs:
|
||||
lint:
|
||||
runs-on: 'ubuntu-latest'
|
||||
steps:
|
||||
- uses: 'actions/checkout@v3.0.0'
|
||||
- uses: 'actions/checkout@v3.3.0'
|
||||
|
||||
- name: 'Use Node.js'
|
||||
uses: 'actions/setup-node@v3.0.0'
|
||||
uses: 'actions/setup-node@v3.6.0'
|
||||
with:
|
||||
node-version: '16.x'
|
||||
node-version: '18.x'
|
||||
cache: 'npm'
|
||||
|
||||
- name: 'Install'
|
||||
@ -30,8 +30,8 @@ jobs:
|
||||
- name: 'lint:markdown'
|
||||
run: 'npm run lint:markdown'
|
||||
|
||||
- name: 'lint:typescript'
|
||||
run: 'npm run lint:typescript'
|
||||
- name: 'lint:eslint'
|
||||
run: 'npm run lint:eslint'
|
||||
|
||||
- name: 'lint:prettier'
|
||||
run: 'npm run lint:prettier'
|
||||
@ -40,8 +40,3 @@ jobs:
|
||||
uses: 'dotenv-linter/action-dotenv-linter@v2'
|
||||
with:
|
||||
github_token: ${{ secrets.github_token }}
|
||||
|
||||
- name: 'lint:docker'
|
||||
uses: 'hadolint/hadolint-action@v1.6.0'
|
||||
with:
|
||||
dockerfile: './Dockerfile'
|
||||
|
6
.github/workflows/release.yml
vendored
6
.github/workflows/release.yml
vendored
@ -8,7 +8,7 @@ jobs:
|
||||
release:
|
||||
runs-on: 'ubuntu-latest'
|
||||
steps:
|
||||
- uses: 'actions/checkout@v3.0.0'
|
||||
- uses: 'actions/checkout@v3.3.0'
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
@ -21,9 +21,9 @@ jobs:
|
||||
git_commit_gpgsign: true
|
||||
|
||||
- name: 'Use Node.js'
|
||||
uses: 'actions/setup-node@v2.4.0'
|
||||
uses: 'actions/setup-node@v3.6.0'
|
||||
with:
|
||||
node-version: '16.x'
|
||||
node-version: '18.x'
|
||||
cache: 'npm'
|
||||
|
||||
- name: 'Install'
|
||||
|
18
.github/workflows/test.yml
vendored
18
.github/workflows/test.yml
vendored
@ -10,12 +10,12 @@ jobs:
|
||||
test-unit:
|
||||
runs-on: 'ubuntu-latest'
|
||||
steps:
|
||||
- uses: 'actions/checkout@v3.0.0'
|
||||
- uses: 'actions/checkout@v3.3.0'
|
||||
|
||||
- name: 'Use Node.js'
|
||||
uses: 'actions/setup-node@v3.0.0'
|
||||
uses: 'actions/setup-node@v3.6.0'
|
||||
with:
|
||||
node-version: '16.x'
|
||||
node-version: '18.x'
|
||||
cache: 'npm'
|
||||
|
||||
- name: 'Install'
|
||||
@ -27,12 +27,12 @@ jobs:
|
||||
test-lighthouse:
|
||||
runs-on: 'ubuntu-latest'
|
||||
steps:
|
||||
- uses: 'actions/checkout@v3.0.0'
|
||||
- uses: 'actions/checkout@v3.3.0'
|
||||
|
||||
- name: 'Use Node.js'
|
||||
uses: 'actions/setup-node@v3.0.0'
|
||||
uses: 'actions/setup-node@v3.6.0'
|
||||
with:
|
||||
node-version: '16.x'
|
||||
node-version: '18.x'
|
||||
cache: 'npm'
|
||||
|
||||
- name: 'Install'
|
||||
@ -52,12 +52,12 @@ jobs:
|
||||
test-e2e:
|
||||
runs-on: 'ubuntu-latest'
|
||||
steps:
|
||||
- uses: 'actions/checkout@v3.0.0'
|
||||
- uses: 'actions/checkout@v3.3.0'
|
||||
|
||||
- name: 'Use Node.js'
|
||||
uses: 'actions/setup-node@v3.0.0'
|
||||
uses: 'actions/setup-node@v3.6.0'
|
||||
with:
|
||||
node-version: '16.x'
|
||||
node-version: '18.x'
|
||||
cache: 'npm'
|
||||
|
||||
- name: 'Install'
|
||||
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -49,3 +49,8 @@ npm-debug.log*
|
||||
.DS_Store
|
||||
.lighthouseci
|
||||
.vercel
|
||||
*.hbs
|
||||
|
||||
# typescript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
|
@ -1,9 +1,9 @@
|
||||
{
|
||||
"urls": [
|
||||
"http://localhost:3000/",
|
||||
"http://localhost:3000/authentication/forgot-password",
|
||||
"http://localhost:3000/authentication/reset-password",
|
||||
"http://localhost:3000/authentication/signin",
|
||||
"http://localhost:3000/authentication/signup"
|
||||
"http://127.0.0.1:3000/",
|
||||
"http://127.0.0.1:3000/authentication/forgot-password",
|
||||
"http://127.0.0.1:3000/authentication/reset-password",
|
||||
"http://127.0.0.1:3000/authentication/signin",
|
||||
"http://127.0.0.1:3000/authentication/signup"
|
||||
]
|
||||
}
|
||||
|
@ -5,11 +5,11 @@
|
||||
"startServerReadyPattern": "ready on",
|
||||
"startServerReadyTimeout": 20000,
|
||||
"url": [
|
||||
"http://localhost:3000/",
|
||||
"http://localhost:3000/authentication/forgot-password",
|
||||
"http://localhost:3000/authentication/reset-password",
|
||||
"http://localhost:3000/authentication/signin",
|
||||
"http://localhost:3000/authentication/signup"
|
||||
"http://127.0.0.1:3000/",
|
||||
"http://127.0.0.1:3000/authentication/forgot-password",
|
||||
"http://127.0.0.1:3000/authentication/reset-password",
|
||||
"http://127.0.0.1:3000/authentication/signin",
|
||||
"http://127.0.0.1:3000/authentication/signup"
|
||||
],
|
||||
"numberOfRuns": 1
|
||||
},
|
||||
|
@ -1,11 +1,5 @@
|
||||
{
|
||||
"config": {
|
||||
"default": true,
|
||||
"MD013": false,
|
||||
"MD024": false,
|
||||
"MD033": false,
|
||||
"MD041": false
|
||||
},
|
||||
"globs": ["**/*.{md,mdx}"],
|
||||
"ignores": ["**/node_modules"]
|
||||
"ignores": ["**/node_modules"],
|
||||
"customRules": ["markdownlint-rule-relative-links"]
|
||||
}
|
||||
|
7
.markdownlint.json
Normal file
7
.markdownlint.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"default": true,
|
||||
"relative-links": true,
|
||||
"extends": "markdownlint/style/prettier",
|
||||
"MD033": false,
|
||||
"MD041": false
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
.next
|
||||
.lighthouseci
|
||||
coverage
|
||||
node_modules
|
||||
**/workbox-*.js
|
||||
**/sw.js
|
||||
*.hbs
|
2
.vscode/extensions.json
vendored
2
.vscode/extensions.json
vendored
@ -3,8 +3,6 @@
|
||||
"editorconfig.editorconfig",
|
||||
"esbenp.prettier-vscode",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"divlo.vscode-styled-jsx-syntax",
|
||||
"divlo.vscode-styled-jsx-languageserver",
|
||||
"bradlc.vscode-tailwindcss",
|
||||
"mikestead.dotenv",
|
||||
"davidanson.vscode-markdownlint",
|
||||
|
@ -16,6 +16,7 @@ All work on **Thream/website** happens directly on [GitHub](https://github.com/T
|
||||
- Suggest a new feature idea.
|
||||
- Correct spelling errors, improvements or additions to documentation files.
|
||||
- Improve structure/format/performance/refactor/tests of the code.
|
||||
- [Add translations](#add-a-translation).
|
||||
|
||||
## Pull Requests
|
||||
|
||||
@ -61,3 +62,15 @@ Scopes define what part of the code changed.
|
||||
git commit -m "feat(components): add Button"
|
||||
git commit -m "docs(readme): update installation process"
|
||||
```
|
||||
|
||||
## Add a translation
|
||||
|
||||
[Reference issue](https://github.com/Thream/website/issues/24)
|
||||
|
||||
Feel free to contribute to Thream and add new languages, we would appreciate your help!
|
||||
|
||||
To add a new language:
|
||||
|
||||
- `npm install`
|
||||
- `npm run generate`
|
||||
- Start editing JSON files with the translation in `locales/{{locale}}` (e.g: `locales/en`)
|
||||
|
30
Dockerfile
30
Dockerfile
@ -1,23 +1,21 @@
|
||||
FROM node:16.17.0 AS dependencies
|
||||
WORKDIR /usr/src/app
|
||||
FROM node:18.13.0 AS builder-dependencies
|
||||
WORKDIR /usr/src/application
|
||||
COPY ./package*.json ./
|
||||
RUN npm install
|
||||
|
||||
FROM node:16.17.0 AS builder
|
||||
WORKDIR /usr/src/app
|
||||
FROM node:18.13.0 AS builder
|
||||
WORKDIR /usr/src/application
|
||||
COPY --from=builder-dependencies /usr/src/application/node_modules ./node_modules
|
||||
COPY ./ ./
|
||||
COPY --from=dependencies /usr/src/app/node_modules ./node_modules
|
||||
RUN npm run build
|
||||
|
||||
FROM node:16.17.0 AS runner
|
||||
WORKDIR /usr/src/app
|
||||
FROM gcr.io/distroless/nodejs18-debian11:latest AS runner
|
||||
WORKDIR /usr/src/application
|
||||
ENV NODE_ENV=production
|
||||
COPY --from=builder /usr/src/app/next.config.js ./next.config.js
|
||||
COPY --from=builder /usr/src/app/public ./public
|
||||
COPY --from=builder /usr/src/app/.next ./.next
|
||||
COPY --from=builder /usr/src/app/i18n.json ./i18n.json
|
||||
COPY --from=builder /usr/src/app/locales ./locales
|
||||
COPY --from=builder /usr/src/app/pages ./pages
|
||||
COPY --from=builder /usr/src/app/node_modules ./node_modules
|
||||
RUN npx next telemetry disable
|
||||
CMD ["node_modules/.bin/next", "start", "--port", "${PORT}"]
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
COPY --from=builder /usr/src/application/.next/standalone ./
|
||||
COPY --from=builder /usr/src/application/.next/static ./.next/static
|
||||
COPY --from=builder /usr/src/application/public ./public
|
||||
COPY --from=builder /usr/src/application/locales ./locales
|
||||
COPY --from=builder /usr/src/application/next.config.js ./next.config.js
|
||||
CMD ["./server.js"]
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
Thream's website to stay close with your friends and communities.
|
||||
|
||||
It uses [Thream/api](https://github.com/Thream/api) [v1.2.0](https://github.com/Thream/api/releases/tag/v1.2.0).
|
||||
It uses [Thream/api](https://github.com/Thream/api) [v1.2.4](https://github.com/Thream/api/releases/tag/v1.2.4).
|
||||
|
||||
## ⚙️ Getting Started
|
||||
|
||||
@ -61,7 +61,7 @@ docker compose up --build
|
||||
|
||||
#### Services started
|
||||
|
||||
- website : `http://localhost:3000`
|
||||
- website : `http://127.0.0.1:3000`
|
||||
|
||||
## 💡 Contributing
|
||||
|
||||
|
@ -5,7 +5,8 @@ import classNames from 'clsx'
|
||||
import { useMediaQuery } from 'react-responsive'
|
||||
import { useSwipeable } from 'react-swipeable'
|
||||
|
||||
import { Sidebar, DirectionSidebar } from './Sidebar'
|
||||
import type { DirectionSidebar } from './Sidebar'
|
||||
import { Sidebar } from './Sidebar'
|
||||
import { IconButton } from '../design/IconButton'
|
||||
import { IconLink } from '../design/IconLink'
|
||||
import { Guilds } from './Guilds/Guilds'
|
||||
@ -148,7 +149,9 @@ export const Application: React.FC<
|
||||
<header className='z-50 flex h-16 items-center justify-between bg-gray-200 px-2 py-3 shadow-lg dark:bg-gray-800'>
|
||||
<IconButton
|
||||
className='h-10 w-10 p-2'
|
||||
onClick={() => handleToggleSidebars('left')}
|
||||
onClick={() => {
|
||||
return handleToggleSidebars('left')
|
||||
}}
|
||||
>
|
||||
{!visibleSidebars.left ? <MenuIcon /> : <XIcon />}
|
||||
</IconButton>
|
||||
@ -163,7 +166,9 @@ export const Application: React.FC<
|
||||
<IconButton
|
||||
data-cy='icon-button-right-sidebar-members'
|
||||
className='h-10 w-10 p-2'
|
||||
onClick={() => handleToggleSidebars('right')}
|
||||
onClick={() => {
|
||||
return handleToggleSidebars('right')
|
||||
}}
|
||||
>
|
||||
{!visibleSidebars.right ? <UsersIcon /> : <XIcon />}
|
||||
</IconButton>
|
||||
|
@ -11,11 +11,11 @@ import { useGuildMember } from '../../../contexts/GuildMember'
|
||||
import { Input } from '../../design/Input'
|
||||
import { Button } from '../../design/Button'
|
||||
import { useAuthentication } from '../../../tools/authentication'
|
||||
import {
|
||||
import type {
|
||||
Channel,
|
||||
channelSchema,
|
||||
ChannelWithDefaultChannelId
|
||||
} from '../../../models/Channel'
|
||||
import { channelSchema } from '../../../models/Channel'
|
||||
import { ConfirmPopup } from '../ConfirmPopup'
|
||||
import { useFormTranslation } from '../../../hooks/useFormTranslation'
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
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 { GuildsChannelsPath } from '../Application'
|
||||
import { Channel as ChannelType } from '../../../models/Channel'
|
||||
import type { GuildsChannelsPath } from '../Application'
|
||||
import type { Channel as ChannelType } from '../../../models/Channel'
|
||||
import { useGuildMember } from '../../../contexts/GuildMember'
|
||||
import { IconButton } from '../../design/IconButton'
|
||||
|
||||
@ -14,42 +15,40 @@ export interface ChannelProps {
|
||||
selected?: boolean
|
||||
}
|
||||
|
||||
export const Channel: React.FC<ChannelProps> = (props) => {
|
||||
const ChannelMemo: React.FC<ChannelProps> = (props) => {
|
||||
const { channel, path, selected = false } = props
|
||||
const router = useRouter()
|
||||
|
||||
const { member } = useGuildMember()
|
||||
|
||||
return (
|
||||
<Link href={`/application/${path.guildId}/${channel.id}`}>
|
||||
<a
|
||||
className={classNames(
|
||||
'group relative my-3 mx-3 flex items-center justify-between overflow-hidden rounded-lg py-2 text-sm transition-all duration-200 hover:bg-gray-100 dark:hover:bg-gray-600',
|
||||
{
|
||||
'font-semibold text-green-800 dark:text-green-400': selected
|
||||
}
|
||||
)}
|
||||
>
|
||||
<span
|
||||
className='max-[315px] ml-2 mr-4 break-all'
|
||||
data-cy='channel-name'
|
||||
<Link
|
||||
href={`/application/${path.guildId}/${channel.id}`}
|
||||
className={classNames(
|
||||
'group relative my-3 mx-3 flex items-center justify-between overflow-hidden rounded-lg py-2 text-sm transition-all duration-200 hover:bg-gray-100 dark:hover:bg-gray-600',
|
||||
{
|
||||
'font-semibold text-green-800 dark:text-green-400': selected
|
||||
}
|
||||
)}
|
||||
>
|
||||
<span className='max-[315px] ml-2 mr-4 break-all' data-cy='channel-name'>
|
||||
# {channel.name}
|
||||
</span>
|
||||
{member.isOwner && (
|
||||
<IconButton
|
||||
onClick={async () => {
|
||||
await router.push(
|
||||
`/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'
|
||||
>
|
||||
# {channel.name}
|
||||
</span>
|
||||
{member.isOwner && (
|
||||
<IconButton
|
||||
onClick={async () => {
|
||||
await router.push(
|
||||
`/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'
|
||||
>
|
||||
<CogIcon height={20} width={20} />
|
||||
</IconButton>
|
||||
)}
|
||||
</a>
|
||||
<CogIcon height={20} width={20} />
|
||||
</IconButton>
|
||||
)}
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
||||
export const Channel = memo(ChannelMemo)
|
||||
|
@ -1,7 +1,7 @@
|
||||
import InfiniteScroll from 'react-infinite-scroll-component'
|
||||
|
||||
import { useChannels } from '../../../contexts/Channels'
|
||||
import { GuildsChannelsPath } from '../Application'
|
||||
import type { GuildsChannelsPath } from '../Application'
|
||||
import { Loader } from '../../design/Loader'
|
||||
import { Channel } from './Channel'
|
||||
|
||||
|
@ -17,7 +17,9 @@ export const ConfirmPopup: React.FC<ConfirmPopupProps> = ({ ...props }) => {
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
|
||||
const handleYesLoading = async (): Promise<void> => {
|
||||
setIsLoading((isLoading) => !isLoading)
|
||||
setIsLoading((isLoading) => {
|
||||
return !isLoading
|
||||
})
|
||||
await props.handleYes()
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,8 @@ import { Input } from '../../design/Input'
|
||||
import { Main } from '../../design/Main'
|
||||
import { Button } from '../../design/Button'
|
||||
import { FormState } from '../../design/FormState'
|
||||
import { Channel, channelSchema } from '../../../models/Channel'
|
||||
import type { Channel } from '../../../models/Channel'
|
||||
import { channelSchema } from '../../../models/Channel'
|
||||
import { useGuildMember } from '../../../contexts/GuildMember'
|
||||
import { useFormTranslation } from '../../../hooks/useFormTranslation'
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
import { useRouter } from 'next/router'
|
||||
import useTranslation from 'next-translate/useTranslation'
|
||||
import { Form, useForm } from 'react-component-form'
|
||||
import { AxiosResponse } from 'axios'
|
||||
import type { AxiosResponse } from 'axios'
|
||||
import type { HandleUseFormCallback } from 'react-component-form'
|
||||
|
||||
import { useAuthentication } from '../../../tools/authentication'
|
||||
import { GuildComplete, guildSchema } from '../../../models/Guild'
|
||||
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'
|
||||
@ -22,19 +23,23 @@ export const CreateGuild: React.FC = () => {
|
||||
const { t } = useTranslation()
|
||||
const router = useRouter()
|
||||
|
||||
const { handleUseForm, fetchState, message, errors } = useForm(schema as any)
|
||||
const { handleUseForm, fetchState, message, errors } = useForm(schema)
|
||||
const { getFirstErrorTranslation } = useFormTranslation()
|
||||
|
||||
const { authentication } = useAuthentication()
|
||||
|
||||
const onSubmit: HandleUseFormCallback<any> = async (formData) => {
|
||||
const onSubmit: HandleUseFormCallback<typeof schema> = async (formData) => {
|
||||
try {
|
||||
const { data } = await authentication.api.post<
|
||||
any,
|
||||
AxiosResponse<{ guild: GuildComplete }>
|
||||
>('/guilds', { name: formData.name, description: formData.description })
|
||||
const guildId = data.guild.id
|
||||
const channelId = data.guild.channels[0].id
|
||||
const channel = data.guild.channels[0]
|
||||
if (channel == null) {
|
||||
throw new Error('No channel found')
|
||||
}
|
||||
const channelId = channel.id
|
||||
await router.push(`/application/${guildId}/${channelId}`)
|
||||
return null
|
||||
} catch (error) {
|
||||
|
@ -5,7 +5,7 @@ import { useGuildMember } from '../../../contexts/GuildMember'
|
||||
import { Divider } from '../../design/Divider'
|
||||
import { Channels } from '../Channels'
|
||||
import { IconButton } from '../../design/IconButton'
|
||||
import { GuildsChannelsPath } from '..'
|
||||
import type { GuildsChannelsPath } from '..'
|
||||
|
||||
export interface GuildLeftSidebarProps {
|
||||
path: GuildsChannelsPath
|
||||
@ -28,20 +28,24 @@ export const GuildLeftSidebar: React.FC<GuildLeftSidebarProps> = (props) => {
|
||||
<Divider />
|
||||
<div className='mb-1 flex items-center justify-center space-x-6 p-2'>
|
||||
{member.isOwner && (
|
||||
<Link href={`/application/${path.guildId}/channels/create`} passHref>
|
||||
<a data-cy='link-add-channel'>
|
||||
<IconButton className='h-10 w-10' title='Add a Channel'>
|
||||
<PlusIcon />
|
||||
</IconButton>
|
||||
</a>
|
||||
<Link
|
||||
href={`/application/${path.guildId}/channels/create`}
|
||||
passHref
|
||||
data-cy='link-add-channel'
|
||||
>
|
||||
<IconButton className='h-10 w-10' title='Add a Channel'>
|
||||
<PlusIcon />
|
||||
</IconButton>
|
||||
</Link>
|
||||
)}
|
||||
<Link href={`/application/${path.guildId}/settings`} passHref>
|
||||
<a data-cy='link-settings-guild'>
|
||||
<IconButton className='h-7 w-7' title='Settings'>
|
||||
<CogIcon />
|
||||
</IconButton>
|
||||
</a>
|
||||
<Link
|
||||
href={`/application/${path.guildId}/settings`}
|
||||
passHref
|
||||
data-cy='link-settings-guild'
|
||||
>
|
||||
<IconButton className='h-7 w-7' title='Settings'>
|
||||
<CogIcon />
|
||||
</IconButton>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -47,10 +47,10 @@ export const GuildSettings: React.FC = () => {
|
||||
errors,
|
||||
setFetchState,
|
||||
setMessage
|
||||
} = useForm(schema as any)
|
||||
} = useForm(schema)
|
||||
const { getFirstErrorTranslation } = useFormTranslation()
|
||||
|
||||
const onSubmit: HandleUseFormCallback<any> = async (formData) => {
|
||||
const onSubmit: HandleUseFormCallback<typeof schema> = async (formData) => {
|
||||
try {
|
||||
await authentication.api.put(`/guilds/${guild.id}`, formData)
|
||||
setInputValues(formData as unknown as any)
|
||||
@ -82,7 +82,7 @@ export const GuildSettings: React.FC = () => {
|
||||
) => {
|
||||
setFetchState('loading')
|
||||
const files = event?.target?.files
|
||||
if (files != null && files.length === 1) {
|
||||
if (files != null && files.length === 1 && files[0] != null) {
|
||||
const file = files[0]
|
||||
const formData = new FormData()
|
||||
formData.append('icon', file)
|
||||
@ -206,7 +206,7 @@ export const GuildSettings: React.FC = () => {
|
||||
message={
|
||||
message != null
|
||||
? t(message)
|
||||
: getFirstErrorTranslation(errors.email)
|
||||
: getFirstErrorTranslation(errors.name)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { memo } from 'react'
|
||||
import Image from 'next/image'
|
||||
|
||||
import { GuildWithDefaultChannelId } from '../../../models/Guild'
|
||||
import type { GuildWithDefaultChannelId } from '../../../models/Guild'
|
||||
import { IconLink } from '../../design/IconLink'
|
||||
|
||||
export interface GuildProps {
|
||||
@ -8,7 +9,7 @@ export interface GuildProps {
|
||||
selected?: boolean
|
||||
}
|
||||
|
||||
export const Guild: React.FC<GuildProps> = (props) => {
|
||||
const GuildMemo: React.FC<GuildProps> = (props) => {
|
||||
const { guild, selected } = props
|
||||
|
||||
return (
|
||||
@ -34,3 +35,5 @@ export const Guild: React.FC<GuildProps> = (props) => {
|
||||
</IconLink>
|
||||
)
|
||||
}
|
||||
|
||||
export const Guild = memo(GuildMemo)
|
||||
|
@ -2,7 +2,7 @@ import InfiniteScroll from 'react-infinite-scroll-component'
|
||||
|
||||
import { Loader } from '../../design/Loader'
|
||||
import { useGuilds } from '../../../contexts/Guilds'
|
||||
import { GuildsPath } from '..'
|
||||
import type { GuildsPath } from '..'
|
||||
import { Guild } from './Guild'
|
||||
|
||||
export interface GuildsProps {
|
||||
|
@ -7,7 +7,7 @@ import axios from 'axios'
|
||||
|
||||
import { Emoji } from '../../Emoji'
|
||||
import { ConfirmPopup } from '../ConfirmPopup'
|
||||
import {
|
||||
import type {
|
||||
GuildPublic as GuildPublicType,
|
||||
GuildWithDefaultChannelId
|
||||
} from '../../../models/Guild'
|
||||
@ -25,7 +25,9 @@ export const GuildPublic: React.FC<GuildPublicProps> = (props) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
const handleIsConfirmed = (): void => {
|
||||
setIsConfirmed((isConfirmed) => !isConfirmed)
|
||||
setIsConfirmed((isConfirmed) => {
|
||||
return !isConfirmed
|
||||
})
|
||||
}
|
||||
|
||||
const handleYes = async (): Promise<void> => {
|
||||
|
@ -3,11 +3,12 @@ import { useEffect, useState } from 'react'
|
||||
import InfiniteScroll from 'react-infinite-scroll-component'
|
||||
|
||||
import { useAuthentication } from '../../../tools/authentication'
|
||||
import { GuildPublic as GuildPublicType } from '../../../models/Guild'
|
||||
import type { GuildPublic as GuildPublicType } from '../../../models/Guild'
|
||||
import { Loader } from '../../design/Loader'
|
||||
import { GuildPublic } from './GuildPublic'
|
||||
import { usePagination } from '../../../hooks/usePagination'
|
||||
import { SocketData, handleSocketData } from '../../../tools/handleSocketData'
|
||||
import type { SocketData } from '../../../tools/handleSocketData'
|
||||
import { handleSocketData } from '../../../tools/handleSocketData'
|
||||
|
||||
export const JoinGuildsPublic: React.FC = () => {
|
||||
const [search, setSearch] = useState('')
|
||||
|
@ -1,47 +1,48 @@
|
||||
import { memo } from 'react'
|
||||
import Image from 'next/image'
|
||||
import Link from 'next/link'
|
||||
|
||||
import { MemberWithPublicUser } from '../../../models/Member'
|
||||
import type { MemberWithPublicUser } from '../../../models/Member'
|
||||
import { Emoji } from '../../Emoji'
|
||||
|
||||
export interface MemberProps {
|
||||
member: MemberWithPublicUser
|
||||
}
|
||||
|
||||
export const Member: React.FC<MemberProps> = (props) => {
|
||||
const MemberMemo: React.FC<MemberProps> = (props) => {
|
||||
const { member } = props
|
||||
|
||||
return (
|
||||
<Link href={`/application/users/${member.user.id}`}>
|
||||
<a>
|
||||
<div className='flex cursor-pointer items-center overflow-hidden py-2 px-6 pr-10 hover:bg-gray-300 dark:hover:bg-gray-900'>
|
||||
<div className='flex min-w-[50px] rounded-full'>
|
||||
<Image
|
||||
src={
|
||||
member.user.logo == null
|
||||
? '/images/data/user-default.png'
|
||||
: member.user.logo
|
||||
}
|
||||
alt={"Users's profil picture"}
|
||||
height={50}
|
||||
width={50}
|
||||
draggable={false}
|
||||
className='rounded-full'
|
||||
/>
|
||||
</div>
|
||||
<div className='ml-5'>
|
||||
<p data-cy='member-user-name' className='flex truncate font-bold'>
|
||||
{member.user.name}
|
||||
{member.isOwner && (
|
||||
<span className='ml-4'>
|
||||
<Emoji value=':crown:' size={18} />
|
||||
</span>
|
||||
)}
|
||||
</p>
|
||||
{member.user.status != null && member.user.status}
|
||||
</div>
|
||||
<div className='flex cursor-pointer items-center overflow-hidden py-2 px-6 pr-10 hover:bg-gray-300 dark:hover:bg-gray-900'>
|
||||
<div className='flex min-w-[50px] rounded-full'>
|
||||
<Image
|
||||
src={
|
||||
member.user.logo == null
|
||||
? '/images/data/user-default.png'
|
||||
: member.user.logo
|
||||
}
|
||||
alt={"Users's profil picture"}
|
||||
height={50}
|
||||
width={50}
|
||||
draggable={false}
|
||||
className='rounded-full'
|
||||
/>
|
||||
</div>
|
||||
</a>
|
||||
<div className='ml-5'>
|
||||
<p data-cy='member-user-name' className='flex truncate font-bold'>
|
||||
{member.user.name}
|
||||
{member.isOwner && (
|
||||
<span className='ml-4'>
|
||||
<Emoji value=':crown:' size={18} />
|
||||
</span>
|
||||
)}
|
||||
</p>
|
||||
{member.user.status != null && member.user.status}
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
||||
export const Member = memo(MemberMemo)
|
||||
|
@ -0,0 +1,48 @@
|
||||
import useTranslation from 'next-translate/useTranslation'
|
||||
import TextareaAutosize from 'react-textarea-autosize'
|
||||
|
||||
import type { MessageProps } from '../Message'
|
||||
|
||||
export interface EditMessageProps extends MessageProps {
|
||||
handleEdit: () => Promise<void>
|
||||
handleKeyDown: React.KeyboardEventHandler<HTMLFormElement>
|
||||
textareaRef: React.RefObject<HTMLTextAreaElement>
|
||||
}
|
||||
|
||||
export const EditMessage: React.FC<
|
||||
React.PropsWithChildren<EditMessageProps>
|
||||
> = ({ handleEdit, handleKeyDown, textareaRef, message }) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
const handleEditSubmit: React.FormEventHandler<HTMLFormElement> = async (
|
||||
event
|
||||
) => {
|
||||
event.preventDefault()
|
||||
await handleEdit()
|
||||
}
|
||||
|
||||
return (
|
||||
<form
|
||||
className='flex h-full w-full items-center'
|
||||
onSubmit={handleEditSubmit}
|
||||
onKeyDown={handleKeyDown}
|
||||
>
|
||||
<TextareaAutosize
|
||||
className='scrollbar-firefox-support w-full resize-none bg-transparent p-2 tracking-wide outline-none'
|
||||
placeholder={t('application:write-a-message')}
|
||||
wrap='soft'
|
||||
maxRows={6}
|
||||
name='message'
|
||||
defaultValue={message.value}
|
||||
ref={textareaRef}
|
||||
autoFocus
|
||||
onFocus={(event) => {
|
||||
event.currentTarget.setSelectionRange(
|
||||
event.currentTarget.value.length,
|
||||
event.currentTarget.value.length
|
||||
)
|
||||
}}
|
||||
/>
|
||||
</form>
|
||||
)
|
||||
}
|
@ -0,0 +1 @@
|
||||
export * from './EditMessage'
|
@ -2,15 +2,14 @@ import { useState, useRef } from 'react'
|
||||
import Image from 'next/image'
|
||||
import Link from 'next/link'
|
||||
import date from 'date-and-time'
|
||||
import TextareaAutosize from 'react-textarea-autosize'
|
||||
import useTranslation from 'next-translate/useTranslation'
|
||||
|
||||
import { MessageWithMember } from '../../../../models/Message'
|
||||
import type { MessageWithMember } from '../../../../models/Message'
|
||||
import { MessageText } from './MessageText'
|
||||
import { Loader } from '../../../design/Loader'
|
||||
import { MessageFile } from './MessageFile'
|
||||
import { Emoji } from '../../../Emoji'
|
||||
import { useAuthentication } from '../../../../tools/authentication'
|
||||
import { MessageOptions } from './MessageOptions'
|
||||
import { EditMessage } from './EditMessage'
|
||||
|
||||
export interface MessageProps {
|
||||
message: MessageWithMember
|
||||
@ -21,15 +20,8 @@ export const Message: React.FC<MessageProps> = (props) => {
|
||||
|
||||
const textareaReference = useRef<HTMLTextAreaElement>(null)
|
||||
const [isEditing, setIsEditing] = useState(false)
|
||||
const { t } = useTranslation()
|
||||
const { authentication, user } = useAuthentication()
|
||||
|
||||
const handleDeleteMessage = async (): Promise<void> => {
|
||||
try {
|
||||
await authentication.api.delete(`/messages/${message.id}`)
|
||||
} catch {}
|
||||
}
|
||||
|
||||
const handleTextareaKeyDown: React.KeyboardEventHandler<HTMLFormElement> = (
|
||||
event
|
||||
) => {
|
||||
@ -57,13 +49,6 @@ export const Message: React.FC<MessageProps> = (props) => {
|
||||
handleEditMode()
|
||||
}
|
||||
|
||||
const handleEditSubmit: React.FormEventHandler<HTMLFormElement> = async (
|
||||
event
|
||||
) => {
|
||||
event.preventDefault()
|
||||
await handleEdit()
|
||||
}
|
||||
|
||||
const handleEditMode = (): void => {
|
||||
setIsEditing((oldIsEditing) => {
|
||||
return !oldIsEditing
|
||||
@ -72,41 +57,37 @@ export const Message: React.FC<MessageProps> = (props) => {
|
||||
|
||||
return (
|
||||
<div
|
||||
className='group flex w-full p-4 transition hover:bg-gray-200 dark:hover:bg-gray-900'
|
||||
data-cy={`message-${message.id}`}
|
||||
className='group flex w-full p-4 transition hover:bg-gray-200 dark:hover:bg-gray-900'
|
||||
>
|
||||
<Link href={`/application/users/${message.member.user.id}`}>
|
||||
<a>
|
||||
<div className='mr-4 flex h-12 w-12 flex-shrink-0 items-center justify-center'>
|
||||
<div className='h-10 w-10 drop-shadow-md'>
|
||||
<Image
|
||||
quality={100}
|
||||
className='rounded-full'
|
||||
src={
|
||||
message.member.user.logo == null
|
||||
? '/images/data/user-default.png'
|
||||
: message.member.user.logo
|
||||
}
|
||||
alt={"Users's profil picture"}
|
||||
width={50}
|
||||
height={50}
|
||||
draggable={false}
|
||||
/>
|
||||
</div>
|
||||
<div className='mr-4 flex h-12 w-12 flex-shrink-0 items-center justify-center'>
|
||||
<div className='h-10 w-10 drop-shadow-md'>
|
||||
<Image
|
||||
quality={100}
|
||||
className='rounded-full'
|
||||
src={
|
||||
message.member.user.logo == null
|
||||
? '/images/data/user-default.png'
|
||||
: message.member.user.logo
|
||||
}
|
||||
alt={"Users's profil picture"}
|
||||
width={50}
|
||||
height={50}
|
||||
draggable={false}
|
||||
/>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</Link>
|
||||
<div className='relative w-full whitespace-pre-wrap break-words break-all'>
|
||||
<div className='flex w-max items-center'>
|
||||
<Link href={`/application/users/${message.member.user.id}`}>
|
||||
<a>
|
||||
<span
|
||||
data-cy='message-member-user-name'
|
||||
className='font-bold text-gray-900 dark:text-gray-200'
|
||||
>
|
||||
{message.member.user.name}
|
||||
</span>
|
||||
</a>
|
||||
<span
|
||||
data-cy='message-member-user-name'
|
||||
className='font-bold text-gray-900 dark:text-gray-200'
|
||||
>
|
||||
{message.member.user.name}
|
||||
</span>
|
||||
</Link>
|
||||
<span
|
||||
data-cy='message-date'
|
||||
@ -115,54 +96,24 @@ export const Message: React.FC<MessageProps> = (props) => {
|
||||
{date.format(new Date(message.createdAt), 'DD/MM/YYYY - HH:mm:ss')}
|
||||
</span>
|
||||
</div>
|
||||
{message.member.userId === user.id ? (
|
||||
<div className='absolute right-6 -top-8 flex opacity-0 transition-opacity group-hover:opacity-100'>
|
||||
{message.type === 'text' ? (
|
||||
<div
|
||||
className='message-options rounded-l-lg border-l-slate-600'
|
||||
title={t('application:edit')}
|
||||
onClick={isEditing ? handleEdit : handleEditMode}
|
||||
>
|
||||
<Emoji
|
||||
value={isEditing ? ':white_check_mark:' : ':pencil2:'}
|
||||
size={18}
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
<div
|
||||
className='message-options rounded-r-lg border-r-slate-600'
|
||||
title={t('application:delete')}
|
||||
onClick={handleDeleteMessage}
|
||||
>
|
||||
<Emoji value=':wastebasket:' size={18} />
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{message.member.userId === user.id && (
|
||||
<MessageOptions
|
||||
message={message}
|
||||
editMode={isEditing ? ':white_check_mark:' : ':pencil2:'}
|
||||
handleEdit={isEditing ? handleEdit : handleEditMode}
|
||||
/>
|
||||
)}
|
||||
|
||||
{message.type === 'text' ? (
|
||||
<>
|
||||
{isEditing ? (
|
||||
<form
|
||||
className='flex h-full w-full items-center'
|
||||
onSubmit={handleEditSubmit}
|
||||
onKeyDown={handleTextareaKeyDown}
|
||||
>
|
||||
<TextareaAutosize
|
||||
className='scrollbar-firefox-support w-full resize-none bg-transparent p-2 tracking-wide outline-none'
|
||||
placeholder={t('application:write-a-message')}
|
||||
wrap='soft'
|
||||
maxRows={6}
|
||||
name='message'
|
||||
defaultValue={message.value}
|
||||
ref={textareaReference}
|
||||
autoFocus
|
||||
onFocus={(event) => {
|
||||
event.currentTarget.setSelectionRange(
|
||||
event.currentTarget.value.length,
|
||||
event.currentTarget.value.length
|
||||
)
|
||||
}}
|
||||
/>
|
||||
</form>
|
||||
<EditMessage
|
||||
message={message}
|
||||
textareaRef={textareaReference}
|
||||
handleEdit={handleEdit}
|
||||
handleKeyDown={handleTextareaKeyDown}
|
||||
/>
|
||||
) : (
|
||||
<MessageText message={message} />
|
||||
)}
|
||||
|
@ -3,7 +3,7 @@ import axios from 'axios'
|
||||
import prettyBytes from 'pretty-bytes'
|
||||
import { DownloadIcon } from '@heroicons/react/solid'
|
||||
|
||||
import { MessageWithMember } from '../../../../../models/Message'
|
||||
import type { MessageWithMember } from '../../../../../models/Message'
|
||||
import { Loader } from '../../../../design/Loader'
|
||||
import { FileIcon } from './FileIcon'
|
||||
import { api } from '../../../../../tools/api'
|
||||
|
@ -0,0 +1,44 @@
|
||||
import useTranslation from 'next-translate/useTranslation'
|
||||
|
||||
import { useAuthentication } from '../../../../../tools/authentication'
|
||||
import { Emoji } from '../../../../Emoji'
|
||||
import type { MessageProps } from '../Message'
|
||||
|
||||
interface MessageOptionsProps extends MessageProps {
|
||||
handleEdit: () => void
|
||||
editMode: ':white_check_mark:' | ':pencil2:'
|
||||
}
|
||||
|
||||
export const MessageOptions: React.FC<
|
||||
React.PropsWithChildren<MessageOptionsProps>
|
||||
> = ({ handleEdit, editMode, message }) => {
|
||||
const { t } = useTranslation()
|
||||
const { authentication } = useAuthentication()
|
||||
|
||||
const handleDeleteMessage = async (): Promise<void> => {
|
||||
try {
|
||||
await authentication.api.delete(`/messages/${message.id}`)
|
||||
} catch {}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='absolute right-6 -top-8 flex opacity-0 transition-opacity group-hover:opacity-100'>
|
||||
{message.type === 'text' && (
|
||||
<div
|
||||
className='message-options rounded-l-lg border-l-slate-600'
|
||||
title={t('application:edit')}
|
||||
onClick={handleEdit}
|
||||
>
|
||||
<Emoji value={editMode} size={18} />
|
||||
</div>
|
||||
)}
|
||||
<div
|
||||
className='message-options rounded-r-lg border-r-slate-600'
|
||||
title={t('application:delete')}
|
||||
onClick={handleDeleteMessage}
|
||||
>
|
||||
<Emoji value=':wastebasket:' size={18} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
@ -0,0 +1 @@
|
||||
export * from './MessageOptions'
|
@ -10,7 +10,7 @@ import { vscDarkPlus } from 'react-syntax-highlighter/dist/cjs/styles/prism'
|
||||
import 'katex/dist/katex.min.css'
|
||||
|
||||
import { Emoji, emojiPlugin, isStringWithOnlyOneEmoji } from '../../../../Emoji'
|
||||
import { MessageWithMember } from '../../../../../models/Message'
|
||||
import type { MessageWithMember } from '../../../../../models/Message'
|
||||
|
||||
export interface MessageContentProps {
|
||||
message: MessageWithMember
|
||||
|
@ -23,11 +23,12 @@ export const PopupGuildCard: React.FC<PopupGuildCardProps> = (props) => {
|
||||
<p className='mt-6 px-8 text-center text-sm text-gray-200'>
|
||||
{description}
|
||||
</p>
|
||||
<Link href={link.href}>
|
||||
<a className='mb-6 flex h-10 w-4/5 items-center justify-center self-center rounded-2xl bg-green-400 font-bold tracking-wide text-white transition duration-200 ease-in-out hover:bg-green-600'>
|
||||
{link.icon}
|
||||
{link.text}
|
||||
</a>
|
||||
<Link
|
||||
href={link.href}
|
||||
className='mb-6 flex h-10 w-4/5 items-center justify-center self-center rounded-2xl bg-green-400 font-bold tracking-wide text-white transition duration-200 ease-in-out hover:bg-green-600'
|
||||
>
|
||||
{link.icon}
|
||||
{link.text}
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -3,9 +3,10 @@ import useTranslation from 'next-translate/useTranslation'
|
||||
import TextareaAutosize from 'react-textarea-autosize'
|
||||
import classNames from 'clsx'
|
||||
|
||||
import { GuildsChannelsPath } from '..'
|
||||
import type { GuildsChannelsPath } from '..'
|
||||
import { useAuthentication } from '../../../tools/authentication'
|
||||
import { EmojiPicker, EmojiPickerOnClick } from '../../Emoji'
|
||||
import type { EmojiPickerOnClick } from '../../Emoji'
|
||||
import { EmojiPicker } from '../../Emoji'
|
||||
|
||||
export interface SendMessageProps {
|
||||
path: GuildsChannelsPath
|
||||
@ -53,7 +54,7 @@ export const SendMessage: React.FC<SendMessageProps> = (props) => {
|
||||
event
|
||||
) => {
|
||||
const files = event?.target?.files
|
||||
if (files != null && files.length === 1) {
|
||||
if (files != null && files.length === 1 && files[0] != null) {
|
||||
const file = files[0]
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
@ -65,7 +66,9 @@ export const SendMessage: React.FC<SendMessageProps> = (props) => {
|
||||
}
|
||||
|
||||
const handleVisibleEmojiPicker = (): void => {
|
||||
setIsVisibleEmojiPicker((isVisible) => !isVisible)
|
||||
setIsVisibleEmojiPicker((isVisible) => {
|
||||
return !isVisible
|
||||
})
|
||||
}
|
||||
|
||||
const handleEmojiPicker: EmojiPickerOnClick = (emoji) => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import classNames from 'clsx'
|
||||
|
||||
import { ApplicationProps } from '..'
|
||||
import type { ApplicationProps } from '..'
|
||||
|
||||
export type DirectionSidebar = 'left' | 'right'
|
||||
|
||||
|
@ -2,8 +2,8 @@ import Image from 'next/image'
|
||||
import date from 'date-and-time'
|
||||
import useTranslation from 'next-translate/useTranslation'
|
||||
|
||||
import { UserPublic } from '../../../models/User'
|
||||
import { Guild } from '../../../models/Guild'
|
||||
import type { UserPublic } from '../../../models/User'
|
||||
import type { Guild } from '../../../models/Guild'
|
||||
|
||||
export interface UserProfileProps {
|
||||
className?: string
|
||||
@ -16,96 +16,88 @@ export const UserProfile: React.FC<UserProfileProps> = (props) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className='relative flex h-full flex-col items-center justify-center'>
|
||||
<div className='transition'>
|
||||
<div className='max-w-[1000px] px-12'>
|
||||
<div className='flex items-center justify-between'>
|
||||
<div className='flex w-max flex-col items-center gap-7 md:flex-row'>
|
||||
<div className='relative flex items-center justify-center overflow-hidden rounded-full shadow-lg transition-all'>
|
||||
<Image
|
||||
quality={100}
|
||||
className='rounded-full'
|
||||
src={
|
||||
user.logo != null
|
||||
? user.logo
|
||||
: '/images/data/user-default.png'
|
||||
}
|
||||
alt='Profil Picture'
|
||||
draggable='false'
|
||||
height={125}
|
||||
width={125}
|
||||
/>
|
||||
<div className='relative flex h-full flex-col items-center justify-center'>
|
||||
<div className='transition'>
|
||||
<div className='max-w-[1000px] px-12'>
|
||||
<div className='flex items-center justify-between'>
|
||||
<div className='flex w-max flex-col items-center gap-7 md:flex-row'>
|
||||
<div className='relative flex items-center justify-center overflow-hidden rounded-full shadow-lg transition-all'>
|
||||
<Image
|
||||
quality={100}
|
||||
className='rounded-full'
|
||||
src={
|
||||
user.logo != null
|
||||
? user.logo
|
||||
: '/images/data/user-default.png'
|
||||
}
|
||||
alt='Profil Picture'
|
||||
draggable='false'
|
||||
height={125}
|
||||
width={125}
|
||||
/>
|
||||
</div>
|
||||
<div className='ml-10 flex flex-col'>
|
||||
<div className='mb-2 flex items-center'>
|
||||
<p
|
||||
className='space text-dark text-3xl font-bold tracking-wide dark:text-white'
|
||||
data-cy='user-name'
|
||||
>
|
||||
{user.name}
|
||||
</p>
|
||||
<p
|
||||
className='ml-8 select-none text-sm tracking-widest text-white opacity-40'
|
||||
data-cy='user-createdAt'
|
||||
>
|
||||
{date.format(new Date(user.createdAt), 'DD/MM/YYYY')}
|
||||
</p>
|
||||
</div>
|
||||
<div className='ml-10 flex flex-col'>
|
||||
<div className='mb-2 flex items-center'>
|
||||
<p
|
||||
className='space text-dark text-3xl font-bold tracking-wide dark:text-white'
|
||||
data-cy='user-name'
|
||||
>
|
||||
{user.name}
|
||||
<div className='my-2 text-left'>
|
||||
{user.email != null && (
|
||||
<p className='font-bold'>
|
||||
Email:{' '}
|
||||
<a
|
||||
href={`mailto:${user.email}`}
|
||||
target='_blank'
|
||||
className='relative ml-2 font-normal tracking-wide no-underline opacity-80 transition-all after:absolute after:left-0 after:bottom-[-1px] after:h-[1px] after:w-0 after:bg-black after:transition-all hover:opacity-100 hover:after:w-full dark:after:bg-white'
|
||||
rel='noreferrer'
|
||||
data-cy='user-email'
|
||||
>
|
||||
{user.email}
|
||||
</a>
|
||||
</p>
|
||||
<p
|
||||
className='ml-8 select-none text-sm tracking-widest text-white opacity-40'
|
||||
data-cy='user-createdAt'
|
||||
>
|
||||
{date.format(new Date(user.createdAt), 'DD/MM/YYYY')}
|
||||
)}
|
||||
{user.website != null && (
|
||||
<p className='font-bold'>
|
||||
{t('application:website')}:{' '}
|
||||
<a
|
||||
target='_blank'
|
||||
rel='noreferrer'
|
||||
href={user.website}
|
||||
className='relative ml-2 font-normal tracking-wide no-underline opacity-80 transition-all after:absolute after:left-0 after:bottom-[-2px] after:h-[1px] after:w-0 after:bg-black after:transition-all hover:opacity-100 hover:after:w-full dark:after:bg-white'
|
||||
>
|
||||
{user.website}
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<div className='my-2 text-left'>
|
||||
{user.email != null && (
|
||||
<p className='font-bold'>
|
||||
Email:{' '}
|
||||
<a
|
||||
href={`mailto:${user.email}`}
|
||||
target='_blank'
|
||||
className='relative ml-2 font-normal tracking-wide no-underline opacity-80 transition-all after:absolute after:left-0 after:bottom-[-1px] after:h-[1px] after:w-0 after:bg-black after:transition-all hover:opacity-100 hover:after:w-full dark:after:bg-white'
|
||||
rel='noreferrer'
|
||||
data-cy='user-email'
|
||||
>
|
||||
{user.email}
|
||||
</a>
|
||||
</p>
|
||||
)}
|
||||
{user.website != null && (
|
||||
<p className='font-bold'>
|
||||
{t('application:website')}:{' '}
|
||||
<a
|
||||
target='_blank'
|
||||
rel='noreferrer'
|
||||
href={user.website}
|
||||
className='relative ml-2 font-normal tracking-wide no-underline opacity-80 transition-all after:absolute after:left-0 after:bottom-[-2px] after:h-[1px] after:w-0 after:bg-black after:transition-all hover:opacity-100 hover:after:w-full dark:after:bg-white'
|
||||
>
|
||||
{user.website}
|
||||
</a>
|
||||
</p>
|
||||
)}
|
||||
{user.status != null && (
|
||||
<p className='flex font-bold'>
|
||||
{t('application:status')}:{' '}
|
||||
<span className='ml-2 font-normal tracking-wide'>
|
||||
{user.status}
|
||||
</span>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{user.status != null && (
|
||||
<p className='flex font-bold'>
|
||||
{t('application:status')}:{' '}
|
||||
<span className='ml-2 font-normal tracking-wide'>
|
||||
{user.status}
|
||||
</span>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{user.biography != null && (
|
||||
<div className='mt-7 text-center'>
|
||||
<p>{user.biography}</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{user.biography != null && (
|
||||
<div className='mt-7 text-center'>
|
||||
<p>{user.biography}</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style jsx global>{`
|
||||
#application-page-content {
|
||||
overflow-x: hidden;
|
||||
}
|
||||
`}</style>
|
||||
</>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
@ -19,7 +19,8 @@ import { Button } from '../../design/Button'
|
||||
import { FormState } from '../../design/FormState'
|
||||
import { userSchema } from '../../../models/User'
|
||||
import { userSettingsSchema } from '../../../models/UserSettings'
|
||||
import { ProviderOAuth, providers } from '../../../models/OAuth'
|
||||
import type { ProviderOAuth } from '../../../models/OAuth'
|
||||
import { providers } from '../../../models/OAuth'
|
||||
import { useFormTranslation } from '../../../hooks/useFormTranslation'
|
||||
|
||||
const schema = {
|
||||
@ -56,7 +57,9 @@ export const UserSettings: React.FC = () => {
|
||||
const { getFirstErrorTranslation } = useFormTranslation()
|
||||
|
||||
const hasAllProviders = useMemo(() => {
|
||||
return providers.every((provider) => user.strategies.includes(provider))
|
||||
return providers.every((provider) => {
|
||||
return user.strategies.includes(provider)
|
||||
})
|
||||
}, [user.strategies])
|
||||
|
||||
const onSubmit: HandleUseFormCallback<typeof schema> = async (formData) => {
|
||||
@ -146,7 +149,7 @@ export const UserSettings: React.FC = () => {
|
||||
) => {
|
||||
setFetchState('loading')
|
||||
const files = event?.target?.files
|
||||
if (files != null && files.length === 1) {
|
||||
if (files != null && files.length === 1 && files[0] != null) {
|
||||
const file = files[0]
|
||||
const formData = new FormData()
|
||||
formData.append('logo', file)
|
||||
@ -189,9 +192,9 @@ export const UserSettings: React.FC = () => {
|
||||
setUser((oldUser) => {
|
||||
return {
|
||||
...oldUser,
|
||||
strategies: oldUser.strategies.filter(
|
||||
(strategy) => strategy !== provider
|
||||
)
|
||||
strategies: oldUser.strategies.filter((strategy) => {
|
||||
return strategy !== provider
|
||||
})
|
||||
}
|
||||
})
|
||||
setMessage('application:success-deleted-provider')
|
||||
@ -309,16 +312,15 @@ export const UserSettings: React.FC = () => {
|
||||
<Language className='!top-12' />
|
||||
<div className='ml-auto flex'>
|
||||
<SwitchTheme />
|
||||
<Link href={`/application/users/${user.id}`}>
|
||||
<a
|
||||
className='group ml-3 flex h-8 w-8 cursor-pointer items-center justify-center rounded-lg bg-slate-200 transition-colors hover:bg-slate-300 dark:bg-slate-700 hover:dark:bg-slate-800'
|
||||
title='Preview Public Profile'
|
||||
>
|
||||
<EyeIcon
|
||||
height={20}
|
||||
className='opacity-50 transition-opacity group-hover:opacity-100'
|
||||
/>
|
||||
</a>
|
||||
<Link
|
||||
href={`/application/users/${user.id}`}
|
||||
className='group ml-3 flex h-8 w-8 cursor-pointer items-center justify-center rounded-lg bg-slate-200 transition-colors hover:bg-slate-300 dark:bg-slate-700 hover:dark:bg-slate-800'
|
||||
title='Preview Public Profile'
|
||||
>
|
||||
<EyeIcon
|
||||
height={20}
|
||||
className='opacity-50 transition-opacity group-hover:opacity-100'
|
||||
/>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -14,10 +14,8 @@ import { FormState } from '../design/FormState'
|
||||
import { AuthenticationForm } from '.'
|
||||
import { userSchema } from '../../models/User'
|
||||
import { api } from '../../tools/api'
|
||||
import {
|
||||
Tokens,
|
||||
Authentication as AuthenticationClass
|
||||
} from '../../tools/authentication'
|
||||
import type { Tokens } from '../../tools/authentication'
|
||||
import { Authentication as AuthenticationClass } from '../../tools/authentication'
|
||||
import { AuthenticationSocialMedia } from './AuthenticationSocialMedia'
|
||||
import { useFormTranslation } from '../../hooks/useFormTranslation'
|
||||
|
||||
@ -141,11 +139,9 @@ export const Authentication: React.FC<AuthenticationProps> = (props) => {
|
||||
: '/authentication/signup'
|
||||
}
|
||||
>
|
||||
<a>
|
||||
{mode === 'signup'
|
||||
? t('authentication:already-have-an-account')
|
||||
: t('authentication:dont-have-an-account')}
|
||||
</a>
|
||||
{mode === 'signup'
|
||||
? t('authentication:already-have-an-account')
|
||||
: t('authentication:dont-have-an-account')}
|
||||
</Link>
|
||||
</p>
|
||||
</AuthenticationForm>
|
||||
|
@ -1,5 +1,6 @@
|
||||
import classNames from 'clsx'
|
||||
import { Form, FormProps } from 'react-component-form'
|
||||
import type { FormProps } from 'react-component-form'
|
||||
import { Form } from 'react-component-form'
|
||||
|
||||
export const AuthenticationForm: React.FC<FormProps> = (props) => {
|
||||
const { className, children, ...rest } = props
|
||||
|
@ -3,7 +3,8 @@ import { useRouter } from 'next/router'
|
||||
|
||||
import { api } from '../../tools/api'
|
||||
import { Authentication, isTokens } from '../../tools/authentication'
|
||||
import { SocialMediaButton, SocialMedia } from '../design/SocialMediaButton'
|
||||
import type { SocialMedia } from '../design/SocialMediaButton'
|
||||
import { SocialMediaButton } from '../design/SocialMediaButton'
|
||||
import { providers } from '../../models/OAuth'
|
||||
|
||||
export const AuthenticationSocialMedia: React.FC = () => {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'emoji-mart/css/emoji-mart.css'
|
||||
import { EmojiData, Picker } from 'emoji-mart'
|
||||
import type { EmojiData } from 'emoji-mart'
|
||||
import { Picker } from 'emoji-mart'
|
||||
import { useTheme } from 'next-themes'
|
||||
|
||||
import { EMOJI_SET } from '../emojiPlugin'
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { visit } from 'unist-util-visit'
|
||||
import { Plugin, Transformer } from 'unified'
|
||||
import { Literal, Parent } from 'unist'
|
||||
import type { Plugin, Transformer } from 'unified'
|
||||
import type { Literal, Parent } from 'unist'
|
||||
import type { ElementContent } from 'hast'
|
||||
import type { EmojiSet } from 'emoji-mart'
|
||||
|
||||
|
@ -1,53 +1,45 @@
|
||||
import useTranslation from 'next-translate/useTranslation'
|
||||
import Link from 'next/link'
|
||||
|
||||
export interface ErrorPageProps {
|
||||
import type { FooterProps } from './Footer'
|
||||
import { Footer } from './Footer'
|
||||
import { Header } from './Header'
|
||||
|
||||
export interface ErrorPageProps extends FooterProps {
|
||||
statusCode: number
|
||||
message: string
|
||||
}
|
||||
|
||||
export const ErrorPage: React.FC<ErrorPageProps> = (props) => {
|
||||
const { message, statusCode } = props
|
||||
const { message, statusCode, version } = props
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1 className='my-6 text-4xl font-semibold'>
|
||||
{t('errors:error')}{' '}
|
||||
<span
|
||||
className='text-green-800 dark:text-green-400'
|
||||
data-cy='status-code'
|
||||
>
|
||||
{statusCode}
|
||||
</span>
|
||||
</h1>
|
||||
<p className='text-center text-lg'>
|
||||
{message}{' '}
|
||||
<Link href='/'>
|
||||
<a className='text-green-800 hover:underline dark:text-green-400'>
|
||||
{t('errors:return-to-home-page')}
|
||||
</a>
|
||||
</Link>
|
||||
</p>
|
||||
|
||||
<style jsx global>
|
||||
{`
|
||||
main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-width: 100vw;
|
||||
flex: 1;
|
||||
}
|
||||
#__next {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-top: 0;
|
||||
height: 100vh;
|
||||
}
|
||||
`}
|
||||
</style>
|
||||
<div className='flex h-screen flex-col pt-0'>
|
||||
<Header />
|
||||
<main className='flex min-w-full flex-1 flex-col items-center justify-center'>
|
||||
<h1 className='my-6 text-4xl font-semibold'>
|
||||
{t('errors:error')}{' '}
|
||||
<span
|
||||
className='text-green-800 dark:text-green-400'
|
||||
data-cy='status-code'
|
||||
>
|
||||
{statusCode}
|
||||
</span>
|
||||
</h1>
|
||||
<p className='text-center text-lg'>
|
||||
{message}{' '}
|
||||
<Link
|
||||
href='/'
|
||||
className='text-green-800 hover:underline dark:text-green-400'
|
||||
>
|
||||
{t('errors:return-to-home-page')}
|
||||
</Link>
|
||||
</p>
|
||||
</main>
|
||||
<Footer version={version} />
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
@ -15,10 +15,11 @@ export const Footer: React.FC<FooterProps> = (props) => {
|
||||
return (
|
||||
<footer className='flex flex-col items-center justify-center border-t-2 border-gray-600 bg-white py-6 text-lg dark:border-gray-400 dark:bg-black'>
|
||||
<p>
|
||||
<Link href='/'>
|
||||
<a className='text-green-800 hover:underline dark:text-green-400'>
|
||||
Thream
|
||||
</a>
|
||||
<Link
|
||||
href='/'
|
||||
className='text-green-800 hover:underline dark:text-green-400'
|
||||
>
|
||||
Thream
|
||||
</Link>{' '}
|
||||
| {t('common:all-rights-reserved')}
|
||||
</p>
|
||||
|
@ -9,20 +9,19 @@ export const Header: React.FC = () => {
|
||||
<header className='sticky top-0 z-50 flex w-full justify-center border-b-2 border-gray-600 bg-white px-6 py-2 dark:border-gray-400 dark:bg-black'>
|
||||
<div className='container flex justify-between'>
|
||||
<Link href='/'>
|
||||
<a>
|
||||
<div className='flex items-center justify-center'>
|
||||
<Image
|
||||
quality={100}
|
||||
width={60}
|
||||
height={60}
|
||||
src='/images/icons/Thream.png'
|
||||
alt='Thream'
|
||||
/>
|
||||
<span className='ml-1 hidden font-headline font-medium text-green-800 dark:text-green-400 xs:block'>
|
||||
Thream
|
||||
</span>
|
||||
</div>
|
||||
</a>
|
||||
<div className='flex items-center justify-center'>
|
||||
<Image
|
||||
priority
|
||||
quality={100}
|
||||
width={60}
|
||||
height={60}
|
||||
src='/images/icons/Thream.png'
|
||||
alt='Thream'
|
||||
/>
|
||||
<span className='ml-1 hidden font-headline font-medium text-green-800 dark:text-green-400 xs:block'>
|
||||
Thream
|
||||
</span>
|
||||
</div>
|
||||
</Link>
|
||||
<div className='flex justify-between'>
|
||||
<Language />
|
||||
|
@ -19,10 +19,14 @@ export const Language: React.FC<LanguageProps> = (props) => {
|
||||
const languageClickRef = useRef<HTMLDivElement | null>(null)
|
||||
|
||||
const handleHiddenMenu = useCallback(() => {
|
||||
setHiddenMenu((oldHiddenMenu) => !oldHiddenMenu)
|
||||
setHiddenMenu((oldHiddenMenu) => {
|
||||
return !oldHiddenMenu
|
||||
})
|
||||
}, [])
|
||||
|
||||
useClickOutsideAlerter(languageClickRef, () => setHiddenMenu(true))
|
||||
useClickOutsideAlerter(languageClickRef, () => {
|
||||
return setHiddenMenu(true)
|
||||
})
|
||||
|
||||
const handleLanguage = async (language: string): Promise<void> => {
|
||||
await setLanguage(language)
|
||||
@ -59,7 +63,9 @@ export const Language: React.FC<LanguageProps> = (props) => {
|
||||
<li
|
||||
key={index}
|
||||
className='flex h-12 w-full items-center justify-center pl-2 hover:bg-[#4f545c] hover:bg-opacity-20'
|
||||
onClick={async () => await handleLanguage(language)}
|
||||
onClick={async () => {
|
||||
return await handleLanguage(language)
|
||||
}}
|
||||
>
|
||||
<LanguageFlag language={language} />
|
||||
</li>
|
||||
|
78
components/Header/SwitchTheme.tsx
Normal file
78
components/Header/SwitchTheme.tsx
Normal file
@ -0,0 +1,78 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import classNames from 'clsx'
|
||||
import { useTheme } from 'next-themes'
|
||||
|
||||
export const SwitchTheme: React.FC = () => {
|
||||
const [mounted, setMounted] = useState(false)
|
||||
const { theme, setTheme } = useTheme()
|
||||
|
||||
useEffect(() => {
|
||||
setMounted(true)
|
||||
}, [])
|
||||
|
||||
if (!mounted) {
|
||||
return null
|
||||
}
|
||||
|
||||
const handleClick = (): void => {
|
||||
setTheme(theme === 'dark' ? 'light' : 'dark')
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className='flex items-center'
|
||||
data-cy='switch-theme-click'
|
||||
onClick={handleClick}
|
||||
>
|
||||
<div className='relative inline-block cursor-pointer touch-pan-x select-none border-0 bg-transparent p-0'>
|
||||
<div className='h-[24px] w-[50px] rounded-[30px] bg-[#4d4d4d] p-0 text-white transition-all duration-200 ease-in-out'>
|
||||
<div
|
||||
data-cy='switch-theme-dark'
|
||||
className={classNames(
|
||||
'absolute top-0 bottom-0 left-[8px] mt-auto mb-auto h-[10px] w-[14px] leading-[0] transition-opacity duration-[250ms] ease-in-out',
|
||||
{
|
||||
'opacity-100': theme === 'dark',
|
||||
'opacity-0': theme === 'light'
|
||||
}
|
||||
)}
|
||||
>
|
||||
<span className='relative flex h-[10px] w-[10px] items-center justify-center'>
|
||||
🌜
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
data-cy='switch-theme-light'
|
||||
className={classNames(
|
||||
'absolute right-[10px] top-0 bottom-0 mt-auto mb-auto h-[10px] w-[10px] leading-[0]',
|
||||
{
|
||||
'opacity-100': theme === 'light',
|
||||
'opacity-0': theme === 'dark'
|
||||
}
|
||||
)}
|
||||
>
|
||||
<span className='relative flex h-[10px] w-[10px] items-center justify-center'>
|
||||
🌞
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className={classNames(
|
||||
'absolute top-[1px] box-border h-[22px] w-[22px] rounded-[50%] bg-[#fafafa] text-white transition-all duration-[250ms] ease-in-out',
|
||||
{
|
||||
'left-[27px]': theme === 'dark',
|
||||
'left-0': theme === 'light'
|
||||
}
|
||||
)}
|
||||
style={{ border: '1px solid #4d4d4d' }}
|
||||
/>
|
||||
<input
|
||||
data-cy='switch-theme-input'
|
||||
type='checkbox'
|
||||
aria-label='Dark mode toggle'
|
||||
className='absolute m-[-1px] h-[1px] w-[1px] overflow-hidden border-0 p-0'
|
||||
defaultChecked
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useTheme } from 'next-themes'
|
||||
|
||||
export const SwitchTheme: React.FC = () => {
|
||||
const [mounted, setMounted] = useState(false)
|
||||
const { theme, setTheme } = useTheme()
|
||||
|
||||
useEffect(() => {
|
||||
setMounted(true)
|
||||
}, [])
|
||||
|
||||
if (!mounted) {
|
||||
return null
|
||||
}
|
||||
|
||||
const handleClick = (): void => {
|
||||
setTheme(theme === 'dark' ? 'light' : 'dark')
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className='flex items-center'
|
||||
data-cy='switch-theme-click'
|
||||
onClick={handleClick}
|
||||
>
|
||||
<div className='toggle-theme-button relative inline-block cursor-pointer bg-transparent'>
|
||||
<div className='toggle-track'>
|
||||
<div
|
||||
data-cy='switch-theme-dark'
|
||||
className='toggle-track-check absolute'
|
||||
>
|
||||
<span className='toggle_Dark relative flex items-center justify-center'>
|
||||
🌜
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
data-cy='switch-theme-light'
|
||||
className='toggle-track-x absolute'
|
||||
>
|
||||
<span className='toggle_Light relative flex items-center justify-center'>
|
||||
🌞
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className='toggle-thumb absolute' />
|
||||
<input
|
||||
data-cy='switch-theme-input'
|
||||
type='checkbox'
|
||||
aria-label='Dark mode toggle'
|
||||
className='toggle-screenreader-only absolute overflow-hidden'
|
||||
defaultChecked
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style jsx>
|
||||
{`
|
||||
.toggle-theme-button {
|
||||
touch-action: pan-x;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
user-select: none;
|
||||
}
|
||||
.toggle-track {
|
||||
width: 50px;
|
||||
height: 24px;
|
||||
padding: 0;
|
||||
border-radius: 30px;
|
||||
background-color: #4d4d4d;
|
||||
transition: all 0.2s ease;
|
||||
color: #fff;
|
||||
}
|
||||
.toggle-track-check {
|
||||
width: 14px;
|
||||
height: 10px;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
margin-top: auto;
|
||||
margin-bottom: auto;
|
||||
line-height: 0;
|
||||
left: 8px;
|
||||
opacity: ${theme === 'dark' ? 1 : 0};
|
||||
transition: opacity 0.25s ease;
|
||||
}
|
||||
.toggle-track-x {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
margin-top: auto;
|
||||
margin-bottom: auto;
|
||||
line-height: 0;
|
||||
right: 10px;
|
||||
opacity: ${theme === 'dark' ? 0 : 1};
|
||||
}
|
||||
.toggle_Dark,
|
||||
.toggle_Light {
|
||||
height: 10px;
|
||||
width: 10px;
|
||||
}
|
||||
.toggle-thumb {
|
||||
left: ${theme === 'dark' ? '27px' : '0px'};
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
border: 1px solid #4d4d4d;
|
||||
border-radius: 50%;
|
||||
background-color: #fafafa;
|
||||
box-sizing: border-box;
|
||||
transition: all 0.25s ease;
|
||||
top: 1px;
|
||||
color: #fff;
|
||||
}
|
||||
.toggle-screenreader-only {
|
||||
border: 0;
|
||||
clip: rect(0 0 0 0);
|
||||
height: 1px;
|
||||
margin: -1px;
|
||||
padding: 0;
|
||||
width: 1px;
|
||||
}
|
||||
`}
|
||||
</style>
|
||||
</>
|
||||
)
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './SwitchTheme'
|
@ -1,20 +0,0 @@
|
||||
export const ScrollableBody: React.FC<React.PropsWithChildren<{}>> = (
|
||||
props
|
||||
) => {
|
||||
const { children } = props
|
||||
|
||||
return (
|
||||
<>
|
||||
{children}
|
||||
<style jsx global>{`
|
||||
body {
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--scroll-bar-color) var(--scroll-bar-bg-color);
|
||||
z-index: 1000;
|
||||
height: calc(100vh - 64px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
`}</style>
|
||||
</>
|
||||
)
|
||||
}
|
@ -14,24 +14,26 @@ export const IconLink: React.FC<React.PropsWithChildren<IconLinkProps>> = (
|
||||
const { children, selected, href, title, className } = props
|
||||
|
||||
return (
|
||||
<Link href={href}>
|
||||
<a className='group relative flex w-full justify-center' title={title}>
|
||||
<div
|
||||
className={classNames('group flex w-full justify-center', className)}
|
||||
>
|
||||
{children}
|
||||
<div className='absolute left-0 flex h-12 w-3 items-center'>
|
||||
<span
|
||||
className={classNames(
|
||||
'absolute w-4/12 rounded-r-lg bg-green-700 group-hover:h-5',
|
||||
{
|
||||
'h-full': selected
|
||||
}
|
||||
)}
|
||||
></span>
|
||||
</div>
|
||||
<Link
|
||||
href={href}
|
||||
className='group relative flex w-full justify-center'
|
||||
title={title}
|
||||
>
|
||||
<div
|
||||
className={classNames('group flex w-full justify-center', className)}
|
||||
>
|
||||
{children}
|
||||
<div className='absolute left-0 flex h-12 w-3 items-center'>
|
||||
<span
|
||||
className={classNames(
|
||||
'absolute w-4/12 rounded-r-lg bg-green-700 group-hover:h-5',
|
||||
{
|
||||
'h-full': selected
|
||||
}
|
||||
)}
|
||||
></span>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
@ -35,61 +35,46 @@ export const Input: React.FC<InputProps> = (props) => {
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className='flex flex-col'>
|
||||
<div
|
||||
className={classNames('mt-6 mb-2 flex justify-between', className)}
|
||||
>
|
||||
<label className='pl-1' htmlFor={name}>
|
||||
{label}
|
||||
</label>
|
||||
{type === 'password' && showForgotPassword ? (
|
||||
<Link href='/authentication/forgot-password'>
|
||||
<a
|
||||
className='text-center font-headline text-xs text-green-800 hover:underline dark:text-green-400 sm:text-sm'
|
||||
data-cy='forgot-password-link'
|
||||
>
|
||||
{t('authentication:forgot-password')}
|
||||
</a>
|
||||
</Link>
|
||||
) : null}
|
||||
</div>
|
||||
<div className='relative mt-0'>
|
||||
<input
|
||||
data-cy={`input-${name ?? 'name'}`}
|
||||
className='h-11 w-full rounded-lg border border-transparent bg-[#f1f1f1] px-3 font-paragraph leading-10 text-[#2a2a2a] caret-green-600 focus:border focus:shadow-green focus:outline-none'
|
||||
{...rest}
|
||||
id={name}
|
||||
name={name}
|
||||
type={inputType}
|
||||
/>
|
||||
{type === 'password' && (
|
||||
<div
|
||||
data-cy='password-eye'
|
||||
onClick={handlePassword}
|
||||
className='password-eye absolute cursor-pointer bg-[#f1f1f1] bg-cover'
|
||||
/>
|
||||
)}
|
||||
<FormState
|
||||
id={`error-${name ?? 'input'}`}
|
||||
state={error == null ? 'idle' : 'error'}
|
||||
message={error}
|
||||
/>
|
||||
</div>
|
||||
<div className='flex flex-col'>
|
||||
<div className={classNames('mt-6 mb-2 flex justify-between', className)}>
|
||||
<label className='pl-1' htmlFor={name}>
|
||||
{label}
|
||||
</label>
|
||||
{type === 'password' && showForgotPassword ? (
|
||||
<Link
|
||||
href='/authentication/forgot-password'
|
||||
className='text-center font-headline text-xs text-green-800 hover:underline dark:text-green-400 sm:text-sm'
|
||||
data-cy='forgot-password-link'
|
||||
>
|
||||
{t('authentication:forgot-password')}
|
||||
</Link>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<style jsx>
|
||||
{`
|
||||
.password-eye {
|
||||
top: 12px;
|
||||
right: 16px;
|
||||
z-index: 1;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
background-image: url('/images/svg/icons/input/${inputType}.svg');
|
||||
}
|
||||
`}
|
||||
</style>
|
||||
</>
|
||||
<div className='relative mt-0'>
|
||||
<input
|
||||
data-cy={`input-${name ?? 'name'}`}
|
||||
className='h-11 w-full rounded-lg border border-transparent bg-[#f1f1f1] px-3 font-paragraph leading-10 text-[#2a2a2a] caret-green-600 focus:border focus:shadow-green focus:outline-none'
|
||||
{...rest}
|
||||
id={name}
|
||||
name={name}
|
||||
type={inputType}
|
||||
/>
|
||||
{type === 'password' && (
|
||||
<div
|
||||
data-cy='password-eye'
|
||||
onClick={handlePassword}
|
||||
style={{
|
||||
backgroundImage: `url('/images/svg/icons/input/${inputType}.svg')`
|
||||
}}
|
||||
className='absolute top-3 right-4 z-10 h-5 w-5 cursor-pointer bg-[#f1f1f1] bg-cover'
|
||||
/>
|
||||
)}
|
||||
<FormState
|
||||
id={`error-${name ?? 'input'}`}
|
||||
state={error == null ? 'idle' : 'error'}
|
||||
message={error}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
39
components/design/Loader/Loader.module.css
Normal file
39
components/design/Loader/Loader.module.css
Normal file
@ -0,0 +1,39 @@
|
||||
@keyframes progressSpinnerRotate {
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
@keyframes progressSpinnerDash {
|
||||
0% {
|
||||
stroke-dasharray: 1, 200;
|
||||
stroke-dashoffset: 0;
|
||||
}
|
||||
50% {
|
||||
stroke-dasharray: 89, 200;
|
||||
stroke-dashoffset: -35px;
|
||||
}
|
||||
100% {
|
||||
stroke-dasharray: 89, 200;
|
||||
stroke-dashoffset: -124px;
|
||||
}
|
||||
}
|
||||
|
||||
.progressSpinnerSvg {
|
||||
animation: progressSpinnerRotate 2s linear infinite;
|
||||
height: 100%;
|
||||
transform-origin: center center;
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
margin: auto;
|
||||
}
|
||||
.progressSpinnerCircle {
|
||||
stroke-dasharray: 89, 200;
|
||||
stroke-dashoffset: 0;
|
||||
stroke: #27b05e;
|
||||
animation: progressSpinnerDash 1.5s ease-in-out infinite;
|
||||
stroke-linecap: round;
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
import styles from './Loader.module.css'
|
||||
|
||||
export interface LoaderProps {
|
||||
width?: number
|
||||
height?: number
|
||||
@ -9,10 +11,14 @@ export const Loader: React.FC<LoaderProps> = (props) => {
|
||||
|
||||
return (
|
||||
<div className={props.className}>
|
||||
<div data-cy='progress-spinner' className='progress-spinner'>
|
||||
<svg className='progress-spinner-svg' viewBox='25 25 50 50'>
|
||||
<div
|
||||
data-cy='progress-spinner'
|
||||
className='relative my-0 mx-auto before:block before:pt-[100%] before:content-none'
|
||||
style={{ width: `${width}px`, height: `${height}px` }}
|
||||
>
|
||||
<svg className={styles['progressSpinnerSvg']} viewBox='25 25 50 50'>
|
||||
<circle
|
||||
className='progress-spinner-circle'
|
||||
className={styles['progressSpinnerCircle']}
|
||||
cx='50'
|
||||
cy='50'
|
||||
r='20'
|
||||
@ -22,60 +28,6 @@ export const Loader: React.FC<LoaderProps> = (props) => {
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<style jsx>
|
||||
{`
|
||||
.progress-spinner {
|
||||
position: relative;
|
||||
margin: 0 auto;
|
||||
width: ${width}px;
|
||||
height: ${height}px;
|
||||
}
|
||||
.progress-spinner::before {
|
||||
content: '';
|
||||
display: block;
|
||||
padding-top: 100%;
|
||||
}
|
||||
.progress-spinner-svg {
|
||||
animation: progress-spinner-rotate 2s linear infinite;
|
||||
height: 100%;
|
||||
transform-origin: center center;
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
margin: auto;
|
||||
}
|
||||
.progress-spinner-circle {
|
||||
stroke-dasharray: 89, 200;
|
||||
stroke-dashoffset: 0;
|
||||
stroke: #27b05e;
|
||||
animation: progress-spinner-dash 1.5s ease-in-out infinite;
|
||||
stroke-linecap: round;
|
||||
}
|
||||
@keyframes progress-spinner-rotate {
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
@keyframes progress-spinner-dash {
|
||||
0% {
|
||||
stroke-dasharray: 1, 200;
|
||||
stroke-dashoffset: 0;
|
||||
}
|
||||
50% {
|
||||
stroke-dasharray: 89, 200;
|
||||
stroke-dashoffset: -35px;
|
||||
}
|
||||
100% {
|
||||
stroke-dasharray: 89, 200;
|
||||
stroke-dashoffset: -124px;
|
||||
}
|
||||
}
|
||||
`}
|
||||
</style>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
.buttonGoogle {
|
||||
color: #000;
|
||||
border: 1px solid #000;
|
||||
}
|
||||
.buttonMedia {
|
||||
color: #fff;
|
||||
border: none;
|
||||
}
|
||||
.button:focus {
|
||||
box-shadow: 0 0 0 2px #27b05e;
|
||||
}
|
@ -2,7 +2,8 @@ import { useMemo } from 'react'
|
||||
import Image from 'next/image'
|
||||
import classNames from 'clsx'
|
||||
|
||||
import { ProviderOAuth } from '../../../models/OAuth'
|
||||
import type { ProviderOAuth } from '../../../models/OAuth'
|
||||
import styles from './SocialMediaButton.module.css'
|
||||
|
||||
export type SocialMedia = ProviderOAuth
|
||||
|
||||
@ -52,27 +53,21 @@ export const SocialMediaButton: React.FC<SocialMediaButtonProps> = (props) => {
|
||||
}, [socialMedia])
|
||||
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
{...rest}
|
||||
className={classNames(className, 'button', givenClassName)}
|
||||
>
|
||||
<SocialMediaChildren socialMedia={socialMedia} />
|
||||
</button>
|
||||
|
||||
<style jsx>
|
||||
{`
|
||||
.button {
|
||||
background: ${socialMediaColor};
|
||||
color: ${socialMedia === 'Google' ? '#000' : '#fff'};
|
||||
border: ${socialMedia === 'Google' ? '1px solid #000' : 'none'};
|
||||
}
|
||||
.button:focus {
|
||||
box-shadow: 0 0 0 2px #27b05e;
|
||||
}
|
||||
`}
|
||||
</style>
|
||||
</>
|
||||
<button
|
||||
{...rest}
|
||||
style={{ background: socialMediaColor }}
|
||||
className={classNames(
|
||||
className,
|
||||
styles['button'],
|
||||
{
|
||||
[styles['buttonGoogle'] as string]: socialMedia === 'Google',
|
||||
[styles['buttonMedia'] as string]: socialMedia !== 'Google'
|
||||
},
|
||||
givenClassName
|
||||
)}
|
||||
>
|
||||
<SocialMediaChildren socialMedia={socialMedia} />
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
@ -88,23 +83,20 @@ export const SocialMediaLink: React.FC<SocialMediaLinkProps> = (props) => {
|
||||
}, [socialMedia])
|
||||
|
||||
return (
|
||||
<>
|
||||
<a {...rest} className={classNames(className, 'link', givenClassName)}>
|
||||
<SocialMediaChildren socialMedia={socialMedia} />
|
||||
</a>
|
||||
|
||||
<style jsx>
|
||||
{`
|
||||
.link {
|
||||
background: ${socialMediaColor};
|
||||
color: ${socialMedia === 'Google' ? '#000' : '#fff'};
|
||||
border: ${socialMedia === 'Google' ? '1px solid #000' : 'none'};
|
||||
}
|
||||
.link:focus {
|
||||
box-shadow: 0 0 0 2px #27b05e;
|
||||
}
|
||||
`}
|
||||
</style>
|
||||
</>
|
||||
<a
|
||||
{...rest}
|
||||
style={{ background: socialMediaColor }}
|
||||
className={classNames(
|
||||
className,
|
||||
styles['button'],
|
||||
{
|
||||
[styles['buttonGoogle'] as string]: socialMedia === 'Google',
|
||||
[styles['buttonMedia'] as string]: socialMedia !== 'Google'
|
||||
},
|
||||
givenClassName
|
||||
)}
|
||||
>
|
||||
<SocialMediaChildren socialMedia={socialMedia} />
|
||||
</a>
|
||||
)
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import TextareaAutosize, {
|
||||
TextareaAutosizeProps
|
||||
} from 'react-textarea-autosize'
|
||||
import type { TextareaAutosizeProps } from 'react-textarea-autosize'
|
||||
import TextareaAutosize from 'react-textarea-autosize'
|
||||
|
||||
export interface TextareaProps extends TextareaAutosizeProps {
|
||||
label: string
|
||||
|
@ -1,12 +1,15 @@
|
||||
import { createContext, useContext, useEffect } from 'react'
|
||||
import { createContext, useContext, useEffect, useMemo } from 'react'
|
||||
import { useRouter } from 'next/router'
|
||||
|
||||
import { NextPage, usePagination } from '../hooks/usePagination'
|
||||
import type { NextPage } from '../hooks/usePagination'
|
||||
import { usePagination } from '../hooks/usePagination'
|
||||
import { useAuthentication } from '../tools/authentication'
|
||||
import { Channel, ChannelWithDefaultChannelId } from '../models/Channel'
|
||||
import { GuildsChannelsPath } from '../components/Application'
|
||||
import { handleSocketData, SocketData } from '../tools/handleSocketData'
|
||||
import { CacheKey, CHANNELS_CACHE_KEY } from '../tools/cache'
|
||||
import type { Channel, ChannelWithDefaultChannelId } from '../models/Channel'
|
||||
import type { GuildsChannelsPath } from '../components/Application'
|
||||
import type { SocketData } from '../tools/handleSocketData'
|
||||
import { handleSocketData } from '../tools/handleSocketData'
|
||||
import type { CacheKey } from '../tools/cache'
|
||||
import { CHANNELS_CACHE_KEY } from '../tools/cache'
|
||||
|
||||
export interface Channels {
|
||||
channels: Channel[]
|
||||
@ -28,7 +31,9 @@ export const ChannelsProvider: React.FC<
|
||||
const router = useRouter()
|
||||
const { authentication } = useAuthentication()
|
||||
|
||||
const cacheKey: CacheKey = `${path.guildId}-${CHANNELS_CACHE_KEY}`
|
||||
const cacheKey = useMemo<CacheKey>(() => {
|
||||
return `${path.guildId}-${CHANNELS_CACHE_KEY}`
|
||||
}, [path.guildId])
|
||||
|
||||
const {
|
||||
items: channels,
|
||||
@ -75,7 +80,7 @@ export const ChannelsProvider: React.FC<
|
||||
export const useChannels = (): Channels => {
|
||||
const channels = useContext(ChannelsContext)
|
||||
if (channels === defaultChannelsContext) {
|
||||
throw new Error('useChannels must be used within ChannelsProvider')
|
||||
throw new Error('`useChannels` must be used within `ChannelsProvider`')
|
||||
}
|
||||
return channels
|
||||
}
|
||||
|
@ -1,19 +1,17 @@
|
||||
import { createContext, useContext, useEffect, useState } from 'react'
|
||||
import { useRouter } from 'next/router'
|
||||
|
||||
import { GuildWithDefaultChannelId } from '../models/Guild'
|
||||
import { Member } from '../models/Member'
|
||||
import type { GuildWithDefaultChannelId } from '../models/Guild'
|
||||
import type { Member } from '../models/Member'
|
||||
import { useAuthentication } from '../tools/authentication'
|
||||
import { SocketData } from '../tools/handleSocketData'
|
||||
import type { SocketData } from '../tools/handleSocketData'
|
||||
|
||||
export interface GuildMember {
|
||||
guild: GuildWithDefaultChannelId
|
||||
member: Member
|
||||
}
|
||||
|
||||
export interface GuildMemberResult extends GuildMember {
|
||||
setGuildMember: React.Dispatch<React.SetStateAction<GuildMember>>
|
||||
}
|
||||
export interface GuildMemberResult extends GuildMember {}
|
||||
|
||||
export interface GuildMemberProps {
|
||||
guildMember: GuildMember
|
||||
@ -79,8 +77,7 @@ export const GuildMemberProvider: React.FC<
|
||||
return (
|
||||
<GuildMemberContext.Provider
|
||||
value={{
|
||||
...guildMember,
|
||||
setGuildMember
|
||||
...guildMember
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
@ -91,7 +88,9 @@ export const GuildMemberProvider: React.FC<
|
||||
export const useGuildMember = (): GuildMemberResult => {
|
||||
const guildMember = useContext(GuildMemberContext)
|
||||
if (guildMember === defaultGuildMemberContext) {
|
||||
throw new Error('useGuildMember must be used within GuildMemberProvider')
|
||||
throw new Error(
|
||||
'`useGuildMember` must be used within `GuildMemberProvider`'
|
||||
)
|
||||
}
|
||||
return guildMember
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
import { createContext, useContext, useEffect } from 'react'
|
||||
|
||||
import { NextPage, usePagination } from '../hooks/usePagination'
|
||||
import type { NextPage } from '../hooks/usePagination'
|
||||
import { usePagination } from '../hooks/usePagination'
|
||||
import { useAuthentication } from '../tools/authentication'
|
||||
import { GuildWithDefaultChannelId } from '../models/Guild'
|
||||
import { handleSocketData, SocketData } from '../tools/handleSocketData'
|
||||
import type { GuildWithDefaultChannelId } from '../models/Guild'
|
||||
import type { SocketData } from '../tools/handleSocketData'
|
||||
import { handleSocketData } from '../tools/handleSocketData'
|
||||
import { GUILDS_CACHE_KEY } from '../tools/cache'
|
||||
|
||||
export interface Guilds {
|
||||
@ -62,7 +64,7 @@ export const GuildsProvider: React.FC<React.PropsWithChildren<{}>> = (
|
||||
export const useGuilds = (): Guilds => {
|
||||
const guilds = useContext(GuildsContext)
|
||||
if (guilds === defaultGuildsContext) {
|
||||
throw new Error('useGuilds must be used within GuildsProvider')
|
||||
throw new Error('`useGuilds` must be used within `GuildsProvider`')
|
||||
}
|
||||
return guilds
|
||||
}
|
||||
|
@ -1,12 +1,15 @@
|
||||
import { createContext, useContext, useEffect } from 'react'
|
||||
import { createContext, useContext, useEffect, useMemo } from 'react'
|
||||
|
||||
import { NextPage, usePagination } from '../hooks/usePagination'
|
||||
import type { NextPage } from '../hooks/usePagination'
|
||||
import { usePagination } from '../hooks/usePagination'
|
||||
import { useAuthentication } from '../tools/authentication'
|
||||
import { MemberWithPublicUser } from '../models/Member'
|
||||
import { GuildsChannelsPath } from '../components/Application'
|
||||
import { handleSocketData, SocketData } from '../tools/handleSocketData'
|
||||
import { User } from '../models/User'
|
||||
import { CacheKey, MEMBERS_CACHE_KEY } from '../tools/cache'
|
||||
import type { MemberWithPublicUser } from '../models/Member'
|
||||
import type { GuildsChannelsPath } from '../components/Application'
|
||||
import type { SocketData } from '../tools/handleSocketData'
|
||||
import { handleSocketData } from '../tools/handleSocketData'
|
||||
import type { User } from '../models/User'
|
||||
import type { CacheKey } from '../tools/cache'
|
||||
import { MEMBERS_CACHE_KEY } from '../tools/cache'
|
||||
|
||||
export interface Members {
|
||||
members: MemberWithPublicUser[]
|
||||
@ -28,7 +31,9 @@ export const MembersProviders: React.FC<
|
||||
|
||||
const { authentication } = useAuthentication()
|
||||
|
||||
const cacheKey: CacheKey = `${path.guildId}-${MEMBERS_CACHE_KEY}`
|
||||
const cacheKey = useMemo<CacheKey>(() => {
|
||||
return `${path.guildId}-${MEMBERS_CACHE_KEY}`
|
||||
}, [path.guildId])
|
||||
|
||||
const {
|
||||
items: members,
|
||||
@ -89,7 +94,7 @@ export const MembersProviders: React.FC<
|
||||
export const useMembers = (): Members => {
|
||||
const members = useContext(MembersContext)
|
||||
if (members === defaultMembersContext) {
|
||||
throw new Error('useMembers must be used within MembersProvider')
|
||||
throw new Error('`useMembers` must be used within `MembersProvider`')
|
||||
}
|
||||
return members
|
||||
}
|
||||
|
@ -1,11 +1,14 @@
|
||||
import { createContext, useContext, useEffect } from 'react'
|
||||
import { createContext, useContext, useEffect, useMemo } from 'react'
|
||||
|
||||
import { NextPage, usePagination } from '../hooks/usePagination'
|
||||
import type { NextPage } from '../hooks/usePagination'
|
||||
import { usePagination } from '../hooks/usePagination'
|
||||
import { useAuthentication } from '../tools/authentication'
|
||||
import { MessageWithMember } from '../models/Message'
|
||||
import { GuildsChannelsPath } from '../components/Application'
|
||||
import { handleSocketData, SocketData } from '../tools/handleSocketData'
|
||||
import { CacheKey, MESSAGES_CACHE_KEY } from '../tools/cache'
|
||||
import type { MessageWithMember } from '../models/Message'
|
||||
import type { GuildsChannelsPath } from '../components/Application'
|
||||
import type { SocketData } from '../tools/handleSocketData'
|
||||
import { handleSocketData } from '../tools/handleSocketData'
|
||||
import type { CacheKey } from '../tools/cache'
|
||||
import { MESSAGES_CACHE_KEY } from '../tools/cache'
|
||||
|
||||
export interface Messages {
|
||||
messages: MessageWithMember[]
|
||||
@ -26,7 +29,9 @@ export const MessagesProvider: React.FC<
|
||||
const { path, children } = props
|
||||
const { authentication, user } = useAuthentication()
|
||||
|
||||
const cacheKey: CacheKey = `${path.channelId}-${MESSAGES_CACHE_KEY}`
|
||||
const cacheKey = useMemo<CacheKey>(() => {
|
||||
return `${path.channelId}-${MESSAGES_CACHE_KEY}`
|
||||
}, [path.channelId])
|
||||
|
||||
const {
|
||||
items: messages,
|
||||
@ -88,7 +93,7 @@ export const MessagesProvider: React.FC<
|
||||
export const useMessages = (): Messages => {
|
||||
const messages = useContext(MessagesContext)
|
||||
if (messages === defaultMessagesContext) {
|
||||
throw new Error('useMessages must be used within a MessagesProvider')
|
||||
throw new Error('`useMessages` must be used within a `MessagesProvider`')
|
||||
}
|
||||
return messages
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import { getLocal } from 'mockttp'
|
||||
import type { Mockttp } from 'mockttp'
|
||||
|
||||
import { API_DEFAULT_PORT } from './tools/api'
|
||||
import { Handlers, Method } from './cypress/fixtures/handler'
|
||||
import type { Handlers, Method } from './cypress/fixtures/handler'
|
||||
|
||||
const UPLOADS_FIXTURES_DIRECTORY = path.join(
|
||||
process.cwd(),
|
||||
@ -19,11 +19,9 @@ let server: Mockttp | null = null
|
||||
export default defineConfig({
|
||||
fixturesFolder: false,
|
||||
video: false,
|
||||
downloadsFolder: undefined,
|
||||
screenshotOnRunFailure: false,
|
||||
|
||||
e2e: {
|
||||
baseUrl: 'http://localhost:3000',
|
||||
baseUrl: 'http://127.0.0.1:3000',
|
||||
supportFile: false,
|
||||
setupNodeEvents(on, config) {
|
||||
on('task', {
|
||||
@ -62,7 +60,6 @@ export default defineConfig({
|
||||
return config
|
||||
}
|
||||
},
|
||||
|
||||
component: {
|
||||
devServer: {
|
||||
framework: 'next',
|
||||
|
@ -1,5 +1,7 @@
|
||||
describe('Common > Header', () => {
|
||||
beforeEach(() => cy.visit('/'))
|
||||
beforeEach(() => {
|
||||
return cy.visit('/')
|
||||
})
|
||||
|
||||
describe('Switch theme color (dark/light)', () => {
|
||||
it('should switch theme from `dark` (default) to `light`', () => {
|
||||
|
@ -241,8 +241,8 @@ describe('Pages > /application/[guildId]/[channelId]', () => {
|
||||
cy.visit('/application/abc/abc', {
|
||||
failOnStatusCode: false
|
||||
})
|
||||
.location('pathname')
|
||||
.should('eq', '/404')
|
||||
.get('[data-cy=status-code]')
|
||||
.contains('404')
|
||||
})
|
||||
|
||||
it("should redirect the user to `/404` if `guildId` doesn't exist", () => {
|
||||
@ -253,8 +253,8 @@ describe('Pages > /application/[guildId]/[channelId]', () => {
|
||||
cy.visit(`/application/123/${channelExample.id}`, {
|
||||
failOnStatusCode: false
|
||||
})
|
||||
.location('pathname')
|
||||
.should('eq', '/404')
|
||||
.get('[data-cy=status-code]')
|
||||
.contains('404')
|
||||
})
|
||||
|
||||
it("should redirect the user to `/404` if `channelId` doesn't exist", () => {
|
||||
@ -263,8 +263,8 @@ describe('Pages > /application/[guildId]/[channelId]', () => {
|
||||
getGuildMemberWithGuildIdHandler
|
||||
]).setCookie('refreshToken', 'refresh-token')
|
||||
cy.visit(`/application/${guildExample.id}/123`, { failOnStatusCode: false })
|
||||
.location('pathname')
|
||||
.should('eq', '/404')
|
||||
.get('[data-cy=status-code]')
|
||||
.contains('404')
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -92,8 +92,8 @@ describe('Pages > /application/[guildId]/[channelId]/settings', () => {
|
||||
cy.visit(`/application/${guildExample.id}/${channelExample.id}/settings`, {
|
||||
failOnStatusCode: false
|
||||
})
|
||||
.location('pathname')
|
||||
.should('eq', '/404')
|
||||
.get('[data-cy=status-code]')
|
||||
.contains('404')
|
||||
})
|
||||
|
||||
it('should redirect the user to `/404` if `guildId` or `channelId` are not numbers', () => {
|
||||
@ -104,8 +104,8 @@ describe('Pages > /application/[guildId]/[channelId]/settings', () => {
|
||||
cy.visit('/application/abc/abc/settings', {
|
||||
failOnStatusCode: false
|
||||
})
|
||||
.location('pathname')
|
||||
.should('eq', '/404')
|
||||
.get('[data-cy=status-code]')
|
||||
.contains('404')
|
||||
})
|
||||
|
||||
it("should redirect the user to `/404` if `guildId` doesn't exist", () => {
|
||||
@ -116,8 +116,8 @@ describe('Pages > /application/[guildId]/[channelId]/settings', () => {
|
||||
cy.visit(`/application/123/${channelExample.id}/settings`, {
|
||||
failOnStatusCode: false
|
||||
})
|
||||
.location('pathname')
|
||||
.should('eq', '/404')
|
||||
.get('[data-cy=status-code]')
|
||||
.contains('404')
|
||||
})
|
||||
|
||||
it("should redirect the user to `/404` if `channelId` doesn't exist", () => {
|
||||
@ -128,8 +128,8 @@ describe('Pages > /application/[guildId]/[channelId]/settings', () => {
|
||||
cy.visit(`/application/${guildExample.id}/123/settings`, {
|
||||
failOnStatusCode: false
|
||||
})
|
||||
.location('pathname')
|
||||
.should('eq', '/404')
|
||||
.get('[data-cy=status-code]')
|
||||
.contains('404')
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -56,8 +56,8 @@ describe('Pages > /application/[guildId]/channels/create', () => {
|
||||
cy.visit('/application/abc/channels/create', {
|
||||
failOnStatusCode: false
|
||||
})
|
||||
.location('pathname')
|
||||
.should('eq', '/404')
|
||||
.get('[data-cy=status-code]')
|
||||
.contains('404')
|
||||
})
|
||||
|
||||
it("should redirect the user to `/404` if `guildId` doesn't exist", () => {
|
||||
@ -68,8 +68,8 @@ describe('Pages > /application/[guildId]/channels/create', () => {
|
||||
cy.visit(`/application/123/channels/create`, {
|
||||
failOnStatusCode: false
|
||||
})
|
||||
.location('pathname')
|
||||
.should('eq', '/404')
|
||||
.get('[data-cy=status-code]')
|
||||
.contains('404')
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -86,8 +86,8 @@ describe('Pages > /application/[guildId]/settings', () => {
|
||||
cy.visit('/application/abc/settings', {
|
||||
failOnStatusCode: false
|
||||
})
|
||||
.location('pathname')
|
||||
.should('eq', '/404')
|
||||
.get('[data-cy=status-code]')
|
||||
.contains('404')
|
||||
})
|
||||
|
||||
it("should redirect the user to `/404` if `guildId` doesn't exist", () => {
|
||||
@ -98,8 +98,8 @@ describe('Pages > /application/[guildId]/settings', () => {
|
||||
cy.visit(`/application/123/settings`, {
|
||||
failOnStatusCode: false
|
||||
})
|
||||
.location('pathname')
|
||||
.should('eq', '/404')
|
||||
.get('[data-cy=status-code]')
|
||||
.contains('404')
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -29,8 +29,8 @@ describe('Pages > /application/users/[userId]', () => {
|
||||
'refresh-token'
|
||||
)
|
||||
cy.visit(`/application/users/123`, { failOnStatusCode: false })
|
||||
.location('pathname')
|
||||
.should('eq', '/404')
|
||||
.get('[data-cy=status-code]')
|
||||
.contains('404')
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Handler } from '../../handler'
|
||||
import type { Handler } from '../../handler'
|
||||
import { channelExample, channelExample2 } from '../channel'
|
||||
|
||||
export const deleteChannelWithChannelIdHandler: Handler = {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Handler } from '../../handler'
|
||||
import type { Handler } from '../../handler'
|
||||
import { channelExample, channelExample2 } from '../channel'
|
||||
|
||||
export const getChannelWithChannelIdHandler: Handler = {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Handler } from '../../../handler'
|
||||
import type { Handler } from '../../../handler'
|
||||
import {
|
||||
messageExampleComplete,
|
||||
messageExampleComplete2,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Handler } from '../../handler'
|
||||
import type { Handler } from '../../handler'
|
||||
import { channelExample, channelExample2 } from '../channel'
|
||||
|
||||
export const putChannelWithChannelIdHandler: Handler = {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { guildExample } from '../../guild'
|
||||
import { Handler } from '../../../handler'
|
||||
import type { Handler } from '../../../handler'
|
||||
import { channelExample, channelExample2 } from '../../../channels/channel'
|
||||
|
||||
export const getChannelsWithGuildIdHandler: Handler = {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { guildExample } from '../../guild'
|
||||
import { Handler } from '../../../handler'
|
||||
import type { Handler } from '../../../handler'
|
||||
import { channelExample, channelExample2 } from '../../../channels/channel'
|
||||
|
||||
export const postChannelsWithGuildIdHandler: Handler = {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Handler } from '../../handler'
|
||||
import type { Handler } from '../../handler'
|
||||
import { guildExample } from '../guild'
|
||||
|
||||
export const deleteGuildWithGuildIdHandler: Handler = {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Handler } from '../../handler'
|
||||
import type { Handler } from '../../handler'
|
||||
import { guildExample } from '../guild'
|
||||
import { memberExampleComplete } from '../../members/member'
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { guildExample } from '../../guild'
|
||||
import { Handler } from '../../../handler'
|
||||
import type { Handler } from '../../../handler'
|
||||
import { memberExampleComplete } from '../../../members/member'
|
||||
|
||||
export const getMembersWithGuildIdHandler: Handler = {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { guildExample } from '../../guild'
|
||||
import { Handler } from '../../../handler'
|
||||
import type { Handler } from '../../../handler'
|
||||
import { memberExampleComplete } from '../../../members/member'
|
||||
import { channelExample } from '../../../channels/channel'
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { guildExample } from '../../guild'
|
||||
import { Handler } from '../../../handler'
|
||||
import type { Handler } from '../../../handler'
|
||||
import { memberExample } from '../../../members/member'
|
||||
|
||||
export const deleteLeaveMembersWithGuildIdHandler: Handler = {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Handler } from '../handler'
|
||||
import type { Handler } from '../handler'
|
||||
import { guildExample, guildExample2 } from './guild'
|
||||
|
||||
export const getGuildsHandler: Handler = {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Guild } from '../../../models/Guild'
|
||||
import type { Guild } from '../../../models/Guild'
|
||||
|
||||
export const guildExample: Guild = {
|
||||
id: 1,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Handler } from '../handler'
|
||||
import type { Handler } from '../handler'
|
||||
import { guildExample } from './guild'
|
||||
import { channelExample } from '../channels/channel'
|
||||
import { memberExampleComplete } from '../members/member'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Handler } from '../../handler'
|
||||
import type { Handler } from '../../handler'
|
||||
import { guildExample, guildExample2 } from '../guild'
|
||||
|
||||
export const getGuildsPublicEmptyHandler: Handler = {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Handler } from '../../handler'
|
||||
import type { Handler } from '../../handler'
|
||||
import {
|
||||
messageExampleComplete6,
|
||||
messageExampleComplete7,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Handler } from '../../handler'
|
||||
import type { Handler } from '../../handler'
|
||||
import { userExample, userSettingsExample } from '../user'
|
||||
|
||||
export const getUserByIdHandler: Handler = {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Handler } from '../../handler'
|
||||
import type { Handler } from '../../handler'
|
||||
import { userExample, userSettingsExample } from '../user'
|
||||
|
||||
export const getUsersCurrentHandler: Handler = {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Handler } from '../../handler'
|
||||
import type { Handler } from '../../handler'
|
||||
|
||||
export const postUsersRefreshTokenHandler: Handler = {
|
||||
method: 'POST',
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Handler } from '../../handler'
|
||||
import type { Handler } from '../../handler'
|
||||
|
||||
export const postUsersResetPasswordHandler: Handler = {
|
||||
method: 'POST',
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Handler } from '../../handler'
|
||||
import type { Handler } from '../../handler'
|
||||
|
||||
export const putUsersResetPasswordHandler: Handler = {
|
||||
method: 'PUT',
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Handler } from '../../handler'
|
||||
import type { Handler } from '../../handler'
|
||||
|
||||
export const postUsersSigninHandler: Handler = {
|
||||
method: 'POST',
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Handler } from '../../handler'
|
||||
import type { Handler } from '../../handler'
|
||||
import { userExample, userSettingsExample } from '../user'
|
||||
|
||||
export const postUsersSignupHandler: Handler = {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user