💄(frontend) update doc export modal

In the new interface, the export modal changes a little.

- We put the buttons on the right
- We remove the alert
- We transform the radio into select
This commit is contained in:
Nathan Panchout
2024-11-25 14:28:30 +01:00
committed by Anthony LC
parent 3a738fe701
commit 5bcce0c64a
3 changed files with 91 additions and 67 deletions

View File

@@ -532,6 +532,12 @@ input:-webkit-autofill:focus {
overflow-y: auto;
}
.c__modal__title {
padding: 0;
font-size: 1.125rem;
margin-bottom: var(--c--theme--spacings--sm);
}
@media screen and (width <= 420px) {
.c__modal__scroller {
padding: 0.7rem;

View File

@@ -1,11 +1,8 @@
import {
Alert,
Button,
Loader,
Modal,
ModalSize,
Radio,
RadioGroup,
Select,
VariantType,
useToastProvider,
@@ -21,6 +18,11 @@ import { useExport } from '../api/useExport';
import { TemplatesOrdering, useTemplates } from '../api/useTemplates';
import { adaptBlockNoteHTML, downloadFile } from '../utils';
export enum DocDownloadFormat {
PDF = 'pdf',
DOCX = 'docx',
}
interface ModalPDFProps {
onClose: () => void;
doc: Doc;
@@ -41,7 +43,9 @@ export const ModalPDF = ({ onClose, doc }: ModalPDFProps) => {
error,
} = useExport();
const [templateIdSelected, setTemplateIdSelected] = useState<string>();
const [format, setFormat] = useState<'pdf' | 'docx'>('pdf');
const [format, setFormat] = useState<DocDownloadFormat>(
DocDownloadFormat.PDF,
);
const templateOptions = useMemo(() => {
if (!templates?.pages) {
@@ -123,46 +127,37 @@ export const ModalPDF = ({ onClose, doc }: ModalPDFProps) => {
return (
<Modal
data-testid="modal-export"
isOpen
closeOnClickOutside
hideCloseButton
leftActions={
<Button
aria-label={t('Close the modal')}
color="secondary"
fullWidth
onClick={() => onClose()}
>
{t('Cancel')}
</Button>
}
onClose={() => onClose()}
rightActions={
<Button
aria-label={t('Download')}
color="primary"
fullWidth
onClick={() => void onSubmit()}
disabled={isPending || !templateIdSelected}
>
{t('Download')}
</Button>
<>
<Button
aria-label={t('Close the modal')}
color="secondary"
fullWidth
onClick={() => onClose()}
>
{t('Cancel')}
</Button>
<Button
aria-label={t('Download')}
color="primary"
fullWidth
onClick={() => void onSubmit()}
disabled={isPending || !templateIdSelected}
>
{t('Download')}
</Button>
</>
}
size={ModalSize.MEDIUM}
title={
<Box $align="center" $gap="1rem">
<Text
className="material-icons"
$size="3.5rem"
$theme="primary"
$variation="600"
>
picture_as_pdf
</Text>
<Text as="h2" $size="h3" $margin="none" $theme="primary">
{t('Export')}
</Text>
</Box>
<Text $size="h6" $align="flex-start">
{t('Download')}
</Text>
}
>
<Box
@@ -170,14 +165,11 @@ export const ModalPDF = ({ onClose, doc }: ModalPDFProps) => {
aria-label={t('Content modal to export the document')}
$gap="1.5rem"
>
<Alert canClose={false} type={VariantType.INFO}>
<Text>
{t(
'Export your document, it will be inserted in the selected template.',
)}
</Text>
</Alert>
<Text $variation="600">
{t(
'Upload your docs to a Microsoft Word, Open Office or PDF document.',
)}
</Text>
<Select
clearable={false}
label={t('Template')}
@@ -187,22 +179,19 @@ export const ModalPDF = ({ onClose, doc }: ModalPDFProps) => {
setTemplateIdSelected(options.target.value as string)
}
/>
<RadioGroup>
<Radio
label={t('PDF')}
value="pdf"
name="format"
onChange={(evt) => setFormat(evt.target.value as 'pdf')}
defaultChecked={true}
/>
<Radio
label={t('Docx')}
value="docx"
name="format"
onChange={(evt) => setFormat(evt.target.value as 'docx')}
/>
</RadioGroup>
<Select
clearable={false}
fullWidth
label={t('Format')}
options={[
{ label: t('Word / Open Office'), value: DocDownloadFormat.DOCX },
{ label: t('PDF'), value: DocDownloadFormat.PDF },
]}
value={format}
onChange={(options) =>
setFormat(options.target.value as DocDownloadFormat)
}
/>
{isPending && (
<Box $align="center" $margin={{ top: 'big' }}>