From b0d499368c03f955829d0c15c2ae0ce206b61fe0 Mon Sep 17 00:00:00 2001 From: reinaka Date: Tue, 15 Oct 2024 10:00:39 +0300 Subject: [PATCH 1/5] fix(39379966): move AddCommunityModal state back into the component --- .../components/Community/CommunityMenu.tsx | 8 ++++---- .../pkg.navigation/components/Dropdown/DropdownMenu.tsx | 9 ++++++--- packages/pkg.navigation/store/communityStore.ts | 4 ---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/pkg.navigation/components/Community/CommunityMenu.tsx b/packages/pkg.navigation/components/Community/CommunityMenu.tsx index 8860475f..69e2fd62 100644 --- a/packages/pkg.navigation/components/Community/CommunityMenu.tsx +++ b/packages/pkg.navigation/components/Community/CommunityMenu.tsx @@ -2,7 +2,7 @@ /* eslint-disable jsx-a11y/no-static-element-interactions */ /* eslint-disable jsx-a11y/click-events-have-key-events */ - +import { useState } from 'react'; import { Modal, ModalContent } from '@xipkg/modal'; import { CategoryCreate } from 'pkg.modal.category-create'; import { CommunitySettings } from 'pkg.community.settings'; @@ -17,16 +17,16 @@ export const CommunityMenu = () => { const { isOpenCommunitySettings, isInviteCommunityModalOpen, - isAddCommunityModalOpen, isCategoryCreateOpen, isCommunityChannelCreateOpen, setIsOpenCommunitySettings, setIsInviteCommunityModalOpen, - setIsAddCommunityModalOpen, setIsCategoryCreateOpen, setIsCommunityChannelCreateOpen, } = useCommunityStore(); + const [isAddCommunityModalOpen, setIsAddCommunityModalOpen] = useState(false); + return ( <> { open={isAddCommunityModalOpen} onOpenChange={() => setIsAddCommunityModalOpen(!isAddCommunityModalOpen)} /> - + ); }; diff --git a/packages/pkg.navigation/components/Dropdown/DropdownMenu.tsx b/packages/pkg.navigation/components/Dropdown/DropdownMenu.tsx index 08d8432b..581cf9cd 100644 --- a/packages/pkg.navigation/components/Dropdown/DropdownMenu.tsx +++ b/packages/pkg.navigation/components/Dropdown/DropdownMenu.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState, useMemo } from 'react'; +import React, { useEffect, useState, useMemo } from 'react'; import { DropdownMenu, DropdownMenuContent, @@ -16,7 +16,11 @@ import { CommunityLink } from '../Community'; import { useCommunityStore } from '../../store/communityStore'; import { RetrieveCommunityT } from '../types'; -export const DropdownMenuBasic = () => { +type DropdownMenuBasicPropsT = { + setIsAddCommunityModalOpen: React.Dispatch>; +}; + +export const DropdownMenuBasic = ({ setIsAddCommunityModalOpen }: DropdownMenuBasicPropsT) => { const [isOpen, setIsOpen] = useState(false); const { @@ -24,7 +28,6 @@ export const DropdownMenuBasic = () => { setIsInviteCommunityModalOpen, isCommunityChannelCreateOpen, setIsCommunityChannelCreateOpen, - setIsAddCommunityModalOpen, setIsCategoryCreateOpen, isCategoryCreateOpen, setIsOpenCommunitySettings, diff --git a/packages/pkg.navigation/store/communityStore.ts b/packages/pkg.navigation/store/communityStore.ts index 56e3b942..819bb277 100644 --- a/packages/pkg.navigation/store/communityStore.ts +++ b/packages/pkg.navigation/store/communityStore.ts @@ -3,13 +3,11 @@ import { create } from 'zustand'; type CommunityStateT = { isOpenCommunitySettings: boolean; isInviteCommunityModalOpen: boolean; - isAddCommunityModalOpen: boolean; isCategoryCreateOpen: boolean; isCommunityChannelCreateOpen: boolean; setIsOpenCommunitySettings: (isOpen: boolean) => void; setIsInviteCommunityModalOpen: (isOpen: boolean) => void; - setIsAddCommunityModalOpen: (isOpen: boolean) => void; setIsCategoryCreateOpen: (isOpen: boolean) => void; setIsCommunityChannelCreateOpen: (isOpen: boolean) => void; }; @@ -17,13 +15,11 @@ type CommunityStateT = { export const useCommunityStore = create((set) => ({ isOpenCommunitySettings: false, isInviteCommunityModalOpen: false, - isAddCommunityModalOpen: false, isCategoryCreateOpen: false, isCommunityChannelCreateOpen: false, setIsOpenCommunitySettings: (isOpen: boolean) => set({ isOpenCommunitySettings: isOpen }), setIsInviteCommunityModalOpen: (isOpen: boolean) => set({ isInviteCommunityModalOpen: isOpen }), - setIsAddCommunityModalOpen: (isOpen: boolean) => set({ isAddCommunityModalOpen: isOpen }), setIsCategoryCreateOpen: (isOpen: boolean) => set({ isCategoryCreateOpen: isOpen }), setIsCommunityChannelCreateOpen: (isOpen: boolean) => set({ isCommunityChannelCreateOpen: isOpen }), From a71991520dc0a1594584f2bc24514953a43f5b39 Mon Sep 17 00:00:00 2001 From: reinaka Date: Tue, 15 Oct 2024 11:02:52 +0300 Subject: [PATCH 2/5] fix(39379966): set state to create if modal is closed --- .../pkg.modal.add-community/AddCommunityModal.tsx | 15 ++++++++++----- .../components/Community/CommunityMenu.tsx | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/pkg.modal.add-community/AddCommunityModal.tsx b/packages/pkg.modal.add-community/AddCommunityModal.tsx index 7e8a0c69..f6c5888a 100644 --- a/packages/pkg.modal.add-community/AddCommunityModal.tsx +++ b/packages/pkg.modal.add-community/AddCommunityModal.tsx @@ -9,14 +9,19 @@ import FormJoin from './components/FormJoinStage'; type AddCommunityModalT = { open: boolean; - onOpenChange: (value: boolean) => void; + setIsAddCommunityModalOpen: React.Dispatch>; }; -export const AddCommunityModal = ({ open, onOpenChange }: AddCommunityModalT) => { +export const AddCommunityModal = ({ open, setIsAddCommunityModalOpen }: AddCommunityModalT) => { const [stage, setStage] = useState<'create' | 'join'>('create'); + const handleOpenChange = () => { + setIsAddCommunityModalOpen(!open); + setStage('create'); + }; + return ( - + @@ -26,7 +31,7 @@ export const AddCommunityModal = ({ open, onOpenChange }: AddCommunityModalT) => Создание сообщества - +

У вас есть приглашение?