Skip to content
This repository was archived by the owner on Jan 30, 2024. It is now read-only.

Commit 0a360bf

Browse files
allow users to remove avatars (#277)
1 parent ee3cf39 commit 0a360bf

File tree

1 file changed

+5
-3
lines changed
  • packages/squeak/src/pages/api/profiles

1 file changed

+5
-3
lines changed

packages/squeak/src/pages/api/profiles/[id].ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,14 @@ async function handlePatch(req: NextApiRequest, res: NextApiResponse) {
9898
let avatar =
9999
image && image?.cloud_name && image?.version && image?.publicId && image?.format
100100
? `https://res.cloudinary.com/${image.cloud_name}/v${image.version}/${image.publicId}.${image.format}`
101-
: await getAvatar(session.email)
101+
: image === null
102+
? await getAvatar(session.email)
103+
: undefined
102104
const data = {
103105
...(teamId ? { team_id: teamId === 'None' ? null : parseInt(teamId) } : {}),
104-
...(image ? { imageId: image?.id } : {}),
106+
...(image?.id ? { imageId: image?.id } : {}),
105107
...other,
106-
avatar,
108+
...(avatar || avatar === null ? { avatar } : {}),
107109
}
108110

109111
const profile = await prisma.profile.update({

0 commit comments

Comments
 (0)