Skip to content

Commit 7660b69

Browse files
Attempt pdf window resizing (#420)
* attempt pdf window resizing * vibe coded responsive sign form page * fix translation for form fields --------- Co-authored-by: Kaiyang Zheng <kaiyang.zheng@gmail.com>
1 parent c3b47c3 commit 7660b69

File tree

21 files changed

+374
-184
lines changed

21 files changed

+374
-184
lines changed

apps/web/src/components/FormPreview.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,20 @@ export const FormPreview = ({
7272
padding="24px"
7373
overflow="hidden"
7474
maxHeight="calc(100vh - 180px)"
75-
width="900px"
75+
minW="800px"
7676
>
7777
<FormEditor
7878
formTemplateName={formInstance.name}
79+
formTemplateDimensions={{
80+
width: formInstance.formTemplate.pageWidth,
81+
height: formInstance.formTemplate.pageHeight,
82+
}}
7983
pdfFile={pdfFile}
8084
disableEdit={true}
8185
fieldGroups={fieldGroups}
8286
formFields={[]}
8387
setFormFields={() => {}}
8488
setFieldGroups={() => {}}
85-
scale={1}
86-
documentWidth={800}
8789
showNav={false}
8890
/>
8991
</Flex>

apps/web/src/components/createForm/FormButtons.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { useSignFormInstance } from '@web/hooks/useSignFormInstance';
2121
import { Toaster, toaster } from '../ui/toaster';
2222
import { useState } from 'react';
2323
import { AxiosError } from 'axios';
24+
import { PDF_HEIGHT_PX, PDF_WIDTH_PX } from '../createFormTemplate/utils';
2425

2526
/**
2627
* Delete, Back, and Save & Continue buttons at the bottom of form template creation flow.
@@ -179,8 +180,8 @@ export const FormButtons = ({
179180
await createFormTemplateMutation
180181
.mutateAsync({
181182
body: {
182-
pageHeight: formDimensions.height,
183-
pageWidth: formDimensions.width,
183+
pageHeight: formDimensions.height ?? PDF_HEIGHT_PX,
184+
pageWidth: formDimensions.width ?? PDF_WIDTH_PX,
184185
name: formTemplateName ?? '',
185186
fieldGroups: fieldGroups,
186187
file: pdfFile,

apps/web/src/components/createForm/FormLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const FormLayout = ({
3737
review?: boolean;
3838
}) => {
3939
return (
40-
<Box height="100vh" marginTop="36px">
40+
<Box height="100vh" marginTop="36px" minW="1000px">
4141
<Flex position="absolute" margin="0px" zIndex={5000}>
4242
<SideCreateForm curStep={pageNumber} interactionType={type} />
4343
</Flex>

apps/web/src/components/createForm/NameAndDescriptionBox.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ export const NameAndDescriptionBox = ({
2323
setName,
2424
description,
2525
setDescription,
26+
formDimensions,
2627
}: {
2728
pdfFile: File | null;
2829
fieldGroups: FieldGroupBaseEntity[];
2930
name: string | null;
3031
setName: Dispatch<SetStateAction<string | null>>;
3132
description: string | null;
3233
setDescription: Dispatch<SetStateAction<string | null>>;
34+
formDimensions: { width: number; height: number };
3335
}) => {
3436
const textInputStyle = {
3537
padding: '8px 10px',
@@ -54,6 +56,7 @@ export const NameAndDescriptionBox = ({
5456
gap="24px"
5557
alignItems={'flex-start'}
5658
flex={1}
59+
maxW="500px"
5760
>
5861
<Flex gap="10px" flexDirection="column" width="100%">
5962
<Text>
@@ -99,17 +102,16 @@ export const NameAndDescriptionBox = ({
99102
>
100103
Preview Only
101104
</Text>
102-
<Box width="580px">
105+
<Box minW="500px">
103106
<FormEditor
104107
formTemplateName={name ?? ''}
108+
formTemplateDimensions={formDimensions}
105109
pdfFile={pdfFile}
106110
disableEdit
107111
fieldGroups={formEditorTranslateFieldGroups(fieldGroups)}
108112
formFields={formEditorTranslateFormFields(fieldGroups)}
109113
setFormFields={() => {}}
110114
setFieldGroups={() => {}}
111-
scale={0.6875}
112-
documentWidth={550}
113115
showNav={false}
114116
/>
115117
</Box>

apps/web/src/components/createFormInstance/AssignGroupsBox.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
formEditorTranslateFormFields,
1515
} from '@web/utils/formInstanceUtils';
1616
import { groupColors } from '@web/utils/formTemplateUtils';
17+
import Error from '../Error';
1718

1819
/**
1920
* The contents of the white box for assigning groups.
@@ -43,7 +44,8 @@ export const AssignGroupsBox = ({
4344
borderColor: 'transparent',
4445
};
4546

46-
const { assignedGroupData, setAssignedGroupData } = useCreateFormInstance();
47+
const { assignedGroupData, setAssignedGroupData, formTemplate } =
48+
useCreateFormInstance();
4749
const { data: positions } = useQuery(positionsControllerFindAllOptions());
4850
const { data: employees } = useQuery(employeesControllerFindAllOptions());
4951
const { data: departments } = useQuery(
@@ -54,6 +56,10 @@ export const AssignGroupsBox = ({
5456
}),
5557
);
5658

59+
if (!formTemplate) {
60+
return <Error></Error>;
61+
}
62+
5763
return (
5864
<Flex
5965
flexDirection={'row'}
@@ -113,7 +119,7 @@ export const AssignGroupsBox = ({
113119
>
114120
Preview Only
115121
</Text>
116-
<Box width="500px">
122+
<Box minW="500px">
117123
<FormEditor
118124
formTemplateName={name ?? ''}
119125
pdfFile={pdfFile}
@@ -122,9 +128,11 @@ export const AssignGroupsBox = ({
122128
formFields={formEditorTranslateFormFields(fieldGroups)}
123129
setFormFields={() => {}}
124130
setFieldGroups={() => {}}
125-
scale={0.625}
126-
documentWidth={500}
127131
showNav={false}
132+
formTemplateDimensions={{
133+
width: formTemplate?.pageWidth,
134+
height: formTemplate?.pageHeight,
135+
}}
128136
/>
129137
</Box>
130138
</Flex>

apps/web/src/components/createFormInstance/ReviewBox.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
formEditorTranslateFormFields,
88
} from '@web/utils/formInstanceUtils';
99
import { groupColors } from '@web/utils/formTemplateUtils';
10+
import Error from '../Error';
1011

1112
export const ReviewBox = ({
1213
pdfFile,
@@ -28,7 +29,7 @@ export const ReviewBox = ({
2829
borderColor: 'transparent',
2930
};
3031

31-
const { assignedGroupData } = useCreateFormInstance();
32+
const { assignedGroupData, formTemplate } = useCreateFormInstance();
3233

3334
const GroupItem = ({ color, border }: { color: string; border: string }) => {
3435
return (
@@ -43,6 +44,10 @@ export const ReviewBox = ({
4344
);
4445
};
4546

47+
if (!formTemplate) {
48+
return <Error></Error>;
49+
}
50+
4651
return (
4752
<Flex
4853
flexDirection={'row'}
@@ -95,7 +100,7 @@ export const ReviewBox = ({
95100
>
96101
Preview Only
97102
</Text>
98-
<Box width="500px">
103+
<Box minW="500px">
99104
<FormEditor
100105
formTemplateName={name ?? ''}
101106
pdfFile={pdfFile}
@@ -104,9 +109,11 @@ export const ReviewBox = ({
104109
formFields={formEditorTranslateFormFields(fieldGroups)}
105110
setFormFields={() => {}}
106111
setFieldGroups={() => {}}
107-
scale={0.625}
108-
documentWidth={500}
109112
showNav={false}
113+
formTemplateDimensions={{
114+
width: formTemplate?.pageWidth,
115+
height: formTemplate?.pageHeight,
116+
}}
110117
/>
111118
</Box>
112119
</Flex>

apps/web/src/components/createFormTemplate/ReviewBox.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const ReviewBox = ({
3131
borderColor: 'transparent',
3232
};
3333

34-
const { formFields } = useCreateFormTemplate();
34+
const { formFields, formDimensions } = useCreateFormTemplate();
3535

3636
const GroupItem = ({
3737
num,
@@ -55,6 +55,10 @@ export const ReviewBox = ({
5555
);
5656
};
5757

58+
if (!formDimensions || !formFields) {
59+
return <></>;
60+
}
61+
5862
return (
5963
<Flex
6064
flexDirection={'row'}
@@ -112,17 +116,16 @@ export const ReviewBox = ({
112116
>
113117
Preview Only
114118
</Text>
115-
<Box width="500px">
119+
<Box minW="500px">
116120
<FormEditor
117121
formTemplateName={name}
122+
formTemplateDimensions={formDimensions}
118123
pdfFile={pdfFile}
119124
disableEdit
120125
fieldGroups={fieldGroups}
121126
formFields={formFields}
122127
setFormFields={() => {}}
123128
setFieldGroups={() => {}}
124-
scale={0.625}
125-
documentWidth={500}
126129
showNav={false}
127130
/>
128131
</Box>

0 commit comments

Comments
 (0)