2025-01-30 12:44:04 +05:30
|
|
|
import { Request, Response } from "express";
|
2025-03-28 12:45:59 +05:30
|
|
|
import userModel from "../../../shared/model/user-Model.ts";
|
2025-01-30 12:44:04 +05:30
|
|
|
|
2025-05-17 10:12:18 +05:30
|
|
|
export class Share {
|
|
|
|
|
static async shareUser(req: Request, res: Response) {
|
|
|
|
|
try {
|
|
|
|
|
const { email, isShare, organization } = req.body;
|
2025-01-30 12:44:04 +05:30
|
|
|
|
2025-05-17 10:12:18 +05:30
|
|
|
const findValue = await userModel(organization).findOneAndUpdate(
|
|
|
|
|
{ email: email },
|
|
|
|
|
{ isShare: isShare },
|
|
|
|
|
{ new: true }
|
|
|
|
|
);
|
2025-01-30 12:44:04 +05:30
|
|
|
|
2025-05-17 10:12:18 +05:30
|
|
|
res
|
|
|
|
|
.status(201)
|
|
|
|
|
.json({ message: "scene shared successfully", data: findValue });
|
|
|
|
|
if (!findValue) {
|
|
|
|
|
res.status(404).json({ message: "Not found" });
|
|
|
|
|
}
|
|
|
|
|
// Send response with the created document
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("Error creating Share:", error);
|
|
|
|
|
res.status(500).json({ message: "Failed to create Share" });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static async findshareUser(req: Request, res: Response) {
|
|
|
|
|
try {
|
|
|
|
|
const organization = req.query.organization as string;
|
|
|
|
|
|
|
|
|
|
const findValue = await userModel(organization)
|
|
|
|
|
.find({})
|
|
|
|
|
.select("isShare email userName -_id");
|
2025-01-30 12:44:04 +05:30
|
|
|
|
2025-05-17 10:12:18 +05:30
|
|
|
res.status(201).json({ message: "scene shared datas", data: findValue });
|
|
|
|
|
if (!findValue) {
|
|
|
|
|
res.status(404).json({ message: "Not found" });
|
|
|
|
|
}
|
|
|
|
|
// Send response with the created document
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("Error Share:", error);
|
|
|
|
|
res.status(500).json({ message: "Failed to Share datas " });
|
2025-01-30 12:44:04 +05:30
|
|
|
}
|
2025-05-17 10:12:18 +05:30
|
|
|
}
|
2025-01-30 12:44:04 +05:30
|
|
|
}
|