🏷️(frontend) adapt title types
We recently changed the default title behavior. It can now be undefined, we have to change the types accordingly.
This commit is contained in:
@@ -33,11 +33,13 @@ export const DocTitle = ({ doc }: DocTitleProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
interface DocTitleTextProps {
|
interface DocTitleTextProps {
|
||||||
title: string;
|
title?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DocTitleText = ({ title }: DocTitleTextProps) => {
|
export const DocTitleText = ({ title }: DocTitleTextProps) => {
|
||||||
const { isMobile } = useResponsiveStore();
|
const { isMobile } = useResponsiveStore();
|
||||||
|
const { untitledDocument } = useTrans();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Text
|
<Text
|
||||||
as="h2"
|
as="h2"
|
||||||
@@ -45,7 +47,7 @@ export const DocTitleText = ({ title }: DocTitleTextProps) => {
|
|||||||
$size={isMobile ? 'h4' : 'h2'}
|
$size={isMobile ? 'h4' : 'h2'}
|
||||||
$variation="1000"
|
$variation="1000"
|
||||||
>
|
>
|
||||||
{title}
|
{title || untitledDocument}
|
||||||
</Text>
|
</Text>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { useCunninghamTheme } from '@/cunningham';
|
|||||||
import { DocTitleText } from './DocTitle';
|
import { DocTitleText } from './DocTitle';
|
||||||
|
|
||||||
interface DocVersionHeaderProps {
|
interface DocVersionHeaderProps {
|
||||||
title: string;
|
title?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DocVersionHeader = ({ title }: DocVersionHeaderProps) => {
|
export const DocVersionHeader = ({ title }: DocVersionHeaderProps) => {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import { css } from 'styled-components';
|
|||||||
|
|
||||||
import { Box, Text } from '@/components';
|
import { Box, Text } from '@/components';
|
||||||
import { useEditorStore } from '@/features/docs/doc-editor';
|
import { useEditorStore } from '@/features/docs/doc-editor';
|
||||||
import { Doc } from '@/features/docs/doc-management';
|
import { Doc, useTrans } from '@/features/docs/doc-management';
|
||||||
|
|
||||||
import { TemplatesOrdering, useTemplates } from '../api/useTemplates';
|
import { TemplatesOrdering, useTemplates } from '../api/useTemplates';
|
||||||
import { downloadFile, exportResolveFileUrl } from '../utils';
|
import { downloadFile, exportResolveFileUrl } from '../utils';
|
||||||
@@ -51,6 +51,7 @@ export const ModalExport = ({ onClose, doc }: ModalExportProps) => {
|
|||||||
const [format, setFormat] = useState<DocDownloadFormat>(
|
const [format, setFormat] = useState<DocDownloadFormat>(
|
||||||
DocDownloadFormat.PDF,
|
DocDownloadFormat.PDF,
|
||||||
);
|
);
|
||||||
|
const { untitledDocument } = useTrans();
|
||||||
|
|
||||||
const templateOptions = useMemo(() => {
|
const templateOptions = useMemo(() => {
|
||||||
const templateOptions = (templates?.pages || [])
|
const templateOptions = (templates?.pages || [])
|
||||||
@@ -78,7 +79,7 @@ export const ModalExport = ({ onClose, doc }: ModalExportProps) => {
|
|||||||
|
|
||||||
setIsExporting(true);
|
setIsExporting(true);
|
||||||
|
|
||||||
const title = doc.title
|
const title = (doc.title || untitledDocument)
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.normalize('NFD')
|
.normalize('NFD')
|
||||||
.replace(/[\u0300-\u036f]/g, '')
|
.replace(/[\u0300-\u036f]/g, '')
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export type Base64 = string;
|
|||||||
|
|
||||||
export interface Doc {
|
export interface Doc {
|
||||||
id: string;
|
id: string;
|
||||||
title: string;
|
title?: string;
|
||||||
content: Base64;
|
content: Base64;
|
||||||
creator: string;
|
creator: string;
|
||||||
is_favorite: boolean;
|
is_favorite: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user