Skip to content

Commit f7974a4

Browse files
committed
chore: fixes positioning of elements when printing in english
1 parent e16f3d3 commit f7974a4

File tree

5 files changed

+66
-36
lines changed

5 files changed

+66
-36
lines changed

src/cv/components/employment-section/employment.tsx

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { LabelledTypography } from "@/shared/components/labelled-typography";
2+
import { PageBreak } from "@/shared/components/page-break";
23
import { EmploymentEntity } from "@/shared/entities/employment-entity";
3-
import { LocalizationService } from "@/shared/services/localization-service";
4+
import { EntityEmploymentLocalizationKeys } from "@/shared/localization/employment-localization";
5+
import { Language, LocalizationService } from "@/shared/services/localization-service";
46
import { Paper, Typography } from "@mui/material";
57
import { ReactNode } from "react";
68

@@ -15,19 +17,22 @@ export function Employment(props: EmploymentProps): JSX.Element {
1517
const employmentPeriode: string = buildEmploymentPeriodeString()
1618

1719
return (
18-
<Paper elevation={1} sx={{padding: '5px', margin: '5px'}}>
19-
<Typography color={'Highlight'}>
20-
{employedAsAt}
21-
</Typography>
22-
<Typography>
23-
{employmentPeriode}
24-
</Typography>
25-
<LabelledTypography
26-
labelText={entityLocalizationService.getComponentText("workDescriptionLabel")}
27-
labelProps={{color: 'GrayText'}}
28-
mainText={entityLocalizationService.getEntityText(props.employmentEntity.workDescriptionKey)}
29-
mainProps={{variant: 'body1', style: {whiteSpace: 'pre-line'}}}/>
30-
</Paper>
20+
<>
21+
{insertNewPageInPrint("employerApps4All", Language.ENGLISH)}
22+
<Paper elevation={1} sx={{padding: '5px', margin: '5px'}}>
23+
<Typography color={'Highlight'}>
24+
{employedAsAt}
25+
</Typography>
26+
<Typography>
27+
{employmentPeriode}
28+
</Typography>
29+
<LabelledTypography
30+
labelText={entityLocalizationService.getComponentText("workDescriptionLabel")}
31+
labelProps={{color: 'GrayText'}}
32+
mainText={entityLocalizationService.getEntityText(props.employmentEntity.workDescriptionKey)}
33+
mainProps={{variant: 'body1', style: {whiteSpace: 'pre-line'}}}/>
34+
</Paper>
35+
</>
3136
)
3237

3338
function buildEmployedAsAtString(): string {
@@ -69,4 +74,12 @@ export function Employment(props: EmploymentProps): JSX.Element {
6974
function getLocalizedDate(date: Date): string {
7075
return date.toLocaleDateString(localizationService.getCurrentLanguage(), {dateStyle: "medium"})
7176
}
77+
78+
function insertNewPageInPrint(employerKey: EntityEmploymentLocalizationKeys, language: Language): ReactNode {
79+
if (props.employmentEntity.employerKey === employerKey && localizationService.getCurrentLanguage() === language) {
80+
return (<PageBreak/>)
81+
}
82+
83+
return (<></>)
84+
}
7285
}
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import { PageBreak } from "@/shared/components/page-break";
2-
import { SkillEntity } from "@/shared/entities/skill-entity";
2+
import { SkillEntity, SkillName } from "@/shared/entities/skill-entity";
33
import { Paper, Rating, Typography } from "@mui/material";
44
import { ReactNode } from "react";
5+
import { Language, LocalizationService } from "@/shared/services/localization-service";
56

67
interface SkillProps {
78
skillEntity: SkillEntity
89
}
910

1011
export function Skill(props: SkillProps): JSX.Element {
12+
const localizationService = LocalizationService.instance
13+
1114
return (
1215
<>
13-
{insertNewPageInPrint('Java')}
16+
{insertNewPageInPrint(SkillName.JAVA, Language.DANISH)}
1417
<Paper elevation={1} sx={{padding: '5px', margin: '5px'}}>
1518
<Typography>{props.skillEntity.name}</Typography>
1619
<Rating value={props.skillEntity.level} readOnly/>
@@ -19,11 +22,11 @@ export function Skill(props: SkillProps): JSX.Element {
1922

2023
)
2124

22-
function insertNewPageInPrint(skillName: string): ReactNode {
23-
if (props.skillEntity.name !== skillName) {
24-
return (<></>)
25-
} else {
25+
function insertNewPageInPrint(skillName: SkillName, language: Language): ReactNode {
26+
if (props.skillEntity.name === skillName && localizationService.getCurrentLanguage() === language) {
2627
return (<PageBreak/>)
27-
}
28+
}
29+
30+
return (<></>)
2831
}
2932
}

src/shared/entities/skill-entity.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,21 @@ export enum SkillLevel {
88
Expert = 5
99
}
1010

11+
export enum SkillName {
12+
C_SHARP = 'C#',
13+
TYPESCRIPT = 'Typescript',
14+
SCRUM = 'Scrum',
15+
GIT = 'Git',
16+
ENTITY_FRAMEWORK_CORE = 'Entity Framework Core',
17+
C_PLUS_PLUS = 'C++',
18+
JAVA = 'Java',
19+
PYTHON = 'Python',
20+
SQL = 'SQL',
21+
ANGULAR = 'Angular',
22+
XAMARIN_FORMS = 'Xamarin Forms'
23+
}
24+
1125
export interface SkillEntity extends Importance {
1226
level: SkillLevel
13-
name: string
27+
name: SkillName
1428
}

src/shared/services/entity-generation-service.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { GeneralInformationEntity } from "../entities/general-information-entity
33
import { ComponentEmploymentLocalizationKeys, EntityEmploymentLocalizationKeys } from "../localization/employment-localization"
44
import { LocalizationService } from "./localization-service"
55
import { EntityGeneralInformationLocalizationKeys } from '../localization/general-information-localization';
6-
import { SkillEntity, SkillLevel } from "../entities/skill-entity";
6+
import { SkillEntity, SkillLevel, SkillName } from "../entities/skill-entity";
77
import { LinkEntity } from "../entities/link-entity";
88
import { EntityLinksLocalizationKeys } from "../localization/links-localization";
99
import { ReferenceEntity } from "../entities/reference-entity";
@@ -90,57 +90,57 @@ export class EntityGenerationService {
9090
public getSkillsEntities(): SkillEntity[] {
9191
const entities: SkillEntity[] = [
9292
{
93-
name: 'C#',
93+
name: SkillName.C_SHARP,
9494
level: SkillLevel.Experienced,
9595
importance: 100
9696
},
9797
{
98-
name: 'Typescript',
98+
name: SkillName.TYPESCRIPT,
9999
level: SkillLevel.Skillful,
100100
importance: 90
101101
},
102102
{
103-
name: 'Scrum',
103+
name: SkillName.SCRUM,
104104
level: SkillLevel.Skillful,
105105
importance: 80
106106
},
107107
{
108-
name: 'Git',
108+
name: SkillName.GIT,
109109
level: SkillLevel.Skillful,
110110
importance: 85
111111
},
112112
{
113-
name: 'Entity Framework Core',
113+
name: SkillName.ENTITY_FRAMEWORK_CORE,
114114
level: SkillLevel.Skillful,
115115
importance: 84
116116
},
117117
{
118-
name: 'C++',
118+
name: SkillName.C_PLUS_PLUS,
119119
level: SkillLevel.Novice,
120120
importance: 25
121121
},
122122
{
123-
name: 'Java',
123+
name: SkillName.JAVA,
124124
level: SkillLevel.Novice,
125125
importance: 20
126126
},
127127
{
128-
name: 'Python',
128+
name: SkillName.PYTHON,
129129
level: SkillLevel.Novice,
130130
importance: 19
131131
},
132132
{
133-
name: 'SQL',
133+
name: SkillName.SQL,
134134
level: SkillLevel.Beginner,
135135
importance: 30
136136
},
137137
{
138-
name: 'Angular',
138+
name: SkillName.ANGULAR,
139139
level: SkillLevel.Novice,
140140
importance: 24
141141
},
142142
{
143-
name: 'Xamarin Forms',
143+
name: SkillName.XAMARIN_FORMS,
144144
level: SkillLevel.Beginner,
145145
importance: 40
146146
},

src/shared/services/entity-localization/language-localization-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { ComponentLanguageLocalizationKeys, EntityLanguageLocalizationKeys } from "@/shared/localization/language-localization";
22
import { EntityLocalizationService } from "../value-objects/entity-localization-service";
3-
import { BaseEntityLocalizationSerive } from "./base-entity-localization-service";
3+
import { BaseEntityLocalizationSerive as BaseEntityLocalizationService } from "./base-entity-localization-service";
44
import { ReactNode } from "react";
55

6-
export class LanguageLocalizationService extends BaseEntityLocalizationSerive implements EntityLocalizationService<ComponentLanguageLocalizationKeys, EntityLanguageLocalizationKeys> {
6+
export class LanguageLocalizationService extends BaseEntityLocalizationService implements EntityLocalizationService<ComponentLanguageLocalizationKeys, EntityLanguageLocalizationKeys> {
77
public getEntityText(key: EntityLanguageLocalizationKeys): ReactNode {
88
return this.getCurrentLocalization().language.entityLocalization[key]
99
}

0 commit comments

Comments
 (0)