Skip to content

Commit 3cee66f

Browse files
committed
chore(review): support direction in views
1 parent 85dcec5 commit 3cee66f

File tree

21 files changed

+64
-136
lines changed

21 files changed

+64
-136
lines changed

src/features/language_switcher/useLanguage.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ const useLanguage = () => {
5252
};
5353

5454
const handleLangChange = async (ui_lang: string) => {
55-
console.log(ui_lang);
5655
handleClose();
5756

5857
const findLanguage = LANGUAGE_LIST.find(

src/features/reports/meeting_attendance/export_S88/useExportS88.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,9 @@ const useExportS88 = () => {
472472
}),
473473
};
474474

475-
const blob = await pdf(<TemplateS88 attendance={finalData} />).toBlob();
475+
const blob = await pdf(
476+
<TemplateS88 attendance={finalData} lang={lang} />
477+
).toBlob();
476478

477479
const filename = `S-88.pdf`;
478480

src/layouts/navbar/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ const NavBar = ({ isSupported }: NavBarType) => {
461461
'& svg': {
462462
transform:
463463
theme.direction === 'rtl'
464-
? 'translateX(-4px) scaleX(-1)'
464+
? 'translateX(4px) scaleX(-1)'
465465
: 'translateX(-4px)',
466466
},
467467
},

src/main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const getInitialTheme = () => {
3030
};
3131

3232
const getInitialDirection = () => {
33-
const savedLang = localStorage.getItem('appLang') || 'eng';
33+
const savedLang = localStorage.getItem('ui_lang') || 'eng';
3434
const direction = LANGUAGE_LIST.find(
3535
(record) => record.threeLettersCode === savedLang
3636
)?.direction;

src/views/activities/upcoming_events/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ const TemplateUpcomingEvents = ({
1212
const { t } = useAppTranslation();
1313

1414
return (
15-
<Document title={t('tr_upcomingEvents')}>
16-
<Page lang={lang}>
15+
<Document title={t('tr_upcomingEvents')} lang={lang}>
16+
<Page>
1717
<PageContent>
1818
<PageHeader
1919
variant="secondary"

src/views/components/document/index.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
import { Document as ReactPDFDocument } from '@react-pdf/renderer';
22
import { PDFDocumentType } from './index.types';
3+
import { LANGUAGE_LIST } from '@constants/index';
34
import registerFonts from '@views/registerFonts';
45

56
registerFonts();
67

7-
const Document = ({ title, children }: PDFDocumentType) => {
8+
const Document = ({ title, children, lang }: PDFDocumentType) => {
9+
const font =
10+
LANGUAGE_LIST.find((record) => record.threeLettersCode === lang)?.font ??
11+
'Inter';
12+
13+
const direction = (LANGUAGE_LIST.find(
14+
(record) => record.threeLettersCode === lang
15+
)?.direction ?? 'ltr') as 'ltr' | 'rtl';
16+
817
return (
918
<ReactPDFDocument
1019
author="sws2apps"
1120
title={title}
1221
creator="Organized"
1322
producer="sws2apps (by react-pdf)"
23+
style={{ fontFamily: font, direction }}
1424
>
1525
{children}
1626
</ReactPDFDocument>

src/views/components/document/index.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ import { ReactNode } from 'react';
44
export type PDFDocumentType = {
55
title: string;
66
children: ReactNode;
7+
lang: string;
78
};

src/views/components/page/index.tsx

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
11
import { Page as ReactPDFPage } from '@react-pdf/renderer';
2-
import { LANGUAGE_LIST } from '@constants/index';
32
import { PageType } from './index.types';
43

5-
const Page = ({ lang, children }: PageType) => {
6-
const font =
7-
LANGUAGE_LIST.find((record) => record.threeLettersCode === lang)?.font ||
8-
'Inter';
9-
4+
const Page = ({ children }: PageType) => {
105
return (
116
<ReactPDFPage
127
size="A4"
13-
style={[
14-
{
15-
padding: '20px',
16-
backgroundColor: '#FFFFFF',
17-
display: 'flex',
18-
flexDirection: 'column',
19-
justifyContent: 'space-between',
20-
},
21-
{ fontFamily: font },
22-
]}
8+
style={{
9+
padding: '20px',
10+
backgroundColor: '#FFFFFF',
11+
display: 'flex',
12+
flexDirection: 'column',
13+
justifyContent: 'space-between',
14+
}}
2315
>
2416
{children}
2517
</ReactPDFPage>
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { ReactNode } from 'react';
22

33
export type PageType = {
4-
lang: string;
54
children: ReactNode;
65
};

src/views/congregation/field_service_groups/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ const TemplateFieldServiceGroups = ({
1414
const { t } = useAppTranslation();
1515

1616
return (
17-
<Document title={t('tr_fieldServiceGroups')}>
18-
<Page lang={lang}>
17+
<Document title={t('tr_fieldServiceGroups')} lang={lang}>
18+
<Page>
1919
<PageContent gap={10}>
2020
<PageHeader
2121
congregationName={congregation}

0 commit comments

Comments
 (0)