[front-2]: fix

This commit is contained in:
maxim 2024-11-26 16:11:52 +04:00
parent cd59459e43
commit eb686935d6
18 changed files with 25 additions and 12 deletions

View File

@ -6,7 +6,9 @@ import { WindmillData } from './types';
import { getWindmillDataRequestParams } from './utils';
export const getWindmillData = (formValues: Partial<FlorisFormValues>) => {
const { park } = formValues;
const params = getWindmillDataRequestParams(formValues);
const url = `${FLORIS_ENDPOINTS.getWindmillData}?${params}`;
const parkPath = park ? `/${park.id}/` : '';
const url = `${FLORIS_ENDPOINTS.getWindmillData}${parkPath}?${params}`;
return api.get<WindmillData>(url);
};

View File

@ -5,20 +5,25 @@ import { FLORIS_PLOTS } from './constants';
export const getWindmillDataRequestParams = (
formValues: Partial<FlorisFormValues>,
) => {
const layoutX = formValues.turbines
?.map((row) => `layout_x=${row.x}`)
.join('&');
const layoutY = formValues.turbines
?.map((row) => `layout_y=${row.y}`)
.join('&');
const yawAngle = formValues.turbines
?.map((row) => `yaw_angle=${row.angle}`)
.join('&');
let params = '';
if (formValues.turbines) {
const layoutX = formValues.turbines
?.map((row) => `layout_x=${row.x}`)
.join('&');
const layoutY = formValues.turbines
?.map((row) => `layout_y=${row.y}`)
.join('&');
const yawAngle = formValues.turbines
?.map((row) => `yaw_angle=${row.angle}`)
.join('&');
params += `${layoutX}&${layoutY}&${yawAngle}`;
}
const plots = Object.values(FLORIS_PLOTS)
.filter((_, i) => formValues.plots?.[i])
.map((p) => `plots=${p.name}`)
.join('&');
const dateStart = `date_start=${formValues.dateFrom?.substring(0, 10)}`;
const dateEnd = `date_end=${formValues.dateTo?.substring(0, 10)}`;
return `${layoutX}&${layoutY}&${yawAngle}&${plots}&${dateStart}&${dateEnd}`;
params += `&${plots}&${dateStart}&${dateEnd}`;
return params;
};

View File

@ -64,7 +64,13 @@ export function FlorisForm({
const handleManulEntryCheckboxChange = (
event: React.ChangeEvent<HTMLInputElement>,
) => {
setIsManualEntry(event.target.checked);
const { checked } = event.target;
setIsManualEntry(checked);
if (checked) {
reset({ ...getValues(), park: undefined });
} else {
reset({ ...getValues(), turbines: undefined });
}
};
return (

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.