Skip to content

Commit 700f3c5

Browse files
committed
feat: fix duplicate modals
1 parent 9c5785b commit 700f3c5

File tree

6 files changed

+13
-4
lines changed

6 files changed

+13
-4
lines changed

apps/frontend/src/components/launches/calendar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ import { AddEditModal } from '@gitroom/frontend/components/new-launch/add.edit.m
5353
import { deleteDialog } from '@gitroom/react/helpers/delete.dialog';
5454
import { useVariables } from '@gitroom/react/helpers/variable.context';
5555
import { stripHtmlValidation } from '@gitroom/helpers/utils/strip.html.validation';
56-
import { ModalWrapperComponent } from '../new-launch/modal.wrapper.component';
5756
import { newDayjs } from '@gitroom/frontend/components/layout/set.timezone';
5857

5958
// Extend dayjs with necessary plugins
@@ -464,6 +463,7 @@ export const CalendarColumn: FC<{
464463
? ExistingDataContextProvider
465464
: Fragment;
466465
modal.openModal({
466+
id: 'add-edit-modal',
467467
closeOnClickOutside: false,
468468
removeLayout: true,
469469
closeOnEscape: false,
@@ -553,6 +553,7 @@ export const CalendarColumn: FC<{
553553
classNames: {
554554
modal: 'w-[100%] max-w-[1400px] text-textColor',
555555
},
556+
id: 'add-edit-modal',
556557
children: (
557558
<AddEditModal
558559
allIntegrations={integrations.map((p) => ({

apps/frontend/src/components/launches/generator/generator.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ const FirstStep: FC = (props) => {
158158
classNames: {
159159
modal: 'w-[100%] max-w-[1400px] bg-transparent text-textColor',
160160
},
161+
id: 'add-edit-modal',
161162
children: (
162163
<AddEditModal
163164
allIntegrations={integrations.map((p) => ({

apps/frontend/src/components/launches/menu/menu.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ export const Menu: FC<{
174174
classNames: {
175175
modal: 'w-[100%] max-w-[1400px] bg-transparent text-textColor',
176176
},
177+
id: 'add-edit-modal',
177178
children: (
178179
<AddEditModal
179180
allIntegrations={integrations.map((p) => ({

apps/frontend/src/components/launches/new.post.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export const NewPost = () => {
5656
classNames: {
5757
modal: 'w-[100%] max-w-[1400px] bg-transparent text-textColor',
5858
},
59+
id: 'add-edit-modal',
5960
children: (
6061
<AddEditModal
6162
allIntegrations={integrations.map((p) => ({

apps/frontend/src/components/layout/new-modal.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,17 @@ interface State extends ModalManagerStoreInterface {
4545

4646
const useModalStore = create<State>((set) => ({
4747
modalManager: [],
48-
openModal: (params) =>
48+
openModal: (params) => {
49+
const newId = params.id || makeId(20);
4950
set((state) => ({
5051
modalManager: [
5152
...state.modalManager,
52-
{ id: params.id || makeId(20), ...params },
53+
...(!state.modalManager.some((p) => p.id === newId)
54+
? [{ id: newId, ...params }]
55+
: []),
5356
],
54-
})),
57+
}));
58+
},
5559
closeById: (id) =>
5660
set((state) => ({
5761
modalManager: state.modalManager.filter((modal) => modal.id !== id),

apps/frontend/src/components/sets/sets.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export const Sets: FC = () => {
9898
withCloseButton: false,
9999
removeLayout: true,
100100
askClose: true,
101+
id: 'add-edit-modal',
101102
children: (
102103
<AddEditModal
103104
allIntegrations={integrations.map((p: any) => ({

0 commit comments

Comments
 (0)