-
-
-
- 2020-23-21
-
-
- 14:32
-
-
-
-
-
- Cum
-
-
- №69
-
-
+ const [randomNumber, setRandomNumber] = useState(null);
+
+ useEffect(() => {
+ // Создаем WebSocket-соединение
+ const ws = new WebSocket('ws://localhost:8765/');
+
+ // Обработка сообщений от сервера
+ ws.onmessage = (event) => {
+ const newRandomNumber = event.data;
+ setRandomNumber(newRandomNumber);
+ };
+
+ // Закрытие соединения при размонтировании компонента
+ return () => {
+ ws.close();
+ };
+ }, []);
+ return (
+
+
+
+
+ 2020-23-21
+
+
+ 14:32
+
+
+
+
+
+ Cum
+
+
+ №69
+
+
+
+
+
+ {randomNumber}
+
-
-
- here camera
-
-
- );
+ );
}
export default Camera;
diff --git a/ui/src/lib/filters/filters.module.scss b/ui/src/lib/filters/filters.module.scss
index 1c38f2f..843b5a3 100644
--- a/ui/src/lib/filters/filters.module.scss
+++ b/ui/src/lib/filters/filters.module.scss
@@ -1,12 +1,18 @@
.container {
+ grid-area: 1 / 1 / 2 / 6;
display: flex;
flex-direction: row;
gap: 30px;
}
+
.button {
font-size: 14px;
border-radius: 20px;
padding: 5px 10px;
color: var(--white);
background-color: #94BF5E;
+
+ &:disabled {
+ background-color: #eee;
+ }
}
diff --git a/ui/src/lib/filters/filters.tsx b/ui/src/lib/filters/filters.tsx
index 2e54e82..ccd9b8d 100644
--- a/ui/src/lib/filters/filters.tsx
+++ b/ui/src/lib/filters/filters.tsx
@@ -1,64 +1,111 @@
-import cls from './filters.module.scss';
-import {ConfigProvider, DatePicker} from "antd";
+import React, {useEffect, useState} from "react";
+import dayjs from "dayjs";
+import customParseFormat from "dayjs/plugin/customParseFormat";
+import utc from "dayjs/plugin/utc";
import SwitchSelector from "react-switch-selector";
-import dayjs from 'dayjs';
-import customParseFormat from 'dayjs/plugin/customParseFormat';
-import {useState} from "react";
-
-/* eslint-disable-next-line */
+import {ConfigProvider, DatePicker} from "antd";
+import cls from "./filters.module.scss";
+import {useGetDateMutation} from "../../../../apps/crud/src/store/services/statisticsFilterApi";
+import {useAppDispatch} from "../../../../apps/crud/src/store";
+import {setData, setType} from "../../../../apps/crud/src/store/features/statisticsFilterSlice";
-enum timeFormatEnum {
- DATE = "date",
- PERIOD = "period"
+export enum timeFormatEnum {
+ DATE = "date",
+ PERIOD = "period",
}
export function Filters() {
- const [timeFormat, setTimeFormat] = useState
(timeFormatEnum.DATE)
- const options = [
- {
- label: "Дата",
- value: "date",
- selectedBackgroundColor: "#94BF5E"
- },
- {
- label: "Период",
- value: "period",
- selectedBackgroundColor: "#94BF5E"
- },
- ]
+ const [timeFormat, setTimeFormat] = useState(timeFormatEnum.DATE);
+ const [timeData, setTimeData] = useState();
+ const [mutation, {data}] = useGetDateMutation();
+ const dispatch = useAppDispatch();
+
+ const options = [
+ {
+ label: "Дата",
+ value: "date",
+ selectedBackgroundColor: "#94BF5E",
+ },
+ {
+ label: "Период",
+ value: "period",
+ selectedBackgroundColor: "#94BF5E",
+ },
+ ];
+
+ dayjs.extend(customParseFormat);
+ dayjs.extend(utc);
- const handleChange = (time: never, timeString: string) => {
- console.log(timeString)
- }
- const onChange = (newValue: timeFormatEnum) => {
- setTimeFormat(newValue)
- };
+ function convertToISO8601(timeString: string): string {
+ const parsedTime = dayjs(timeString, {format: "YYYY-MM-DD HH:mm:ss"});
+ const iso8601Time = parsedTime.utc().format("YYYY-MM-DDTHH:mm:ss.SSS[Z]");
+ return iso8601Time;
+ }
- return (
-
-
-
-
-
{
+ setTimeData(timeString);
+ };
+
+ const onChange = (newValue: timeFormatEnum) => {
+ setTimeFormat(newValue);
+ dispatch(setType())
+ };
+
+ async function handleData() {
+ if (timeFormat === timeFormatEnum.DATE) {
+ mutation({start_date: convertToISO8601(timeData)});
+ } else {
+ mutation({
+ start_date: convertToISO8601(timeData[0]),
+ end_date: convertToISO8601(timeData[1]),
+ });
}
- }}>
- {timeFormat === timeFormatEnum.PERIOD ?
- :
-
+ }
+
+ useEffect(() => {
+ if (data) {
+ dispatch(setData(data));
}
-
-
-
- );
+ }, [data]);
+
+ return (
+
+
+
+
+
+ {timeFormat === timeFormatEnum.PERIOD ? (
+
+ ) : (
+
+ )}
+
+
+
+ );
}
export default Filters;
diff --git a/ui/src/lib/sidebar-item/sidebar-item.module.scss b/ui/src/lib/sidebar-item/sidebar-item.module.scss
index 4153ee0..74a2598 100644
--- a/ui/src/lib/sidebar-item/sidebar-item.module.scss
+++ b/ui/src/lib/sidebar-item/sidebar-item.module.scss
@@ -1,59 +1,64 @@
.item {
- background: var(--white);
- border-radius: var(--border-medium);
- padding: 10px 20px;
- display: flex;
- gap: 0 8px;
- justify-content: space-between;
+ background: var(--white);
+ border-radius: var(--border-medium);
+ padding: 10px 20px;
+ display: flex;
+ gap: 0 8px;
+ justify-content: space-between;
}
.line {
- width: 1px;
- background-color: var(--black);
+ width: 1px;
+ background-color: var(--black);
}
.heading {
- display: flex;
- flex-direction: column;
- gap: 0 10px;
- justify-content: center;
- .text {
- text-align: end;
- color: var(--gray);
- font-size: 20px;
- font-style: normal;
- font-weight: 300;
- line-height: normal;
- }
+ display: flex;
+ flex-direction: column;
+ gap: 0 10px;
+ justify-content: center;
+ .text {
+ display: flex;
+ align-items: center;
+ color: var(--gray);
+ font-size: 20px;
+ font-style: normal;
+ font-weight: 300;
+ line-height: normal;
+ & svg {
+ margin-right: 5px;
+ }
+ }
- .percent {
- font-size: 54px;
- font-style: normal;
- font-weight: 300;
- line-height: normal;
- }
+ .percent {
+ font-size: 54px;
+ font-style: normal;
+ font-weight: 300;
+ line-height: normal;
+ }
}
.info {
- padding: 10px;
- display: flex;
- flex-direction: column;
- gap: 5px;
- & p {
- padding: 0;
- margin: 0;
- font-size: 36px;
- font-style: normal;
- font-weight: 300;
- line-height: normal;
- color: var(--black
- );
- }
+ padding: 10px;
+ display: flex;
+ flex-direction: column;
+ gap: 5px;
- & span {
- font-size: 20px;
- font-style: normal;
- font-weight: 300;
- line-height: normal;
- }
+ & p {
+ padding: 0;
+ margin: 0;
+ font-size: 36px;
+ font-style: normal;
+ font-weight: 300;
+ line-height: normal;
+ color: var(--black
+ );
+ }
+
+ & span {
+ font-size: 20px;
+ font-style: normal;
+ font-weight: 300;
+ line-height: normal;
+ }
}
diff --git a/ui/src/lib/sidebar-item/sidebar-item.tsx b/ui/src/lib/sidebar-item/sidebar-item.tsx
index 4390169..09c46c5 100644
--- a/ui/src/lib/sidebar-item/sidebar-item.tsx
+++ b/ui/src/lib/sidebar-item/sidebar-item.tsx
@@ -1,63 +1,65 @@
import styles from './sidebar-item.module.scss';
import Button from "../button/button";
+import {ImLeaf} from "react-icons/im"
/* eslint-disable-next-line */
export interface SidebarItemProps {
- name: string
- percent: number | string
- weight: number | string
- href: string
+ name: string
+ percent: number | string
+ weight: number | string
+ href: string
}
export function SidebarItem() {
- const obj: SidebarItemProps[] = [
- {
- name: "Дерево",
- href: "some",
- percent: "10%",
- weight: 200
- },
- {
- name: "Металл",
- href: "some",
- percent: "10%",
- weight: 200
- },
- {
- name: "Пластик",
- href: "some",
- percent: "10%",
- weight: 200
- },
- {
- name: "Стекло",
- href: "some",
- percent: "10%",
- weight: 200
- }
- ]
- return (
- <>
- {obj.map((item, i) => (
-
-
-
- {item.name}
-
-
- {item.percent}
-
-
-
-
-
{item.weight}
-
Тонн
-
-
-
- ))}
- >
- );
+ const obj: SidebarItemProps[] = [
+ {
+ name: "Дерево",
+ href: "some",
+ percent: "10%",
+ weight: 200
+ },
+ {
+ name: "Металл",
+ href: "some",
+ percent: "10%",
+ weight: 200
+ },
+ {
+ name: "Пластик",
+ href: "some",
+ percent: "10%",
+ weight: 200
+ },
+ {
+ name: "Стекло",
+ href: "some",
+ percent: "10%",
+ weight: 200
+ }
+ ]
+ return (
+ <>
+ {obj.map((item, i) => (
+
+
+
+
+ {item.name}
+
+
+ {item.percent}
+
+
+
+
+
{item.weight}
+
Тонн
+
+
+
+ ))}
+ >
+ );
}
export default SidebarItem;
diff --git a/ui/src/lib/sidebar/sidebar.module.scss b/ui/src/lib/sidebar/sidebar.module.scss
index 6048683..97a56d8 100644
--- a/ui/src/lib/sidebar/sidebar.module.scss
+++ b/ui/src/lib/sidebar/sidebar.module.scss
@@ -1,5 +1,5 @@
.container {
- flex: 0 0 20%;
+ flex: 0 0 25%;
display: flex;
flex-direction: column;
gap: 30px;