Skip to content

Commit 4f227b3

Browse files
adaptive full
1 parent 4a0ad0c commit 4f227b3

File tree

17 files changed

+581
-154
lines changed

17 files changed

+581
-154
lines changed

client/src/components/Form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const Form: FC<Props> = ({ id, onDelete, num }) => {
5757
<>
5858
<span className='number_form'>
5959
#{num}
60-
<img onClick={() => onDelete(id)} id='delete_icon' width={36} src={deleteIcon} alt="Удалить участника" />
60+
<img onClick={() => onDelete(id)} className='delete_icon' width={36} src={deleteIcon} alt="Удалить участника" />
6161
</span>
6262
<FormProvider {...methods}>
6363
<form className='various'>

client/src/components/Nav.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const NavComponent: FC = () => {
1515
<NavLink id='logo' to={Links.MAIN_PAGE}><img src={logo} alt="logo" /></NavLink>
1616
<div id="a">
1717
<NavLink to={Links.MAIN_PAGE}>Главная</NavLink>
18-
<NavLink to={Links.REDACT}>{window_size.width > 436 ? 'Конструктор бюллетеней' : 'Конструктор'}</NavLink>
18+
<NavLink to={Links.REDACT}>{window_size.width > 458 ? 'Конструктор бюллетеней' : 'Конструктор'}</NavLink>
1919
</div>
2020
</nav>
2121
)

client/src/components/form_parts/CadastralNumber.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ useEffect(()=> {
6363
/>
6464
<span className='double_t'>:</span>
6565

66-
6766
<input
6867
defaultValue={ls_2}
6968
id='c_2'

client/src/components/form_parts/FIO.tsx

Lines changed: 103 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -4,118 +4,121 @@ import { useFormContext } from 'react-hook-form';
44

55
import ShareSize from "@components/form_parts/Share_size"
66

7-
const FIO:FC = () => {
7+
const FIO: FC = () => {
88
const { register, formState: { errors }, watch } = useFormContext<FractionAndFIO>();
99

1010
const isR = watch('isRepresentative')
1111
const [isRes, setIsRes] = useState<boolean>(false)
1212

1313
const fraction = watch('fraction')
1414
const [fractionState, setFractionState] = useState<'в доле' | 'га'>('в доле')
15-
16-
useEffect(()=> {
15+
16+
useEffect(() => {
1717
setIsRes((prev) => !prev)
1818
}, [isR])
19-
useEffect(()=> {
19+
useEffect(() => {
2020
setFractionState(fraction)
2121
}, [fraction])
22-
return (
23-
<>
24-
<div className='pole' id="fio">
25-
<div className='part'>
26-
<div className="line">
27-
<label htmlFor="fio_input">ФИО участника</label>
28-
<input
29-
30-
type="text"
31-
id="fio_input"
32-
placeholder='Иванов Иван Иванович'
33-
{...register('name', {
34-
required: "Это поле обязательное",
35-
maxLength: {
36-
value: 60,
37-
message: "Слишком длинное ФИО"
38-
},
39-
minLength: {
40-
value: 2,
41-
message: "Слишком короткое ФИО"
42-
}
43-
})}
44-
/>
45-
46-
{isRes && <label htmlFor="name_res">ФИО Представителя</label> }
47-
{ isRes && <input
48-
type="text"
49-
id="name_res"
50-
placeholder='Иванов Иван Иванович'
51-
{...register('name_representative', {
52-
maxLength: {
53-
value: 60,
54-
message: "Слишком длинное ФИО"
55-
},
56-
minLength: {
57-
value: 2,
58-
message: "Слишком короткое ФИО"
59-
}
60-
})}
61-
/>
62-
}
63-
</div>
64-
</div>
65-
{
66-
errors.name &&
67-
<div className="validate_errors">
68-
<p className="validate_error">{errors.name.message}</p>
69-
</div>
70-
}
71-
</div>
72-
<div className='pole' id="fraction">
73-
<div className='part'>
74-
<label>Доля в праве:</label>
75-
<label className='label-fraction'>
76-
<input
77-
type="radio"
78-
value="в доле"
79-
{...register("fraction")}
80-
defaultChecked
81-
/>
82-
дробь
83-
</label>
84-
85-
<label className='label-fraction'>
86-
<input
87-
type="radio"
88-
value="га"
89-
{...register("fraction")}
90-
/>
91-
га
92-
</label>
93-
94-
<label style={{marginLeft:"40px"}}>Представитель:</label>
95-
<label className='label-fraction'>
96-
<input
97-
defaultChecked
98-
type="radio"
99-
value="true"
100-
{...register('isRepresentative')}
101-
/>
102-
есть
103-
</label>
104-
105-
<label className='label-fraction'>
106-
<input
107-
type="radio"
108-
value="false"
109-
{...register('isRepresentative')}
110-
/>
111-
нет
112-
</label>
22+
return (
23+
<>
24+
<div className='pole' id="fio">
25+
<div className='part'>
26+
<div className="line">
27+
<div>
28+
<label htmlFor="fio_input">ФИО участника</label>
29+
<input
30+
type="text"
31+
id="fio_input"
32+
placeholder='Иванов Иван Иванович'
33+
{...register('name', {
34+
required: "Это поле обязательное",
35+
maxLength: {
36+
value: 60,
37+
message: "Слишком длинное ФИО"
38+
},
39+
minLength: {
40+
value: 2,
41+
message: "Слишком короткое ФИО"
42+
}
43+
})}
44+
/>
45+
</div>
46+
<div>
47+
{isRes && <label htmlFor="name_res">ФИО Представителя</label>}
48+
{isRes && <input
49+
type="text"
50+
id="name_res"
51+
placeholder='Иванов Иван Иванович'
52+
{...register('name_representative', {
53+
maxLength: {
54+
value: 60,
55+
message: "Слишком длинное ФИО"
56+
},
57+
minLength: {
58+
value: 2,
59+
message: "Слишком короткое ФИО"
60+
}
61+
})}
62+
/>
63+
}
64+
</div>
65+
</div>
66+
</div>
67+
{
68+
errors.name &&
69+
<div className="validate_errors">
70+
<p className="validate_error">{errors.name.message}</p>
71+
</div>
72+
}
73+
</div>
74+
<div className='pole' id="fraction">
75+
<div className='part'>
76+
<div>
77+
<label>Доля в праве:</label>
78+
<label className='label-fraction'>
79+
<input
80+
type="radio"
81+
value="в доле"
82+
{...register("fraction")}
83+
defaultChecked
84+
/>
85+
<span className="text_radio">дробь</span>
86+
</label>
87+
<label id='ga_input' className='label-fraction'>
88+
<input
89+
type="radio"
90+
value="га"
91+
{...register("fraction")}
92+
/>
93+
<span className='text_radio'>га</span>
94+
</label>
95+
</div>
96+
<div>
97+
<label style={{ marginLeft: "40px" }}>Представитель:</label>
98+
<label className='label-fraction'>
99+
<input
100+
defaultChecked
101+
type="radio"
102+
value="true"
103+
{...register('isRepresentative')}
104+
/>
105+
<span className='text_radio'>есть</span>
106+
</label>
107+
<label className='label-fraction'>
108+
<input
109+
type="radio"
110+
value="false"
111+
{...register('isRepresentative')}
112+
/>
113+
<span className='text_radio'>нет</span>
114+
</label>
115+
</div>
116+
</div>
117+
{errors.fraction && <p>{errors.fraction.message}</p>} {/* Вывод ошибок (если required) */}
113118
</div>
114-
{errors.fraction && <p>{errors.fraction.message}</p>} {/* Вывод ошибок (если required) */}
115-
</div>
116-
<ShareSize fraction={fractionState}/>
117-
</>
118-
)
119+
<ShareSize fraction={fractionState} />
120+
</>
121+
)
119122
}
120123

121124
export default FIO;

client/src/components/form_parts/NumberQuest.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ const NumberQuest:FC = () => {
1010
const ls = localStorage.getItem('number_quest') || ''
1111
return (
1212
<div id='number_quest'>
13-
<div className="part_row_inputs">
13+
<div className="part_row_inputs minus">
1414
<label className='number_quest_text' htmlFor="number_quest">Число вопросов повестки дня</label>
1515
<input
16-
id='number_quest'
16+
id='number_quest_input'
1717
placeholder='1'
1818
type="number"
1919
defaultValue={ls}

client/src/components/form_parts/Share_size.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@ const ShareSize: FC<Props> = ({ fraction }) => {
1616
formState: { errors },
1717
} = useFormContext<Share>();
1818

19-
// Получаем объект general_info из Redux.
2019
const general_info = useSelector((state: RootState) => state.general_info.general_info);
2120

22-
// Вычисляем значение прямо в рендере.
23-
const isShareSize = general_info?.isShareWithCommon === true;
2421

2522
return (
2623
<div id="share">
@@ -40,7 +37,7 @@ const ShareSize: FC<Props> = ({ fraction }) => {
4037
/>
4138
{fraction === 'в доле' && (
4239
<>
43-
<span>/</span>
40+
<span id='slash'>/</span>
4441
<input
4542
type="number"
4643
className="share_size"
@@ -61,7 +58,7 @@ const ShareSize: FC<Props> = ({ fraction }) => {
6158
<input
6259
className="share_size"
6360
type="text"
64-
placeholder="1"
61+
placeholder="288"
6562
{...register('share_size_with_common_ch', {
6663
required: 'Это поле обязательное',
6764
min: {
@@ -74,7 +71,7 @@ const ShareSize: FC<Props> = ({ fraction }) => {
7471
<input
7572
className="share_size"
7673
type="text"
77-
placeholder="2"
74+
placeholder="512"
7875
{...register('share_size_with_common_z', {
7976
required: 'Это поле обязательное',
8077
min: {
@@ -96,4 +93,4 @@ const ShareSize: FC<Props> = ({ fraction }) => {
9693
);
9794
};
9895

99-
export default ShareSize;
96+
export default ShareSize;

client/src/components/form_parts/isShareWithCommon.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ const IsShareWithCommon:FC = () => {
99

1010

1111
return (
12-
<div className='line'>
12+
<div className='part_row_inputs minus'>
1313
<label>Нужна ли доля с общим знаменателем?</label>
1414
<label className='label-fraction'>
1515
<input
16-
16+
className='no'
1717
type="radio"
1818
value="true"
1919
{...register('isShareWithCommon')}
@@ -23,6 +23,7 @@ const IsShareWithCommon:FC = () => {
2323

2424
<label className='label-fraction'>
2525
<input
26+
className='no'
2627
type="radio"
2728
value="false"
2829
{...register('isShareWithCommon')}

client/src/pages/Redactor.page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ const RedactorPage: FC = () => {
106106
<IsShareWithCommon />
107107
<NumberQuest />
108108
<div className="line">
109-
<button onClick={ResetValues} disabled={isFormEmpty} >Сбросить все поля</button>
110-
<button disabled={!isValid} className='next' type="submit">Далее</button>
109+
<button className='general_butt' onClick={ResetValues} disabled={isFormEmpty} >Сбросить все поля</button>
110+
<button disabled={!isValid} className='next general_butt' type="submit">Далее</button>
111111
</div>
112112

113113
</form>

client/src/pages/Result.page.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FC, useEffect, useMemo, useCallback } from 'react';
1+
import { FC, useEffect, useMemo, useCallback, useState } from 'react';
22
import "../sass/result_page.scss"
33
import { Link } from 'react-router-dom';
44
import { Links } from "@enums/Links.enum"
@@ -18,6 +18,8 @@ const ResultPage: FC = () => {
1818
const various_data = useSelector((state: RootState) => state.various_info.various_info_to_server);
1919
const dispatch = useAppDispatch();
2020

21+
const [fortune, setFortune] = useState<number>(Math.floor(Math.random() * 999 + 1))
22+
2123
const various_info = useSelector((state: RootState) => state.various_info.various_info);
2224
const general_info = useSelector((state: RootState) => state.general_info.general_info);
2325

@@ -84,7 +86,7 @@ const ResultPage: FC = () => {
8486
req = await res.blob();
8587
return req
8688
} else {
87-
throw new Error("Unexpected content type");
89+
throw new Error("Ошибка, связанная с неожиданным типом данных");
8890
}
8991
}
9092
});
@@ -99,16 +101,17 @@ const ResultPage: FC = () => {
99101

100102

101103

102-
const handleDownload = useCallback(async () => {
104+
const handleDownload = useCallback(async ():Promise<void> => {
103105
try {
104106
const blob = await mutation.mutateAsync(req_body);
105107

106108
if(!blob) throw new Error('Ошибка')
107109

110+
setFortune(Math.floor(Math.random() * 999 + 1));
108111
const url = window.URL.createObjectURL(blob);
109112
const link = document.createElement('a');
110113
link.href = url;
111-
link.setAttribute('download', 'bullet.docx');
114+
link.setAttribute('download', `bullet-${fortune}.docx`);
112115
document.body.appendChild(link);
113116
link.style.display = 'none';
114117
link.click();
@@ -140,7 +143,7 @@ const ResultPage: FC = () => {
140143
<div id="finally">
141144
<div id="info_file">
142145
<img width={48} src={wordImg} alt="Word Document" />
143-
<span>bullet.docx</span>
146+
<span>bullet-{fortune}.docx</span>
144147
</div>
145148

146149
<button id='download' disabled={mutation.isError || mutation.isPending} onClick={handleDownload}>{mutation.isPending ? 'Генерация...' : 'Скачать'}</button>

0 commit comments

Comments
 (0)