Skip to content

Commit 3393640

Browse files
authored
Merge branch 'main' into fix/org-avatar-not-showing-shell
2 parents 9552208 + 07f803e commit 3393640

4 files changed

Lines changed: 38 additions & 48 deletions

File tree

packages/app-store/paypal/lib/PaymentService.ts

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,24 @@ export class PaymentService implements IAbstractPaymentService {
117117
throw new Error();
118118
}
119119

120+
const uid = uuidv4();
121+
122+
const paypalClient = new Paypal({
123+
clientId: this.credentials.client_id,
124+
secretKey: this.credentials.secret_key,
125+
});
126+
const preference = await paypalClient.createOrder({
127+
referenceId: uid,
128+
amount: payment.amount,
129+
currency: payment.currency,
130+
returnUrl: `${WEBAPP_URL}/booking/${booking.uid}`,
131+
cancelUrl: `${WEBAPP_URL}/payment/${uid}`,
132+
intent: "AUTHORIZE",
133+
});
134+
120135
const paymentData = await prisma.payment.create({
121136
data: {
122-
uid: uuidv4(),
137+
uid,
123138
app: {
124139
connect: {
125140
slug: "paypal",
@@ -132,34 +147,12 @@ export class PaymentService implements IAbstractPaymentService {
132147
},
133148
amount: payment.amount,
134149
currency: payment.currency,
135-
data: {},
150+
data: Object.assign({}, preference) as unknown as Prisma.InputJsonValue,
136151
fee: 0,
137152
refunded: false,
138153
success: false,
139154
paymentOption: paymentOption || "ON_BOOKING",
140-
},
141-
});
142-
143-
const paypalClient = new Paypal({
144-
clientId: this.credentials.client_id,
145-
secretKey: this.credentials.secret_key,
146-
});
147-
const preference = await paypalClient.createOrder({
148-
referenceId: paymentData.uid,
149-
amount: paymentData.amount,
150-
currency: paymentData.currency,
151-
returnUrl: `${WEBAPP_URL}/booking/${booking.uid}`,
152-
cancelUrl: `${WEBAPP_URL}/payment/${paymentData.uid}`,
153-
intent: "AUTHORIZE",
154-
});
155-
156-
await prisma.payment.update({
157-
where: {
158-
id: paymentData.id,
159-
},
160-
data: {
161155
externalId: preference?.id,
162-
data: Object.assign({}, preference) as unknown as Prisma.InputJsonValue,
163156
},
164157
});
165158

packages/features/ee/organizations/pages/settings/profile.tsx

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { z } from "zod";
88

99
import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired";
1010
import { subdomainSuffix } from "@calcom/features/ee/organizations/lib/orgDomains";
11-
import { WEBAPP_URL } from "@calcom/lib/constants";
1211
import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage";
1312
import { useLocale } from "@calcom/lib/hooks/useLocale";
1413
import { md } from "@calcom/lib/markdownIt";
@@ -69,7 +68,7 @@ const OrgProfileView = () => {
6968
onSuccess: (org) => {
7069
if (org) {
7170
form.setValue("name", org.name || "");
72-
form.setValue("slug", org.slug || "");
71+
form.setValue("slug", org.slug || org.metadata?.requestedSlug || "");
7372
form.setValue("logo", org.logo || "");
7473
form.setValue("bio", org.bio || "");
7574
if (org.slug === null && (org?.metadata as Prisma.JsonObject)?.requestedSlug) {
@@ -89,20 +88,8 @@ const OrgProfileView = () => {
8988
!currentOrganisation.bio ||
9089
!currentOrganisation.bio.replace("<p><br></p>", "").length;
9190

92-
const deleteTeamMutation = trpc.viewer.teams.delete.useMutation({
93-
async onSuccess() {
94-
await utils.viewer.teams.list.invalidate();
95-
showToast(t("your_org_disbanded_successfully"), "success");
96-
router.push(`${WEBAPP_URL}/teams`);
97-
},
98-
});
99-
10091
if (!orgBranding) return null;
10192

102-
function deleteTeam() {
103-
if (currentOrganisation?.id) deleteTeamMutation.mutate({ teamId: currentOrganisation.id });
104-
}
105-
10693
return (
10794
<LicenseRequired>
10895
<Meta title={t("profile")} description={t("profile_org_description")} />
@@ -168,15 +155,21 @@ const OrgProfileView = () => {
168155
</div>
169156
)}
170157
/>
171-
<div className="mt-8">
172-
<TextField
173-
name="slug"
174-
label={t("org_url")}
175-
value={currentOrganisation.slug ?? ""}
176-
disabled
177-
addOnSuffix={`.${subdomainSuffix()}`}
178-
/>
179-
</div>
158+
<Controller
159+
control={form.control}
160+
name="slug"
161+
render={({ field: { value } }) => (
162+
<div className="mt-8">
163+
<TextField
164+
name="slug"
165+
label={t("org_url")}
166+
value={value}
167+
disabled
168+
addOnSuffix={`.${subdomainSuffix()}`}
169+
/>
170+
</div>
171+
)}
172+
/>
180173
<div className="mt-8">
181174
<Label>{t("about")}</Label>
182175
<Editor

packages/prisma/schema.prisma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ model Payment {
509509
success Boolean
510510
refunded Boolean
511511
data Json
512-
externalId String? @unique
512+
externalId String @unique
513513
paymentOption PaymentOption? @default(ON_BOOKING)
514514
515515
@@index([bookingId])

packages/trpc/server/routers/viewer/organizations/list.handler.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { PrismaClient } from "@calcom/prisma/client";
2+
import { teamMetadataSchema } from "@calcom/prisma/zod-utils";
23
import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";
34

45
import { TRPCError } from "@trpc/server";
@@ -28,11 +29,14 @@ export const listHandler = async ({ ctx }: ListHandlerInput) => {
2829
},
2930
});
3031

32+
const metadata = teamMetadataSchema.parse(membership?.team.metadata);
33+
3134
return {
3235
user: {
3336
role: membership?.role,
3437
accepted: membership?.accepted,
3538
},
3639
...membership?.team,
40+
metadata,
3741
};
3842
};

0 commit comments

Comments
 (0)