diff --git a/client/src/components/Menu.tsx b/client/src/components/Menu.tsx
index 78bf571..80c5ef5 100644
--- a/client/src/components/Menu.tsx
+++ b/client/src/components/Menu.tsx
@@ -73,7 +73,6 @@ function Menu() {
diff --git a/client/src/components/Schedule.tsx b/client/src/components/Schedule.tsx
index a048a28..8a8e15f 100644
--- a/client/src/components/Schedule.tsx
+++ b/client/src/components/Schedule.tsx
@@ -2,7 +2,15 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { useEffect, useState } from "react";
import Timeline from "./Timeline";
-import { format, getDate, setDate, setHours, startOfDay } from "date-fns";
+import {
+ format,
+ getDate,
+ getMonth,
+ setDate,
+ setHours,
+ setMonth,
+ startOfDay,
+} from "date-fns";
// import useEventStore from "../stores/useEventStore";
import Button from "./Button";
import CloseIcon from "./icons/CloseIcon";
@@ -40,7 +48,12 @@ function Schedule({ selectedDay, slots, events }: Props) {
}
function handleChangeStartAt(startAt: Date) {
- setStartAt(setDate(startAt, getDate(selectedDay)));
+ let newStartAt = setMonth(startAt, getMonth(selectedDay));
+ newStartAt = setDate(newStartAt, getDate(selectedDay));
+
+ // console.log("newStartAt", newStartAt);
+
+ setStartAt(newStartAt);
setDateForInstantStart(undefined);
}
diff --git a/client/src/components/Select3.tsx b/client/src/components/Select3.tsx
index 2ab6e07..3911dad 100644
--- a/client/src/components/Select3.tsx
+++ b/client/src/components/Select3.tsx
@@ -5,12 +5,13 @@ import { useClickAway } from "@uidotdev/usehooks";
import CheckIcon from "./icons/CheckIcon";
interface Props {
+ required?: boolean;
defaultOption?: string;
options: string[];
onSelect: (option: string) => void;
}
-function Select3({ defaultOption, options, onSelect }: Props) {
+function Select3({ required, defaultOption, options, onSelect }: Props) {
const [showOptions, setShowOptions] = useState
(false);
const [selectedOption, setSelectedOption] = useState();
@@ -37,9 +38,10 @@ function Select3({ defaultOption, options, onSelect }: Props) {
onClick={() => setShowOptions((prev) => !prev)}
>
diff --git a/client/src/components/modals/AddManagerModal.tsx b/client/src/components/modals/AddManagerModal.tsx
new file mode 100644
index 0000000..36aa933
--- /dev/null
+++ b/client/src/components/modals/AddManagerModal.tsx
@@ -0,0 +1,118 @@
+/* eslint-disable @typescript-eslint/no-explicit-any */
+import { FormEvent, useState } from "react";
+import useModalStore from "../../stores/useModalStore";
+import Button from "../Button";
+import CloseIcon from "../icons/CloseIcon";
+import ModalTabButton from "../ModalTabButton";
+import Label from "../Label";
+import Input from "../Input";
+import Select3 from "../Select3";
+import IError from "../../types/IError";
+import api from "../../utils/api";
+import toast from "react-hot-toast";
+import useAuthStore from "../../stores/useAuthStore";
+
+function AddManagerModal() {
+ const { setModal } = useModalStore();
+ const { user } = useAuthStore();
+ const [username, setUsername] = useState
("");
+ const [name, setName] = useState("");
+ const [role, setRole] = useState("");
+ const [loading, setLoading] = useState(false);
+
+ async function handleSubmitAddManager(e: FormEvent) {
+ e.preventDefault();
+
+ setLoading(true);
+ await addManager();
+ setLoading(false);
+ }
+
+ async function addManager() {
+ try {
+ const result: any | IError = await api
+ .post("addManager", {
+ json: {
+ companyId: user?.companyId,
+ username,
+ name,
+ role:
+ (role === "Менеджер" && "manager") ||
+ (role === "Администратор" && "admin"),
+ },
+ })
+ .json();
+
+ if ("error" in result) {
+ toast.error(result.error);
+ return;
+ }
+
+ setModal(null);
+ toast.success("Пользователь успешно добавлен");
+
+ setTimeout(() => {
+ window.location.reload();
+ }, 2000);
+ } catch (error) {
+ toast.error((error as Error).message);
+ }
+ }
+
+ return (
+
+
+ Добавить сотрудника
+ }
+ onlyIcon
+ onClick={() => setModal(null)}
+ />
+
+
+
+ );
+}
+
+export default AddManagerModal;
diff --git a/client/src/components/modals/CompanyModal.tsx b/client/src/components/modals/CompanyModal.tsx
index e0608fa..c56303f 100644
--- a/client/src/components/modals/CompanyModal.tsx
+++ b/client/src/components/modals/CompanyModal.tsx
@@ -7,6 +7,7 @@ import useAuthStore from "../../stores/useAuthStore";
import MoreIcon from "../icons/MoreIcon";
import useStore from "../../stores/useStore";
import ModalTabButton from "../ModalTabButton";
+import AddManagerModal from "./AddManagerModal";
function CompanyModal() {
const [selectedTab, setSelectedTab] = useState<"company" | "employees">(
@@ -99,8 +100,7 @@ function CompanyModal() {
- {user?.name.split(" ")[0][0]}
- {user?.name.split(" ")[1][0]}
+ {manager?.name.split(" ")[0][0]}
@@ -129,11 +129,13 @@ function CompanyModal() {
))}
-
-
-
+ {user?.role === "admin" && (
+
+
+
+ )}
>
)}
diff --git a/client/src/components/modals/SettingsModal.tsx b/client/src/components/modals/SettingsModal.tsx
index 018cc45..c3792e8 100644
--- a/client/src/components/modals/SettingsModal.tsx
+++ b/client/src/components/modals/SettingsModal.tsx
@@ -64,7 +64,6 @@ function SettingsModal() {
{user?.name.split(" ")[0][0]}
- {user?.name.split(" ")[1][0]}
diff --git a/client/src/main.tsx b/client/src/main.tsx
index 910fe61..4fffc33 100644
--- a/client/src/main.tsx
+++ b/client/src/main.tsx
@@ -10,6 +10,8 @@ import RegistrationCompanyPage from "./pages/RegistrationCompanyPage.tsx";
import RegistrationManagerPage from "./pages/RegistrationManagerPage.tsx";
import AdminPage from "./pages/AdminPage.tsx";
import AdminCompanyPage from "./pages/AdminCompanyPage.tsx";
+import ResetPasswordPage from "./pages/ResetPasswordPage.tsx";
+import ResetPasswordConfirmPage from "./pages/ResetPasswordConfirmPage.tsx";
const router = createBrowserRouter([
{
@@ -23,6 +25,14 @@ const router = createBrowserRouter([
path: "login",
element: ,
},
+ {
+ path: "reset",
+ element: ,
+ },
+ {
+ path: "resetConfirm",
+ element: ,
+ },
{
path: "registration",
children: [
diff --git a/client/src/pages/DashboardPage.tsx b/client/src/pages/DashboardPage.tsx
index 81bf1a0..4cb4ff6 100644
--- a/client/src/pages/DashboardPage.tsx
+++ b/client/src/pages/DashboardPage.tsx
@@ -18,6 +18,7 @@ import IError from "../types/IError";
import Schedule from "../components/Schedule";
import IScheduledSession from "../types/IScheduledSession";
import toast, { Toaster } from "react-hot-toast";
+import Calendar from "../components/Calendar";
function DashboardPage() {
const { user } = useAuthStore();
@@ -228,7 +229,7 @@ function DashboardPage() {
- {/* */}
+
{/* */}
diff --git a/client/src/pages/LoginPage.tsx b/client/src/pages/LoginPage.tsx
index 4747226..389e455 100644
--- a/client/src/pages/LoginPage.tsx
+++ b/client/src/pages/LoginPage.tsx
@@ -70,11 +70,6 @@ function LoginPage() {
handleChange={(value) => setPassword(value)}
/>