Skip to content
Snippets Groups Projects
Commit 8e5adaf5 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

open add comment modal

parent e6173b17
No related branches found
No related tags found
2 merge requests!223reset the pin numbers before search results are fetch (so the results will be...,!202Resolve "[MIN-264] Right click - Add comment"
...@@ -3,7 +3,7 @@ import { contextMenuSelector } from '@/redux/contextMenu/contextMenu.selector'; ...@@ -3,7 +3,7 @@ import { contextMenuSelector } from '@/redux/contextMenu/contextMenu.selector';
import { closeContextMenu } from '@/redux/contextMenu/contextMenu.slice'; import { closeContextMenu } from '@/redux/contextMenu/contextMenu.slice';
import { useAppDispatch } from '@/redux/hooks/useAppDispatch'; import { useAppDispatch } from '@/redux/hooks/useAppDispatch';
import { useAppSelector } from '@/redux/hooks/useAppSelector'; import { useAppSelector } from '@/redux/hooks/useAppSelector';
import { openMolArtModalById } from '@/redux/modal/modal.slice'; import { openAddCommentModal, openMolArtModalById } from '@/redux/modal/modal.slice';
import React from 'react'; import React from 'react';
import { twMerge } from 'tailwind-merge'; import { twMerge } from 'tailwind-merge';
...@@ -27,6 +27,11 @@ export const ContextMenu = (): React.ReactNode => { ...@@ -27,6 +27,11 @@ export const ContextMenu = (): React.ReactNode => {
} }
}; };
const handleAddCommentClick = (): void => {
dispatch(closeContextMenu());
dispatch(openAddCommentModal());
};
return ( return (
<div <div
className={twMerge( className={twMerge(
...@@ -50,6 +55,15 @@ export const ContextMenu = (): React.ReactNode => { ...@@ -50,6 +55,15 @@ export const ContextMenu = (): React.ReactNode => {
> >
Open MolArt ({getUnitProtId()}) Open MolArt ({getUnitProtId()})
</button> </button>
<hr />
<button
className={twMerge('cursor-pointer text-xs font-normal')}
onClick={handleAddCommentClick}
type="button"
data-testid="add-comment"
>
Add comment
</button>
</div> </div>
); );
}; };
import { useAppSelector } from '@/redux/hooks/useAppSelector'; import { useAppSelector } from '@/redux/hooks/useAppSelector';
import { modalSelector } from '@/redux/modal/modal.selector'; import { modalSelector } from '@/redux/modal/modal.selector';
import dynamic from 'next/dynamic'; import dynamic from 'next/dynamic';
import { AddCommentModal } from '@/components/FunctionalArea/Modal/AddCommentModal/AddCommentModal.component';
import { EditOverlayModal } from './EditOverlayModal'; import { EditOverlayModal } from './EditOverlayModal';
import { LoginModal } from './LoginModal'; import { LoginModal } from './LoginModal';
import { ModalLayout } from './ModalLayout'; import { ModalLayout } from './ModalLayout';
...@@ -44,6 +45,11 @@ export const Modal = (): React.ReactNode => { ...@@ -44,6 +45,11 @@ export const Modal = (): React.ReactNode => {
<LoggedInMenuModal /> <LoggedInMenuModal />
</ModalLayout> </ModalLayout>
)} )}
{isOpen && modalName === 'add-comment' && (
<ModalLayout>
<AddCommentModal />
</ModalLayout>
)}
</> </>
); );
}; };
...@@ -28,6 +28,7 @@ export const ModalLayout = ({ children }: ModalLayoutProps): JSX.Element => { ...@@ -28,6 +28,7 @@ export const ModalLayout = ({ children }: ModalLayoutProps): JSX.Element => {
className={twMerge( className={twMerge(
'flex h-5/6 w-10/12 flex-col overflow-hidden rounded-lg', 'flex h-5/6 w-10/12 flex-col overflow-hidden rounded-lg',
modalName === 'login' && 'h-auto w-[400px]', modalName === 'login' && 'h-auto w-[400px]',
modalName === 'add-comment' && 'h-auto w-[400px]',
['edit-overlay', 'logged-in-menu'].includes(modalName) && 'h-auto w-[432px]', ['edit-overlay', 'logged-in-menu'].includes(modalName) && 'h-auto w-[432px]',
)} )}
> >
......
...@@ -42,6 +42,12 @@ export const openLoginModalReducer = (state: ModalState): void => { ...@@ -42,6 +42,12 @@ export const openLoginModalReducer = (state: ModalState): void => {
state.modalTitle = 'You need to login'; state.modalTitle = 'You need to login';
}; };
export const openAddCommentModalReducer = (state: ModalState): void => {
state.isOpen = true;
state.modalName = 'add-comment';
state.modalTitle = 'Add comment';
};
export const openLoggedInMenuModalReducer = (state: ModalState): void => { export const openLoggedInMenuModalReducer = (state: ModalState): void => {
state.isOpen = true; state.isOpen = true;
state.modalName = 'logged-in-menu'; state.modalName = 'logged-in-menu';
......
...@@ -10,6 +10,7 @@ import { ...@@ -10,6 +10,7 @@ import {
openPublicationsModalReducer, openPublicationsModalReducer,
openEditOverlayModalReducer, openEditOverlayModalReducer,
openLoggedInMenuModalReducer, openLoggedInMenuModalReducer,
openAddCommentModalReducer,
} from './modal.reducers'; } from './modal.reducers';
const modalSlice = createSlice({ const modalSlice = createSlice({
...@@ -22,6 +23,7 @@ const modalSlice = createSlice({ ...@@ -22,6 +23,7 @@ const modalSlice = createSlice({
openMolArtModalById: openMolArtModalByIdReducer, openMolArtModalById: openMolArtModalByIdReducer,
setOverviewImageId: setOverviewImageIdReducer, setOverviewImageId: setOverviewImageIdReducer,
openLoginModal: openLoginModalReducer, openLoginModal: openLoginModalReducer,
openAddCommentModal: openAddCommentModalReducer,
openPublicationsModal: openPublicationsModalReducer, openPublicationsModal: openPublicationsModalReducer,
openEditOverlayModal: openEditOverlayModalReducer, openEditOverlayModal: openEditOverlayModalReducer,
openLoggedInMenuModal: openLoggedInMenuModalReducer, openLoggedInMenuModal: openLoggedInMenuModalReducer,
...@@ -33,6 +35,7 @@ export const { ...@@ -33,6 +35,7 @@ export const {
closeModal, closeModal,
openOverviewImagesModalById, openOverviewImagesModalById,
setOverviewImageId, setOverviewImageId,
openAddCommentModal,
openMolArtModalById, openMolArtModalById,
openLoginModal, openLoginModal,
openPublicationsModal, openPublicationsModal,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment