feat: Custom Fields OR Add-Ons with a fee associated (#19997)

* feat: Addons to bookings

* Add tests

* Add tests

* Fix price field not shown immediately after enabling payment for an event

* Add support for all currencies in addons and fix type errors

* Address review comments

* Add tests to cover all input types

* Address cubic-dev-ai comments

* Remove openapi.json from git tracking

* Revert changes

* Revert unrelated linter/formatter changes

* Address cubic-dev-ai comments

* Addres cubic-dev-ai comment

* Update to use test id instead of hardcoded label

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Address coderabbits review comments

* Fix failing unit test

* some fixes...

* Fix tests

* Fix import

* Move handlePayment test file to appropriate location

* Fix test

---------

Co-authored-by: Omar López <[email protected]>
Co-authored-by: amrit <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Kartik Saini <[email protected]>
Co-authored-by: Anik Dhabal Babu <[email protected]>
Co-authored-by: Devanshu Sharma <[email protected]>
Co-authored-by: Benny Joo <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Volnei Munhoz <[email protected]>
This commit is contained in:
14 files changed
+822 -40

No files matched your search

@@ -42,6 +42,7 @@ import {
} from "@calcom/lib/constants";
import { generateHashedLink } from "@calcom/lib/generateHashedLink";
import { checkWCAGContrastColor } from "@calcom/lib/getBrandColours";
import { getPaymentAppData } from "@calcom/app-store/_utils/payments/getPaymentAppData";
import { extractHostTimezone } from "@calcom/lib/hashedLinksUtils";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { Prisma } from "@calcom/prisma/client";
@@ -569,6 +570,21 @@ export const EventAdvancedTab = ({
userEmail = removePlatformClientIdFromEmail(userEmail, platformContext.clientId);
}
const metadata = formMethods.watch("metadata");
const paymentAppData = useMemo(() => {
const _eventType = {
price: 0,
currency: "",
metadata,
};
return getPaymentAppData(_eventType);
}, [metadata]);
const isPaidEvent = useMemo(
() => !Number.isNaN(paymentAppData.price) && paymentAppData.price > 0,
[paymentAppData]
);
const TimezoneSelect = useMemo(() => {
return isPlatform ? PlatformTimzoneSelect : WebTimezoneSelect;
}, [isPlatform]);
@@ -628,6 +644,8 @@ export const EventAdvancedTab = ({
// Location field has a default value at backend so API can send no location but we don't allow it in UI and thus we want to show it as required to user
return field.name === "location" ? true : field.required;
}}
showPriceField={isPaidEvent}
paymentCurrency={paymentAppData?.currency || "usd"}
/>
</div>
</div>