upd
This commit is contained in:
+2
-2
@@ -1,4 +1,4 @@
|
||||
# VITE_API_URL=http://localhost:3001
|
||||
VITE_API_URL=http://localhost:3001
|
||||
# VITE_API_URL=http://192.168.1.171:3001
|
||||
VITE_API_URL=https://crm.stream.graff.tech/api
|
||||
# VITE_API_URL=https://crm.stream.graff.tech/api
|
||||
VITE_STREAM_URL=https://stream.graff.tech
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import {
|
||||
addMonths,
|
||||
format,
|
||||
getDay,
|
||||
getDaysInMonth,
|
||||
getISODay,
|
||||
isSameDay,
|
||||
isToday,
|
||||
setDate,
|
||||
startOfDay,
|
||||
startOfMonth,
|
||||
subMonths,
|
||||
} from "date-fns";
|
||||
import { useState } from "react";
|
||||
@@ -22,7 +24,9 @@ import useStore from "../stores/useStore";
|
||||
function Calendar() {
|
||||
const { selectedDay, setSelectedDay } = useStore();
|
||||
const { isShowCalendar, setIsShowCalendar } = useSettingsStore();
|
||||
const [currentMonth, setCurrentMonth] = useState<Date>(new Date());
|
||||
const [currentMonth, setCurrentMonth] = useState<Date>(
|
||||
startOfMonth(startOfDay(new Date()))
|
||||
);
|
||||
|
||||
function selectPrevMonth() {
|
||||
setCurrentMonth(subMonths(currentMonth, 1));
|
||||
@@ -74,11 +78,11 @@ function Calendar() {
|
||||
))}
|
||||
</div>
|
||||
<div className="grid grid-cols-7 gap-2">
|
||||
{Array.from({ length: getISODay(currentMonth) - 1 }).map(
|
||||
(_, index) => (
|
||||
<div key={index} className="w-8 h-8"></div>
|
||||
)
|
||||
)}
|
||||
{Array.from({
|
||||
length: getDay(startOfDay(startOfMonth(currentMonth))) - 1,
|
||||
}).map((_, index) => (
|
||||
<div key={index} className="w-8 h-8"></div>
|
||||
))}
|
||||
{Array.from({ length: getDaysInMonth(currentMonth) }).map(
|
||||
(_, index) => (
|
||||
<button
|
||||
|
||||
@@ -9,7 +9,7 @@ import { Link } from "react-router-dom";
|
||||
import IUser from "../types/IUser";
|
||||
import useAuthStore from "../stores/useAuthStore";
|
||||
import EntryIcon from "./icons/EntryIcon";
|
||||
import { isAfter } from "date-fns";
|
||||
import { isAfter, subMinutes } from "date-fns";
|
||||
|
||||
interface CardProps {
|
||||
companyId: string;
|
||||
@@ -112,7 +112,10 @@ function Card({
|
||||
<div className="flex gap-2">
|
||||
{user?.role === "manager" &&
|
||||
(manager ? (
|
||||
isAfter(new Date(), new Date(scheduleSessionStartAt)) ? (
|
||||
isAfter(
|
||||
new Date(),
|
||||
subMinutes(new Date(scheduleSessionStartAt), 10)
|
||||
) ? (
|
||||
<Link
|
||||
to={`${
|
||||
import.meta.env.VITE_STREAM_URL
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
"express": "^4.18.2",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"mongoose": "^7.5.1",
|
||||
"nodemailer": "^6.9.14",
|
||||
"uuid": "^9.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -23,6 +24,7 @@
|
||||
"@types/express": "^4.17.17",
|
||||
"@types/jsonwebtoken": "^9.0.2",
|
||||
"@types/node": "^20.5.9",
|
||||
"@types/nodemailer": "^6.4.15",
|
||||
"@types/uuid": "^9.0.6",
|
||||
"nodemon": "^3.0.1",
|
||||
"ts-node": "^10.9.1",
|
||||
|
||||
@@ -5,7 +5,6 @@ import cors from "cors";
|
||||
import loginRouter from "./routes/login";
|
||||
import registrationRouter from "./routes/registration";
|
||||
import authMiddleware from "./middlewares/auth";
|
||||
import appRouter from "./routes/app";
|
||||
import companiesRouter from "./routes/companies";
|
||||
import usersRouter from "./routes/users";
|
||||
import buildsRouter from "./routes/builds";
|
||||
@@ -27,7 +26,6 @@ app.use("/actions", actionsRouter);
|
||||
app.use("/builds", buildsRouter);
|
||||
app.use("/scheduled_sessions", scheduledSessionsRoute);
|
||||
app.use("/schedules", schedulesRouter);
|
||||
app.use("/app", authMiddleware, appRouter);
|
||||
app.use("/companies", authMiddleware, companiesRouter);
|
||||
app.use("/users", authMiddleware, usersRouter);
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import { Router } from "express";
|
||||
import Company from "../models/Company";
|
||||
|
||||
const appRouter = Router();
|
||||
|
||||
appRouter.post("/", async (_req, res) => {
|
||||
await Company.find();
|
||||
|
||||
res.json({ route: "app" });
|
||||
});
|
||||
|
||||
export default appRouter;
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
parseISO,
|
||||
startOfDay,
|
||||
} from "date-fns";
|
||||
import { createTransport } from "nodemailer";
|
||||
|
||||
const router = Router();
|
||||
|
||||
@@ -79,7 +80,7 @@ router.post("/", async (req, res) => {
|
||||
if (!buildId || !startAt) {
|
||||
return res.json({
|
||||
status: "error",
|
||||
message: "Parameters `buildId`, `startAt` are required!", // Параметры `compamyId`, `buildId`, `startAt`, `client` обязательны!
|
||||
message: "Parameters `buildId`, `startAt` are required!", // Параметры `buildId`, `startAt` обязательны!
|
||||
});
|
||||
}
|
||||
|
||||
@@ -207,10 +208,43 @@ router.post("/", async (req, res) => {
|
||||
endAt: endAtISO,
|
||||
});
|
||||
|
||||
const url = `https://stream.graff.tech/scheduled/${scheduledSession.id}`;
|
||||
|
||||
// <-- Send an mail
|
||||
|
||||
if (client?.email) {
|
||||
// create reusable transporter object using the default SMTP transport
|
||||
let transporter = createTransport({
|
||||
host: "mail.netangels.ru",
|
||||
port: 587,
|
||||
secure: false, // true for 465, false for other ports
|
||||
auth: {
|
||||
user: "stream@graff.tech", // generated ethereal user
|
||||
pass: "zLUbt8Io7dh2F9KT", // generated ethereal password
|
||||
},
|
||||
});
|
||||
|
||||
// send mail with defined transport object
|
||||
try {
|
||||
await transporter.sendMail({
|
||||
from: "stream@graff.tech", // sender address
|
||||
to: client.email, // list of receivers
|
||||
subject: "Приглашение на демонстрацию - stream.graff.tech", // Subject line
|
||||
html: `<div>
|
||||
Ссылка для подключения к демонстрации: <a href="${url}" target="_blank">${url}</a>
|
||||
</div>`,
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("error", (error as Error).message);
|
||||
}
|
||||
}
|
||||
|
||||
// Send an mail -->
|
||||
|
||||
res.json({
|
||||
status: "success",
|
||||
scheduledSessionId: scheduledSession.id,
|
||||
url: `https://stream.graff.tech/scheduled/${scheduledSession.id}`,
|
||||
url,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -154,6 +154,13 @@
|
||||
dependencies:
|
||||
undici-types "~5.26.4"
|
||||
|
||||
"@types/nodemailer@^6.4.15":
|
||||
version "6.4.15"
|
||||
resolved "https://registry.yarnpkg.com/@types/nodemailer/-/nodemailer-6.4.15.tgz#494be695e11c438f7f5df738fb4ab740312a6ed2"
|
||||
integrity sha512-0EBJxawVNjPkng1zm2vopRctuWVCxk34JcIlRuXSf54habUWdz1FB7wHDqOqvDa8Mtpt0Q3LTXQkAs2LNyK5jQ==
|
||||
dependencies:
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/qs@*":
|
||||
version "6.9.11"
|
||||
resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.11.tgz#208d8a30bc507bd82e03ada29e4732ea46a6bbda"
|
||||
@@ -996,6 +1003,11 @@ node-fetch@^2.6.7:
|
||||
dependencies:
|
||||
whatwg-url "^5.0.0"
|
||||
|
||||
nodemailer@^6.9.14:
|
||||
version "6.9.14"
|
||||
resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-6.9.14.tgz#845fda981f9fd5ac264f4446af908a7c78027f75"
|
||||
integrity sha512-Dobp/ebDKBvz91sbtRKhcznLThrKxKt97GI2FAlAyy+fk19j73Uz3sBXolVtmcXjaorivqsbbbjDY+Jkt4/bQA==
|
||||
|
||||
nodemon@^3.0.1:
|
||||
version "3.0.3"
|
||||
resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-3.0.3.tgz#244a62d1c690eece3f6165c6cdb0db03ebd80b76"
|
||||
|
||||
Reference in New Issue
Block a user