-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- updated profile photo handling after uploadthing done
- Loading branch information
1 parent
73d372b
commit 889c373
Showing
3 changed files
with
62 additions
and
15 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,52 @@ | ||
import { authOptions } from "@/lib/auth"; | ||
import { prismadb } from "@/lib/prisma"; | ||
import { getServerSession } from "next-auth"; | ||
import { NextResponse } from "next/server"; | ||
|
||
export async function PUT(req: Request) { | ||
const session = await getServerSession(authOptions); | ||
|
||
if (!session) { | ||
return NextResponse.json( | ||
{ message: "Unauthorized" }, | ||
{ | ||
status: 401, | ||
} | ||
); | ||
} | ||
|
||
const body = await req.json(); | ||
|
||
if (!body.avatar) { | ||
return NextResponse.json( | ||
{ message: "No avatar provided" }, | ||
{ | ||
status: 400, | ||
} | ||
); | ||
} | ||
|
||
try { | ||
await prismadb.users.update({ | ||
where: { | ||
id: session.user.id, | ||
}, | ||
data: { | ||
avatar: body.avatar, | ||
}, | ||
}); | ||
console.log("Profile photo updated"); | ||
return NextResponse.json( | ||
{ message: "Profile photo updated" }, | ||
{ status: 200 } | ||
); | ||
} catch (e) { | ||
console.log(e); | ||
return NextResponse.json( | ||
{ message: "Error updating profile photo" }, | ||
{ | ||
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
889c373
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nextcrm-others – ./
nextcrm-others-git-main-e-osvc.vercel.app
nextcrm-others-e-osvc.vercel.app
others.nextcrm.io
889c373
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nextcrm-demo – ./
demo.nextcrm.io
nextcrm-demo-e-osvc.vercel.app
nextcrm-demo-git-main-e-osvc.vercel.app
889c373
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nextcrm-test – ./
nextcrm-test-git-main-e-osvc.vercel.app
nextcrm-test-e-osvc.vercel.app
test.nextcrm.io
889c373
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nextcrm-softbase – ./
nextcrm-softbase-e-osvc.vercel.app
softbase.nextcrm.io
nextcrm-softbase.vercel.app
nextcrm-softbase-git-main-e-osvc.vercel.app
889c373
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nextcrm-documex – ./
nextcrm-documex-e-osvc.vercel.app
documex.nextcrm.io
nextcrm-documex.vercel.app
nextcrm-documex-git-main-e-osvc.vercel.app
889c373
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nextcrm-sunstream – ./
nextcrm-sunstream-e-osvc.vercel.app
nextcrm-sunstream-git-main-e-osvc.vercel.app
sunstream.nextcrm.io
nextcrm-sunstream.vercel.app