feat: fix duplicate modals

This commit is contained in:
Nevo David 2025-09-20 15:25:43 +07:00
parent 9c5785b5cb
commit 700f3c5ccb
6 changed files with 13 additions and 4 deletions

View File

@ -53,7 +53,6 @@ import { AddEditModal } from '@gitroom/frontend/components/new-launch/add.edit.m
import { deleteDialog } from '@gitroom/react/helpers/delete.dialog';
import { useVariables } from '@gitroom/react/helpers/variable.context';
import { stripHtmlValidation } from '@gitroom/helpers/utils/strip.html.validation';
import { ModalWrapperComponent } from '../new-launch/modal.wrapper.component';
import { newDayjs } from '@gitroom/frontend/components/layout/set.timezone';
// Extend dayjs with necessary plugins
@ -464,6 +463,7 @@ export const CalendarColumn: FC<{
? ExistingDataContextProvider
: Fragment;
modal.openModal({
id: 'add-edit-modal',
closeOnClickOutside: false,
removeLayout: true,
closeOnEscape: false,
@ -553,6 +553,7 @@ export const CalendarColumn: FC<{
classNames: {
modal: 'w-[100%] max-w-[1400px] text-textColor',
},
id: 'add-edit-modal',
children: (
<AddEditModal
allIntegrations={integrations.map((p) => ({

View File

@ -158,6 +158,7 @@ const FirstStep: FC = (props) => {
classNames: {
modal: 'w-[100%] max-w-[1400px] bg-transparent text-textColor',
},
id: 'add-edit-modal',
children: (
<AddEditModal
allIntegrations={integrations.map((p) => ({

View File

@ -174,6 +174,7 @@ export const Menu: FC<{
classNames: {
modal: 'w-[100%] max-w-[1400px] bg-transparent text-textColor',
},
id: 'add-edit-modal',
children: (
<AddEditModal
allIntegrations={integrations.map((p) => ({

View File

@ -56,6 +56,7 @@ export const NewPost = () => {
classNames: {
modal: 'w-[100%] max-w-[1400px] bg-transparent text-textColor',
},
id: 'add-edit-modal',
children: (
<AddEditModal
allIntegrations={integrations.map((p) => ({

View File

@ -45,13 +45,17 @@ interface State extends ModalManagerStoreInterface {
const useModalStore = create<State>((set) => ({
modalManager: [],
openModal: (params) =>
openModal: (params) => {
const newId = params.id || makeId(20);
set((state) => ({
modalManager: [
...state.modalManager,
{ id: params.id || makeId(20), ...params },
...(!state.modalManager.some((p) => p.id === newId)
? [{ id: newId, ...params }]
: []),
],
})),
}));
},
closeById: (id) =>
set((state) => ({
modalManager: state.modalManager.filter((modal) => modal.id !== id),

View File

@ -98,6 +98,7 @@ export const Sets: FC = () => {
withCloseButton: false,
removeLayout: true,
askClose: true,
id: 'add-edit-modal',
children: (
<AddEditModal
allIntegrations={integrations.map((p: any) => ({