upd
This commit is contained in:
+4
-3
@@ -1,3 +1,4 @@
|
||||
# VITE_SERVER_URL=http://localhost:3001
|
||||
# VITE_SERVER_URL=http://192.168.1.170:3001
|
||||
VITE_SERVER_URL=https://crm.stream.graff.tech/api
|
||||
# VITE_API_URL=http://localhost:3001
|
||||
# VITE_API_URL=http://192.168.1.170:3001
|
||||
VITE_API_URL=https://crm.stream.graff.tech/api
|
||||
VITE_STREAM_URL=https://stream.graff.tech
|
||||
|
||||
@@ -104,7 +104,10 @@ function Card({
|
||||
|
||||
<div className="flex gap-2">
|
||||
{manager && (
|
||||
<Link to={`http://localhost:5001/scheduled/${scheduledSessionId}`} target="_blank">
|
||||
<Link
|
||||
to={`${import.meta.env.VITE_STREAM_URL}/scheduled/${scheduledSessionId}`}
|
||||
target="_blank"
|
||||
>
|
||||
<Button>Начать</Button>
|
||||
</Link>
|
||||
)}
|
||||
@@ -119,7 +122,7 @@ function Card({
|
||||
</div>
|
||||
|
||||
<div className="absolute bottom-[2px] left-[272px] z-10">
|
||||
{availableManagers?.length && (
|
||||
{availableManagers && availableManagers.length > 0 && (
|
||||
<SelectUser
|
||||
shown={isShow}
|
||||
selectedManagerId={manager?.id}
|
||||
|
||||
@@ -24,7 +24,7 @@ function LoginPage() {
|
||||
setisLoading(true);
|
||||
|
||||
const result: any = await ky
|
||||
.post(import.meta.env.VITE_SERVER_URL + "/login", {
|
||||
.post(import.meta.env.VITE_API_URL + "/login", {
|
||||
json: {
|
||||
username,
|
||||
password,
|
||||
|
||||
@@ -2,7 +2,7 @@ import ky from "ky";
|
||||
import useAuthStore from "../stores/useAuthStore";
|
||||
|
||||
const api = ky.extend({
|
||||
prefixUrl: `${import.meta.env.VITE_SERVER_URL}`,
|
||||
prefixUrl: `${import.meta.env.VITE_API_URL}`,
|
||||
hooks: {
|
||||
beforeRequest: [
|
||||
(request) => {
|
||||
|
||||
@@ -9,7 +9,7 @@ export default ({ mode }) => {
|
||||
server: {
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: process.env.VITE_SERVER_URL,
|
||||
target: process.env.VITE_API_URL,
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/api/, ""),
|
||||
},
|
||||
|
||||
@@ -36,11 +36,8 @@ const scheduledSessionSchema = new Schema(
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
adminInviteKey: {
|
||||
type: String,
|
||||
},
|
||||
userInviteKey: {
|
||||
type: String,
|
||||
activeSessionId: {
|
||||
type: Schema.Types.ObjectId,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -183,33 +183,37 @@ companiesRouter.get(
|
||||
req.params.scheduledSessionId
|
||||
);
|
||||
|
||||
const scheduledSessionUserId = scheduledSession?.userId;
|
||||
if (!scheduledSession) {
|
||||
res.json({ error: "Scheduled session not found" });
|
||||
return;
|
||||
}
|
||||
|
||||
const scheduledSessionsAtSameTime = await ScheduledSession.find({
|
||||
companyId: req.params.id,
|
||||
const buildUsers = await BuildUser.find({ buildId: req.params.buildId });
|
||||
let buildUserIds = buildUsers.map((buildUser) =>
|
||||
buildUser.userId.toString()
|
||||
);
|
||||
|
||||
const scheduledSessionsAtTime = await ScheduledSession.find({
|
||||
buildId: req.params.buildId,
|
||||
startAt: req.query.startAt,
|
||||
});
|
||||
|
||||
const { users }: any = await Company.findById(req.params.id).populate(
|
||||
"users"
|
||||
);
|
||||
const scheduledSessionAtTimeUserIds: any[] = [];
|
||||
|
||||
const companyUserIds: any[] = users.map((user: any) => user.id);
|
||||
const sessionsUserIds: any[] = [];
|
||||
|
||||
for (const sessionAtSameTime of scheduledSessionsAtSameTime) {
|
||||
if (sessionAtSameTime.userId) {
|
||||
sessionsUserIds.push(sessionAtSameTime.userId.toString());
|
||||
for (const scheduledSessionAtTime of scheduledSessionsAtTime) {
|
||||
if (scheduledSessionAtTime.userId) {
|
||||
scheduledSessionAtTimeUserIds.push(
|
||||
scheduledSessionAtTime.userId.toString()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const filteredUserIds = companyUserIds.filter(
|
||||
(userId: any) => !sessionsUserIds.includes(userId)
|
||||
const filteredUserIds: any[] = buildUserIds.filter(
|
||||
(buildUserId) => !scheduledSessionAtTimeUserIds.includes(buildUserId)
|
||||
);
|
||||
|
||||
if (scheduledSessionUserId) {
|
||||
filteredUserIds.push(scheduledSessionUserId.toString());
|
||||
if (scheduledSession.userId) {
|
||||
filteredUserIds.push(scheduledSession.userId);
|
||||
}
|
||||
|
||||
res.json(filteredUserIds);
|
||||
|
||||
@@ -29,7 +29,9 @@ router.post("/", async (req, res) => {
|
||||
expiresIn: "365d",
|
||||
});
|
||||
|
||||
await Token.create({ userId: user.id, accessToken });
|
||||
const userId = user.id;
|
||||
|
||||
await Token.create({ userId, accessToken });
|
||||
|
||||
res.json({ accessToken, user });
|
||||
});
|
||||
|
||||
@@ -32,7 +32,7 @@ router.post("/", async (req, res) => {
|
||||
|
||||
await Token.create({ userId, accessToken });
|
||||
|
||||
res.json({ accessToken });
|
||||
res.json({ accessToken, user });
|
||||
});
|
||||
|
||||
const registerRouter = router;
|
||||
|
||||
@@ -3,10 +3,18 @@ import ScheduledSession from "../models/ScheduledSession.js";
|
||||
import Build from "../models/Build.js";
|
||||
import Schedule from "../models/Schedule.js";
|
||||
import { addMinutes, endOfDay, parseISO, startOfDay } from "date-fns";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
const scheduledSessionsRouter = Router();
|
||||
|
||||
scheduledSessionsRouter.get("/", async (_req, res) => {
|
||||
const scheduledSessions = await ScheduledSession.find({
|
||||
startAt: { $gte: startOfDay(new Date()) },
|
||||
endAt: { $lte: endOfDay(new Date()) },
|
||||
});
|
||||
|
||||
res.json(scheduledSessions);
|
||||
});
|
||||
|
||||
scheduledSessionsRouter.get("/:id", async (req, res) => {
|
||||
const scheduledSession = await ScheduledSession.findById(req.params.id);
|
||||
|
||||
@@ -114,11 +122,19 @@ scheduledSessionsRouter.post("/", async (req, res) => {
|
||||
clientName: client.name,
|
||||
clientEmail: client.email,
|
||||
clientPhone: client.phone,
|
||||
adminInviteKey: uuidv4(),
|
||||
userInviteKey: uuidv4(),
|
||||
});
|
||||
|
||||
res.json({ ok: 1, scheduleSession });
|
||||
});
|
||||
|
||||
scheduledSessionsRouter.put("/:id", async (req, res) => {
|
||||
const scheduledSession = await ScheduledSession.findByIdAndUpdate(
|
||||
req.params.id,
|
||||
req.body,
|
||||
{ new: true, upsert: true }
|
||||
);
|
||||
|
||||
res.json(scheduledSession);
|
||||
});
|
||||
|
||||
export default scheduledSessionsRouter;
|
||||
|
||||
Reference in New Issue
Block a user