-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #484 from Sid-80/feat/480
feat: profile and dashboard
- Loading branch information
Showing
13 changed files
with
322 additions
and
164 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import FileModel from "@/models/file"; | ||
import { NextRequest } from "next/server"; | ||
import { NextResponse } from "next/server"; | ||
|
||
export const PUT = async (req: NextRequest, res: NextResponse) => { | ||
try { | ||
const {whiteboard, document, fileId} = await req.json(); | ||
console.log(document,whiteboard) | ||
|
||
await FileModel.updateOne({_id:fileId},{whiteboard, document}); | ||
|
||
return NextResponse.json({ status: "Updated" }, { status: 200 }); | ||
} catch (error) { | ||
console.error("Error in health endpoint:", error); | ||
return NextResponse.json({ message: 'Error occurred!' }, { status: 500 }); | ||
} | ||
}; |
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,34 @@ | ||
import { AuthMiddleware } from "@/Middleware/AuthMiddleware"; | ||
import FileModel from "@/models/file"; | ||
import { ApiUser } from "@/types/types"; | ||
import { NextRequest } from "next/server"; | ||
import { NextResponse } from "next/server"; | ||
|
||
export const PUT = async (req: NextRequest, res: NextResponse) => { | ||
try { | ||
const result = await AuthMiddleware(req); | ||
// If middleware returns NextResponse.next(), proceed with API logic | ||
if (result instanceof NextResponse) { | ||
|
||
const {whiteboard, document, fileId} = await req.json(); | ||
console.log(whiteboard,document) | ||
|
||
|
||
if(!whiteboard || !document || !fileId){ | ||
return NextResponse.json(`Access Denied!!`, {status:404}); | ||
} | ||
|
||
const user: ApiUser = JSON.parse(req.headers.get("user") || "{}"); | ||
|
||
await FileModel.updateOne({_id:fileId},{whiteboard, document}); | ||
|
||
return NextResponse.json({ status: "Updated" }, { status: 200 }); | ||
} else { | ||
// Handle any errors from the middleware | ||
return result; | ||
} | ||
} catch (error) { | ||
console.error("Error in health endpoint:", error); | ||
return NextResponse.json({ message: 'Error occurred!' }, { status: 500 }); | ||
} | ||
}; |
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,32 @@ | ||
import { AuthMiddleware } from "@/Middleware/AuthMiddleware"; | ||
import UserModel from "@/models/user"; | ||
import { ApiUser } from "@/types/types"; | ||
import { NextRequest } from "next/server"; | ||
import { NextResponse } from "next/server"; | ||
|
||
export const PUT = async (req: NextRequest, res: NextResponse) => { | ||
try { | ||
const result = await AuthMiddleware(req); | ||
// If middleware returns NextResponse.next(), proceed with API logic | ||
if (result.status==200) { | ||
|
||
const {firstName, lastName} = await req.json(); | ||
|
||
if(!firstName || !lastName ){ | ||
return NextResponse.json(`Access Denied!!`, {status:404}); | ||
} | ||
|
||
const user: ApiUser = JSON.parse(req.headers.get("user") || "{}"); | ||
|
||
await UserModel.updateOne({_id:user._id},{firstName, lastName}); | ||
|
||
return NextResponse.json({ status: "Updated" }, { status: 200 }); | ||
} else { | ||
// Handle any errors from the middleware | ||
return result; | ||
} | ||
} catch (error) { | ||
console.error("Error in health endpoint:", error); | ||
return NextResponse.json({ message: 'Error occurred!' }, { status: 500 }); | ||
} | ||
}; |
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
Oops, something went wrong.