New version API collaboration and tested for Project
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import projectModel from "../../V1Models/Project/project-model.ts";
|
||||
import { existingUser } from "../helpers/v1projecthelperFns.ts";
|
||||
interface IOrg {
|
||||
organization: string;
|
||||
role: string;
|
||||
@@ -21,6 +22,8 @@ export const TrashDatas = async (data: IOrg) => {
|
||||
// if (role === "User") {
|
||||
// filter.createdBy = userId;
|
||||
// }
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const TrashLists = await projectModel(organization).find(filter);
|
||||
if (!TrashLists) return { staus: "Trash is Empty" };
|
||||
const TrashDocs: any[] = [];
|
||||
@@ -56,6 +59,8 @@ export const TrashDatas = async (data: IOrg) => {
|
||||
export const RestoreTrashData = async (data: IRestore) => {
|
||||
try {
|
||||
const { projectId, organization, role, userId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
let filter = { isArchive: true, _id: projectId } as RoleFilter;
|
||||
// if (role === "User") {
|
||||
// filter.createdBy = userId;
|
||||
@@ -73,3 +78,24 @@ export const RestoreTrashData = async (data: IRestore) => {
|
||||
return { status: error };
|
||||
}
|
||||
};
|
||||
export const TrashDelete = async (data: IRestore) => {
|
||||
try {
|
||||
const { projectId, organization, userId } = data;
|
||||
const UserExists = await existingUser(userId, organization);
|
||||
if (!UserExists) return { status: "User not found" };
|
||||
const findProject = await projectModel(organization).findOne({
|
||||
_id: projectId,
|
||||
isArchive: true,
|
||||
});
|
||||
if (!findProject) return { status: "Project not found" };
|
||||
const DeleteTrashData = await projectModel(organization).findOneAndUpdate(
|
||||
{ _id: projectId, isArchive: true, isDeleted: false },
|
||||
{ isDeleted: true },
|
||||
{ new: true }
|
||||
);
|
||||
if (!DeleteTrashData) return { status: "Project Already Deleted" };
|
||||
return { status: "Trash Project Delete successfully" };
|
||||
} catch (error) {
|
||||
return { status: error };
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user