2020-01-18 02:07:52 +05:30
|
|
|
import React, { ComponentProps, ComponentType } from 'react';
|
2019-12-08 00:32:00 +05:30
|
|
|
import { Button } from 'app/components/ui/form';
|
2020-01-18 02:07:52 +05:30
|
|
|
import RejectionLink from 'app/components/auth/RejectionLink';
|
2019-12-08 00:32:00 +05:30
|
|
|
import AuthTitle from 'app/components/auth/AuthTitle';
|
2019-12-07 16:58:52 +05:30
|
|
|
import { MessageDescriptor } from 'react-intl';
|
2019-12-08 00:32:00 +05:30
|
|
|
import { Color } from 'app/components/ui';
|
2020-01-18 02:07:52 +05:30
|
|
|
import BaseAuthBody from './BaseAuthBody';
|
2019-12-07 16:58:52 +05:30
|
|
|
|
2020-01-18 02:07:52 +05:30
|
|
|
export type Factory = () => {
|
|
|
|
Title: ComponentType;
|
|
|
|
Body: typeof BaseAuthBody;
|
|
|
|
Footer: ComponentType;
|
|
|
|
Links: ComponentType;
|
|
|
|
};
|
|
|
|
|
|
|
|
type RejectionLinkProps = ComponentProps<typeof RejectionLink>;
|
|
|
|
interface FactoryParams {
|
2019-12-07 16:58:52 +05:30
|
|
|
title: MessageDescriptor;
|
2020-01-18 02:07:52 +05:30
|
|
|
body: typeof BaseAuthBody;
|
2019-12-07 16:58:52 +05:30
|
|
|
footer: {
|
|
|
|
color?: Color;
|
|
|
|
label: string | MessageDescriptor;
|
|
|
|
autoFocus?: boolean;
|
|
|
|
};
|
2020-01-18 02:07:52 +05:30
|
|
|
links?: RejectionLinkProps | Array<RejectionLinkProps>;
|
|
|
|
}
|
|
|
|
|
2020-05-20 22:05:52 +05:30
|
|
|
export default function ({
|
2020-01-18 02:07:52 +05:30
|
|
|
title,
|
|
|
|
body,
|
|
|
|
footer,
|
|
|
|
links,
|
|
|
|
}: FactoryParams): Factory {
|
2019-12-07 16:58:52 +05:30
|
|
|
return () => ({
|
|
|
|
Title: () => <AuthTitle title={title} />,
|
|
|
|
Body: body,
|
|
|
|
Footer: () => <Button type="submit" {...footer} />,
|
|
|
|
Links: () =>
|
|
|
|
links ? (
|
|
|
|
<span>
|
2020-01-18 02:07:52 +05:30
|
|
|
{([] as Array<RejectionLinkProps>)
|
2019-12-07 16:58:52 +05:30
|
|
|
.concat(links)
|
|
|
|
.map((link, index) => [
|
|
|
|
index ? ' | ' : '',
|
|
|
|
<RejectionLink {...link} key={index} />,
|
|
|
|
])}
|
|
|
|
</span>
|
|
|
|
) : null,
|
|
|
|
});
|
|
|
|
}
|