13639$ types 13639$
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
import React from 'react';
|
||||
import NavigationPrompt from 'react-router-navigation-prompt';
|
||||
import { useAuth } from '@payloadcms/config-provider';
|
||||
import { useFormModified } from '../../forms/Form/context';
|
||||
import MinimalTemplate from '../../templates/Minimal';
|
||||
import Button from '../../elements/Button';
|
||||
import { useAuth } from '@payloadcms/config-provider';
|
||||
|
||||
import './index.scss';
|
||||
|
||||
const modalSlug = 'leave-without-saving';
|
||||
|
||||
const LeaveWithoutSaving = () => {
|
||||
const LeaveWithoutSaving: React.FC = () => {
|
||||
const modified = useFormModified();
|
||||
const { user } = useAuth();
|
||||
|
||||
return (
|
||||
<NavigationPrompt when={modified && user}>
|
||||
<NavigationPrompt when={Boolean(modified && user)}>
|
||||
{({ onConfirm, onCancel }) => (
|
||||
<div className={modalSlug}>
|
||||
<MinimalTemplate>
|
||||
|
||||
@@ -5,12 +5,13 @@ import { useModal, Modal } from '@faceless-ui/modal';
|
||||
import { useConfig } from '@payloadcms/config-provider';
|
||||
import MinimalTemplate from '../../templates/Minimal';
|
||||
import Button from '../../elements/Button';
|
||||
import { Props } from './types';
|
||||
|
||||
import './index.scss';
|
||||
|
||||
const baseClass = 'stay-logged-in';
|
||||
|
||||
const StayLoggedInModal = (props) => {
|
||||
const StayLoggedInModal: React.FC<Props> = (props) => {
|
||||
const { refreshCookie } = props;
|
||||
const history = useHistory();
|
||||
const { routes: { admin } } = useConfig();
|
||||
|
||||
4
src/admin/components/modals/StayLoggedIn/types.ts
Normal file
4
src/admin/components/modals/StayLoggedIn/types.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
export type Props = {
|
||||
refreshCookie: () => void
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import DefaultNav from '../../elements/Nav';
|
||||
import { useConfig } from '@payloadcms/config-provider';
|
||||
import DefaultNav from '../../elements/Nav';
|
||||
import { StepNavProvider } from '../../elements/StepNav';
|
||||
import RenderCustomComponent from '../../utilities/RenderCustomComponent';
|
||||
import Meta from '../../utilities/Meta';
|
||||
import { Props } from './types';
|
||||
|
||||
import './index.scss';
|
||||
|
||||
const baseClass = 'template-default';
|
||||
|
||||
const Default = ({ children, className }) => {
|
||||
const Default: React.FC<Props> = ({ children, className }) => {
|
||||
const {
|
||||
admin: {
|
||||
components: {
|
||||
@@ -44,16 +44,4 @@ const Default = ({ children, className }) => {
|
||||
);
|
||||
};
|
||||
|
||||
Default.defaultProps = {
|
||||
className: '',
|
||||
};
|
||||
|
||||
Default.propTypes = {
|
||||
children: PropTypes.oneOfType([
|
||||
PropTypes.arrayOf(PropTypes.node),
|
||||
PropTypes.node,
|
||||
]).isRequired,
|
||||
className: PropTypes.string,
|
||||
};
|
||||
|
||||
export default Default;
|
||||
|
||||
3
src/admin/components/templates/Default/types.ts
Normal file
3
src/admin/components/templates/Default/types.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export type Props = {
|
||||
className?: string,
|
||||
};
|
||||
@@ -1,13 +1,16 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Props } from './types';
|
||||
|
||||
import './index.scss';
|
||||
|
||||
const baseClass = 'template-minimal';
|
||||
|
||||
const Minimal = (props) => {
|
||||
const Minimal: React.FC<Props> = (props) => {
|
||||
const {
|
||||
className, style, children, width,
|
||||
className,
|
||||
style = {},
|
||||
children,
|
||||
width = 'normal',
|
||||
} = props;
|
||||
|
||||
const classes = [
|
||||
@@ -28,17 +31,4 @@ const Minimal = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
Minimal.defaultProps = {
|
||||
className: null,
|
||||
style: {},
|
||||
width: 'normal',
|
||||
};
|
||||
|
||||
Minimal.propTypes = {
|
||||
className: PropTypes.string,
|
||||
style: PropTypes.shape({}),
|
||||
children: PropTypes.node.isRequired,
|
||||
width: PropTypes.oneOf(['normal', 'wide']),
|
||||
};
|
||||
|
||||
export default Minimal;
|
||||
|
||||
7
src/admin/components/templates/Minimal/types.ts
Normal file
7
src/admin/components/templates/Minimal/types.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import React from 'react';
|
||||
|
||||
export type Props = {
|
||||
className?: string,
|
||||
width?: 'normal' | 'wide'
|
||||
style?: React.CSSProperties
|
||||
};
|
||||
@@ -15,7 +15,7 @@ export const LocaleProvider: React.FC = ({ children }) => {
|
||||
const localeFromParams = searchParams.locale;
|
||||
|
||||
useEffect(() => {
|
||||
if (localeFromParams && localization.locales.indexOf(localeFromParams) > -1) setLocale(localeFromParams as string);
|
||||
if (localeFromParams && localization.locales.indexOf(localeFromParams as string) > -1) setLocale(localeFromParams as string);
|
||||
}, [localeFromParams, localization]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
|
||||
export type Props = {
|
||||
CustomComponent: React.FC
|
||||
DefaultComponent: React.FC
|
||||
componentProps: unknown
|
||||
CustomComponent: React.ComponentType
|
||||
DefaultComponent: React.ComponentType
|
||||
componentProps?: unknown
|
||||
}
|
||||
|
||||
@@ -57,6 +57,9 @@ export type PayloadConfig = {
|
||||
}
|
||||
disable?: boolean;
|
||||
indexHTML?: string;
|
||||
components?: {
|
||||
Nav: React.ComponentType
|
||||
}
|
||||
};
|
||||
collections?: Collection[];
|
||||
globals?: Global[];
|
||||
@@ -92,7 +95,8 @@ export type PayloadConfig = {
|
||||
};
|
||||
};
|
||||
localization?: {
|
||||
locales: string[];
|
||||
locales: string[]
|
||||
defaultLocale: string
|
||||
};
|
||||
defaultLocale?: string;
|
||||
fallback?: boolean;
|
||||
|
||||
Reference in New Issue
Block a user