Lint frontend (#131)
* Add lint-fix npm target * Sync eslint+plugins with backend * Add prettier * Ignore no-explicit-any lint rule for now * Silence eslint react warning * Format frontend via prettier * Lint frontend. --------- Co-authored-by: antanst <>
This commit is contained in:
parent
f433dbffe3
commit
220bc92b4a
114 changed files with 30271 additions and 48239 deletions
|
|
@ -1,42 +1,44 @@
|
|||
import React, { createContext, useContext, useState, ReactNode } from 'react';
|
||||
|
||||
interface ModalContextType {
|
||||
isAnyModalOpen: boolean;
|
||||
openModal: () => void;
|
||||
closeModal: () => void;
|
||||
modalCount: number;
|
||||
isAnyModalOpen: boolean;
|
||||
openModal: () => void;
|
||||
closeModal: () => void;
|
||||
modalCount: number;
|
||||
}
|
||||
|
||||
const ModalContext = createContext<ModalContextType | undefined>(undefined);
|
||||
|
||||
export const useModal = () => {
|
||||
const context = useContext(ModalContext);
|
||||
if (context === undefined) {
|
||||
throw new Error('useModal must be used within a ModalProvider');
|
||||
}
|
||||
return context;
|
||||
const context = useContext(ModalContext);
|
||||
if (context === undefined) {
|
||||
throw new Error('useModal must be used within a ModalProvider');
|
||||
}
|
||||
return context;
|
||||
};
|
||||
|
||||
interface ModalProviderProps {
|
||||
children: ReactNode;
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export const ModalProvider: React.FC<ModalProviderProps> = ({ children }) => {
|
||||
const [modalCount, setModalCount] = useState(0);
|
||||
const [modalCount, setModalCount] = useState(0);
|
||||
|
||||
const openModal = () => {
|
||||
setModalCount(prev => prev + 1);
|
||||
};
|
||||
const openModal = () => {
|
||||
setModalCount((prev) => prev + 1);
|
||||
};
|
||||
|
||||
const closeModal = () => {
|
||||
setModalCount(prev => Math.max(0, prev - 1));
|
||||
};
|
||||
const closeModal = () => {
|
||||
setModalCount((prev) => Math.max(0, prev - 1));
|
||||
};
|
||||
|
||||
const isAnyModalOpen = modalCount > 0;
|
||||
const isAnyModalOpen = modalCount > 0;
|
||||
|
||||
return (
|
||||
<ModalContext.Provider value={{ isAnyModalOpen, openModal, closeModal, modalCount }}>
|
||||
{children}
|
||||
</ModalContext.Provider>
|
||||
);
|
||||
};
|
||||
return (
|
||||
<ModalContext.Provider
|
||||
value={{ isAnyModalOpen, openModal, closeModal, modalCount }}
|
||||
>
|
||||
{children}
|
||||
</ModalContext.Provider>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue