From cb2ddbf6613e49a77fd9334772385f00899cd174 Mon Sep 17 00:00:00 2001 From: Walid <87608619+Walidoux@users.noreply.github.com> Date: Sat, 9 Apr 2022 11:48:48 +0000 Subject: [PATCH] feat: confirm popup for guild/channel deletion (#27) --- components/Application/Application.tsx | 2 +- .../ChannelSettings/ChannelSettings.tsx | 91 +++++---- .../Application/ConfirmGuildJoin/index.ts | 1 - .../ConfirmPopup.tsx} | 24 +-- components/Application/ConfirmPopup/index.ts | 1 + .../GuildSettings/GuildSettings.tsx | 179 ++++++++++-------- .../GuildPublic/GuildPublic.tsx | 5 +- .../[guildId]/[channelId]/settings.spec.ts | 1 + .../application/[guildId]/settings.spec.ts | 1 + locales/en/application.json | 2 + locales/fr/application.json | 2 + locales/fr/common.json | 2 +- 12 files changed, 185 insertions(+), 126 deletions(-) delete mode 100644 components/Application/ConfirmGuildJoin/index.ts rename components/Application/{ConfirmGuildJoin/ConfirmGuildJoin.tsx => ConfirmPopup/ConfirmPopup.tsx} (76%) create mode 100644 components/Application/ConfirmPopup/index.ts diff --git a/components/Application/Application.tsx b/components/Application/Application.tsx index c02d7c4..cd90af4 100644 --- a/components/Application/Application.tsx +++ b/components/Application/Application.tsx @@ -215,7 +215,7 @@ export const Application: React.FC = (props) => { id='application-page-content' onClick={handleCloseSidebars} className={classNames( - 'h-full-without-header top-0 z-0 flex w-full flex-1 flex-col overflow-y-auto transition', + 'h-full-without-header relative top-0 z-0 flex w-full flex-1 flex-col overflow-y-auto transition', { 'absolute opacity-20': isMobile && (visibleSidebars.left || visibleSidebars.right) diff --git a/components/Application/ChannelSettings/ChannelSettings.tsx b/components/Application/ChannelSettings/ChannelSettings.tsx index 3eb498e..1dbcfc3 100644 --- a/components/Application/ChannelSettings/ChannelSettings.tsx +++ b/components/Application/ChannelSettings/ChannelSettings.tsx @@ -2,6 +2,7 @@ import { useRouter } from 'next/router' import { useState } from 'react' import { Form } from 'react-component-form' import useTranslation from 'next-translate/useTranslation' +import classNames from 'classnames' import axios from 'axios' import { HandleSubmitCallback, useForm } from '../../../hooks/useForm' @@ -15,6 +16,7 @@ import { channelSchema, ChannelWithDefaultChannelId } from '../../../models/Channel' +import { ConfirmPopup } from '../ConfirmPopup' export interface ChannelSettingsProps { channel: Channel @@ -32,6 +34,12 @@ export const ChannelSettings: React.FC = (props) => { name: channel.name }) + const [confirmation, setConfirmation] = useState(false) + + const handleConfirmation = (): void => { + return setConfirmation(!confirmation) + } + const { fetchState, message, @@ -91,43 +99,60 @@ export const ChannelSettings: React.FC = (props) => { } return ( -
-
-
-
- + <> + +
+
+
+ +
-
-
-
- - +
+
+ + +
+
- + +
+
- + ) } diff --git a/components/Application/ConfirmGuildJoin/index.ts b/components/Application/ConfirmGuildJoin/index.ts deleted file mode 100644 index bd4a659..0000000 --- a/components/Application/ConfirmGuildJoin/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './ConfirmGuildJoin' diff --git a/components/Application/ConfirmGuildJoin/ConfirmGuildJoin.tsx b/components/Application/ConfirmPopup/ConfirmPopup.tsx similarity index 76% rename from components/Application/ConfirmGuildJoin/ConfirmGuildJoin.tsx rename to components/Application/ConfirmPopup/ConfirmPopup.tsx index 20ab7cd..8f88768 100644 --- a/components/Application/ConfirmGuildJoin/ConfirmGuildJoin.tsx +++ b/components/Application/ConfirmPopup/ConfirmPopup.tsx @@ -5,15 +5,14 @@ import classNames from 'classnames' import { Loader } from '../../design/Loader' -export interface ConfirmGuildJoinProps { +export interface ConfirmPopupProps { className?: string + title: string handleYes: () => void | Promise handleNo: () => void | Promise } -export const ConfirmGuildJoin: React.FC = ({ - ...props -}) => { +export const ConfirmPopup: React.FC = ({ ...props }) => { const { t } = useTranslation() const [isLoading, setIsLoading] = useState(false) @@ -25,9 +24,12 @@ export const ConfirmGuildJoin: React.FC = ({ return (
= ({ Join Guild Illustration
-

- {t('application:join-the-guild')} ? -

+

{props.title}

diff --git a/components/Application/ConfirmPopup/index.ts b/components/Application/ConfirmPopup/index.ts new file mode 100644 index 0000000..5dcf1f2 --- /dev/null +++ b/components/Application/ConfirmPopup/index.ts @@ -0,0 +1 @@ +export * from './ConfirmPopup' diff --git a/components/Application/GuildSettings/GuildSettings.tsx b/components/Application/GuildSettings/GuildSettings.tsx index deb93aa..f2f8464 100644 --- a/components/Application/GuildSettings/GuildSettings.tsx +++ b/components/Application/GuildSettings/GuildSettings.tsx @@ -5,6 +5,7 @@ import { Type } from '@sinclair/typebox' import { PhotographIcon } from '@heroicons/react/solid' import { Form } from 'react-component-form' import useTranslation from 'next-translate/useTranslation' +import classNames from 'classnames' import { HandleSubmitCallback, useForm } from '../../../hooks/useForm' import { guildSchema } from '../../../models/Guild' @@ -14,6 +15,7 @@ import { Textarea } from '../../design/Textarea' import { Input } from '../../design/Input' import { Button } from '../../design/Button' import { useAuthentication } from '../../../tools/authentication' +import { ConfirmPopup } from '../ConfirmPopup' export const GuildSettings: React.FC = () => { const { t } = useTranslation() @@ -26,6 +28,12 @@ export const GuildSettings: React.FC = () => { description: guild.description }) + const [confirmation, setConfirmation] = useState(false) + + const handleConfirmation = (): void => { + return setConfirmation(!confirmation) + } + const { fetchState, message, @@ -109,95 +117,112 @@ export const GuildSettings: React.FC = () => { } return ( -
- {member.isOwner && ( -
-
-
-
- +
+
+ Profil Picture - - +
-
- Profil Picture + +