13639$ types 13639$

This commit is contained in:
James
2020-11-25 11:23:03 -05:00
parent ed8d7f2106
commit 472a6cb232
10 changed files with 37 additions and 40 deletions

View File

@@ -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>

View File

@@ -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();

View File

@@ -0,0 +1,4 @@
export type Props = {
refreshCookie: () => void
}

View File

@@ -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;

View File

@@ -0,0 +1,3 @@
export type Props = {
className?: string,
};

View File

@@ -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;

View File

@@ -0,0 +1,7 @@
import React from 'react';
export type Props = {
className?: string,
width?: 'normal' | 'wide'
style?: React.CSSProperties
};

View File

@@ -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 (

View File

@@ -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
}

View File

@@ -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;