This commit is contained in:
2023-10-20 15:14:02 +05:00
parent 45e5b95dd9
commit 6f908a0da1
11 changed files with 125 additions and 10 deletions
+1 -1
View File
@@ -1 +1 @@
VITE_SERVER_URL=http://192.168.1.170:3000
VITE_SERVER_URL=http://192.168.1.170:3001
+1
View File
@@ -21,6 +21,7 @@
"zustand": "^4.4.1"
},
"devDependencies": {
"@types/node": "^20.8.7",
"@types/react": "^18.2.15",
"@types/react-datepicker": "^4.19.0",
"@types/react-dom": "^18.2.7",
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable react-hooks/exhaustive-deps */
/* eslint-disable no-irregular-whitespace */
import { ru } from "date-fns/locale";
@@ -13,24 +14,29 @@ import Input from "../Input";
import {
addMonths,
addWeeks,
areIntervalsOverlapping,
differenceInDays,
eachMinuteOfInterval,
endOfDay,
format,
parse,
parseISO,
startOfDay,
subDays,
} from "date-fns";
import api from "../../utils/api";
interface CreateScheduleProps {
companyId: string;
buildId: string;
schedules?: any[];
handleCreate: () => void;
}
function CreateSchedule({
companyId,
buildId,
schedules,
handleCreate,
}: CreateScheduleProps) {
const setModal = useModalStore((state) => state.setModal);
@@ -50,9 +56,12 @@ function CreateSchedule({
setStartDate(startOfDay(date));
setEndDate(
endOfDay(
scheduleDuration !== 3
? addWeeks(date, scheduleDuration)
: addMonths(date, 1)
subDays(
scheduleDuration !== 3
? addWeeks(date, scheduleDuration)
: addMonths(date, 1),
1
)
)
);
}, [date, scheduleDuration]);
@@ -102,6 +111,25 @@ function CreateSchedule({
}
async function handleClickCreateSchedule() {
if (!startDate || !endDate) return;
if (
schedules?.some((schedule) =>
areIntervalsOverlapping(
{ start: startDate, end: endDate },
{
start: parseISO(schedule.startDate),
end: parseISO(schedule.endDate),
}
)
)
) {
alert(
"Данные даты пересекаются с другим расписанием! Выберите другие даты."
);
return;
}
await createSchedule();
handleCreate();
setModal(null);
+1
View File
@@ -512,6 +512,7 @@ function DashboardPage() {
<CreateSchedule
companyId={company?.id}
buildId={selectedBuild?.id}
schedules={schedules}
handleCreate={getSchedules}
/>
)
+18 -5
View File
@@ -1,7 +1,20 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react-swc";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
export default ({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
const config = {
plugins: [react()],
server: {
proxy: {
"/api": {
target: process.env.VITE_SERVER_URL,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ""),
},
},
},
};
return defineConfig(config);
};
+12
View File
@@ -321,6 +321,13 @@
resolved "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz"
integrity sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==
"@types/node@^20.8.7":
version "20.8.7"
resolved "https://registry.npmjs.org/@types/node/-/node-20.8.7.tgz"
integrity sha512-21TKHHh3eUHIi2MloeptJWALuCu5H7HQTdTrWIFReA8ad+aggoX+lRes3ex7/FtpC+sVUpFMQ+QTfYr74mruiQ==
dependencies:
undici-types "~5.25.1"
"@types/prop-types@*":
version "15.7.5"
resolved "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz"
@@ -1717,6 +1724,11 @@ typescript@^5.0.2:
resolved "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz"
integrity sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==
undici-types@~5.25.1:
version "5.25.3"
resolved "https://registry.npmjs.org/undici-types/-/undici-types-5.25.3.tgz"
integrity sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==
update-browserslist-db@^1.0.11:
version "1.0.11"
resolved "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.11.tgz"