You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
827 B
35 lines
827 B
2 years ago
|
import {
|
||
|
ModalsProvider as MantineModalsProvider,
|
||
|
ModalsProviderProps as MantineModalsProviderProps,
|
||
|
} from "@mantine/modals";
|
||
|
import { FunctionComponent, useMemo } from "react";
|
||
|
import { ModalComponent, StaticModals } from "./WithModal";
|
||
|
|
||
|
const DefaultModalProps: MantineModalsProviderProps["modalProps"] = {
|
||
|
centered: true,
|
||
|
styles: {
|
||
|
modal: {
|
||
|
maxWidth: "100%",
|
||
|
},
|
||
|
},
|
||
|
};
|
||
|
|
||
|
const ModalsProvider: FunctionComponent = ({ children }) => {
|
||
|
const modals = useMemo(
|
||
|
() =>
|
||
|
StaticModals.reduce<Record<string, ModalComponent>>((prev, curr) => {
|
||
|
prev[curr.modalKey] = curr;
|
||
|
return prev;
|
||
|
}, {}),
|
||
|
[]
|
||
|
);
|
||
|
|
||
|
return (
|
||
|
<MantineModalsProvider modalProps={DefaultModalProps} modals={modals}>
|
||
|
{children}
|
||
|
</MantineModalsProvider>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
export default ModalsProvider;
|