Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Update onboard-partner.ts

Steven Teye914ee28b973
diff --git a/apps/web/lib/actions/partners/onboard-partner.ts b/apps/web/lib/actions/partners/onboard-partner.ts
index f9b0bc103d..ef374f7266 100644
--- a/apps/web/lib/actions/partners/onboard-partner.ts
+++ b/apps/web/lib/actions/partners/onboard-partner.ts
@@ -81,20 +81,37 @@ export const onboardPartnerAction = authUserActionClient
},
}),
- (!user.defaultPartnerId || !user.image) &&
+ // if the user doesn't have a default partner id, set the new partner id as the user's default partner id
+ user.defaultPartnerId &&
prisma.user.update({
where: {
id: user.id,
},
data: {
- // if the user doesn't have a default partner id, set the new partner id
- ...(!user.defaultPartnerId && { defaultPartnerId: partnerId }),
- // if the user doesn't have an image, set the partner image
- ...(!user.image && { image: imageUrl }),
+ defaultPartnerId: partnerId,
},
}),
]);
// Complete any outstanding program application
waitUntil(completeProgramApplications(user.email));
+
+ // if the user doesn't have an image, set the uploaded image as the user's image
+ if (!user.image && image) {
+ waitUntil(
+ storage
+ .upload({
+ key: `avatars/${user.id}`,
+ body: image,
+ })
+ .then(({ url }) => {
+ prisma.user.update({
+ where: {
+ id: user.id,
+ },
+ data: { image: url },
+ });
+ }),
+ );
+ }
});