-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'subhadeeproy3902:main' into feature
- Loading branch information
Showing
22 changed files
with
699 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { api } from "../../../../../convex/_generated/api"; | ||
import { ConvexHttpClient } from "convex/browser"; | ||
|
||
export const PUT = async(req: Request) => { | ||
try { | ||
const { teamId, email, fileId } = await req.json(); | ||
|
||
console.log(teamId,email,fileId) | ||
|
||
if (!teamId || !email || !fileId) return new Response('Parameters missing!!',{status: 401}); | ||
|
||
const client = new ConvexHttpClient(process.env.NEXT_PUBLIC_CONVEX_URL!); | ||
|
||
const teamInfo = await client.query(api.teams.getTeamById,{_id:teamId}); | ||
|
||
if (teamInfo.createdBy !== email) return new Response('Only owner can make changes!!',{status: 400}); | ||
|
||
|
||
await client.mutation(api.files.changeToPrivate,{_id:fileId}); | ||
|
||
return new Response('Changed to Private!!',{status: 200}); | ||
} catch (err) { | ||
console.log(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { api } from "../../../../../convex/_generated/api"; | ||
import { ConvexHttpClient } from "convex/browser"; | ||
|
||
export const PUT = async(req: Request) => { | ||
try { | ||
const { teamId, email, fileId } = await req.json(); | ||
|
||
if (!teamId || !email || !fileId) return new Response('Parameters missing!!',{status: 401}); | ||
|
||
const client = new ConvexHttpClient(process.env.NEXT_PUBLIC_CONVEX_URL!); | ||
|
||
const teamInfo = await client.query(api.teams.getTeamById,{_id:teamId}) | ||
|
||
if (teamInfo.createdBy !== email) { | ||
return new Response('Only owner can make changes!!',{status: 400}); | ||
} | ||
|
||
await client.mutation(api.files.changeToPublic,{_id:fileId}); | ||
|
||
return new Response('Changed to Public!!',{status: 200}); | ||
} catch (err) { | ||
console.log(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { api } from "../../../../../convex/_generated/api"; | ||
import { ConvexHttpClient } from "convex/browser"; | ||
|
||
export const PUT = async (req: Request) => { | ||
try { | ||
const { teamId, email, memberEmail, readBy, fileId } = await req.json(); | ||
|
||
if (!teamId || !memberEmail || !email || !fileId) | ||
return new Response("Parameters missing!!", { status: 401 }); | ||
|
||
const client = new ConvexHttpClient(process.env.NEXT_PUBLIC_CONVEX_URL!); | ||
|
||
const teamInfo = await client.query(api.teams.getTeamById, { _id: teamId }); | ||
|
||
if (!teamInfo.teamMembers.includes(memberEmail)) { | ||
return new Response("User is not member of the team", { status: 400 }); | ||
} | ||
|
||
if (teamInfo.createdBy !== email) { | ||
return new Response("Only owner can make changes!!", { status: 400 }); | ||
} | ||
|
||
const updatedReadBy = Array.isArray(readBy) | ||
? readBy.filter(writer => writer !== memberEmail) | ||
: []; | ||
|
||
await client.mutation(api.files.updateRead, { _id: fileId, readBy:updatedReadBy }); | ||
|
||
return new Response("Changed to Public!!", { status: 200 }); | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { api } from "../../../../../convex/_generated/api"; | ||
import { ConvexHttpClient } from "convex/browser"; | ||
|
||
export const PUT = async (req: Request) => { | ||
try { | ||
const { teamId, email, memberEmail, writtenBy, fileId } = await req.json(); | ||
|
||
if (!teamId || !memberEmail || !email || !fileId) | ||
return new Response("Parameters missing!!", { status: 401 }); | ||
|
||
const client = new ConvexHttpClient(process.env.NEXT_PUBLIC_CONVEX_URL!); | ||
|
||
const teamInfo = await client.query(api.teams.getTeamById, { _id: teamId }); | ||
|
||
if (!teamInfo.teamMembers.includes(memberEmail)) { | ||
return new Response("User is not member of the team", { status: 400 }); | ||
} | ||
|
||
if (teamInfo.createdBy !== email) { | ||
return new Response("Only owner can make changes!!", { status: 400 }); | ||
} | ||
|
||
await client.mutation(api.files.updateWrite, { _id: fileId, writtenBy: [...writtenBy,memberEmail] }); | ||
|
||
return new Response("Changed to Public!!", { status: 200 }); | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { NextResponse } from "next/server"; | ||
import { api } from "../../../../../convex/_generated/api"; | ||
import { ConvexHttpClient } from "convex/browser"; | ||
|
||
export const GET = async () => { | ||
try { | ||
|
||
const client = new ConvexHttpClient(process.env.NEXT_PUBLIC_CONVEX_URL!); | ||
|
||
const teamInfo = await client.query(api.teams.getAllTeam); | ||
|
||
return NextResponse.json(teamInfo); | ||
} catch (err) { | ||
console.log(err) | ||
} | ||
}; |
Oops, something went wrong.