2023-02-15 19:08:17 +00:00
import dynamic from "next/dynamic" ;
2021-09-22 19:52:38 +00:00
import { useRouter } from "next/router" ;
Generate SSG Page used as cache for user's third-party calendar (#6775)
* Generate SSG Page used as cache for user's third-party calendars
* remove next-build-id dependency
* yarn.lock from main
* add support to get cached data from multiple months
* Update apps/web/pages/[user]/calendar-cache/[month].tsx
Co-authored-by: Omar López <zomars@me.com>
* Update apps/web/pages/[user]/calendar-cache/[month].tsx
Co-authored-by: Omar López <zomars@me.com>
* Update packages/core/CalendarManager.ts
Co-authored-by: Omar López <zomars@me.com>
* Add api endpoint that revalidates the current month and 3 more ahead
* Revalidate calendar cache when user connect new calendar.
* Revalidate calendar cache when user remove a calendar.
* Revalidate calendar cache when user change de selected calendars-
* Change revalidateCalendarCache function to @calcom/lib/server
* Remove the memory cache from getCachedResults
* refetch availability slots in a 3 seconds interval
* Hotfix: Event Name (#6863) (#6864)
* feat: make key unique (#6861)
* version 2.5.9 (#6868)
* Use Calendar component view=day for drop-in replacement troubleshooter (#6869)
* Use Calendar component view=day for drop-in replacement troubleshooter
* Setting the id to undefined makes the busy time selected
* Updated event title to include title+source
* lots of small changes by me and ciaran (#6871)
* Hotfix: For old Plausible installs enabled in an EventType, give a default value (#6860)
* Add default for trackingId for old plausible installs in event-types
* Fix types
* fix: filter booking in upcoming (#6406)
* fix: filter booking in upcoming
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: test
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: wipe-my-cal failing test
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: Peer Richelsen <peer@cal.com>
* fix workflows when duplicating event types (#6873)
* fix: get location url from metadata (#6774)
* fix: get location url from metadata
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: replace location
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: type error
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: use zod
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Updates heroku deployment template (#6879)
* Hide button (#6895)
* Fixed some inconsistencies within single event type page (#6887)
* Fixed some inconsistencies within single event type page
* Fix layout shift on AvailabilityTab
* fix(date-overrides): alignment of edit & delete btns (#6892)
* When unchecking the common schedule, schedule should be nulled (#6898)
* theme for storybook
* nit border change (#6899)
* fix: metadata not saved while creating a booking. (#6866)
* feat: add metadata to booking creation
* fix: bug
* Beginning of Strict CSP Compliance (#6841)
* Add CSP Support and enable it initially for Login page
* Update README
* Make sure that CSP is not enabled if CSP_POLICY isnt set
* Add a new value for x-csp header that tells if instance has opted-in to CSP or not
* Add more src to CSP
* Fix typo in header name
* Remove duplicate headers fn
* Add https://eu.ui-avatars.com/api/
* Add CSP_POLICY to env.example
* v2.5.10
* fix: add req.headers (#6921)
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* add-console-vars (#6929)
* Admin Wizard Choose License (#6574)
* Implementation
* i18n
* More i18n
* extracted i18n, needs api to get most recent price, added hint: update later
* Fixing i18n var
* Fix booking filters not working for admin (#6576)
* fix: react-select overflow issue in some modals. (#6587)
* feat: add a disable overflow prop
* feat: use the disable overflow prop
* Tailwind Merge (#6596)
* Tailwind Merge
* Fix merge classNames
* [CAL-808] /availability/single - UI issue on buttons beside time inputs (#6561)
* [CAL-808] /availability/single - UI issue on buttons beside time inputs
* Update apps/web/public/static/locales/en/common.json
* Update packages/features/schedules/components/Schedule.tsx
* create new translation for tooltip
Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
* Bye bye submodules (#6585)
* WIP
* Uses ssh instead
* Update .gitignore
* Update .gitignore
* Update Makefile
* Update git-setup.sh
* Update git-setup.sh
* Replaced Makefile with bash script
* Update package.json
* fix: show button on empty string (#6601)
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: add delete in dropdown (#6599)
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Update README.md
* Update README.md
* Changed a neutral- classes to gray (#6603)
* Changed a neutral- classes to gray
* Changed all border-1 to border
* Update package.json
* Test fixes
* Yarn lock fixes
* Fix string equality check in git-setup.sh
* [CAL-811] Avatar icon not redirecting user back to the main page (#6586)
* Remove cursor-pointer, remove old Avatar* files
* Fixed styling for checkedSelect + some cleanup
Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
* Harsh/add member invite (#6598)
Co-authored-by: Guest <guest@pop-os.localdomain>
Co-authored-by: root <harsh.singh@gocomet.com>
* Regenerated lockfile without upgrade (#6610)
* fix: remove annoying outline when <Button /> clicked (#6537)
* fix: remove annoying outline when <Button /> clicked
* Delete yarn.lock
* remove 1 on 1 icon (#6609)
* removed 1-on-1 badge
* changed user to users for group events
* fix: case-sensitivity in apps path (#6552)
* fix: lowercase slug
* fix: make fallback blocking
* Fix FAB (#6611)
* feat: add LocationSelect component (#6571)
* feat: add LocationSelect component
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: type error
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* chore: type error
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Update booking filters design (#6543)
* Update booking filters
* Add filter on YOUR bookings
* Fix pending members showing up in list
* Reduce the avatar size to 'sm' for now
* Bugfix/dropdown menu trigger as child remove class names (#6614)
* Fix UsernameTextfield to take right height
* Remove className side-effect
* Incorrect resolution version fixed
* Converted mobile DropdownMenuTrigger styles into Button
* v2.5.3
* fix: use items-center (#6618)
* fix tooltip and modal stacking issues (#6491)
* fix tooltip and modal stacking issues
* use z-index in larger screens and less
Co-authored-by: Alex van Andel <me@alexvanandel.com>
* Temporary fix (#6626)
* Fix Ga4 tracking (#6630)
* generic <UpgradeScreen> component (#6594)
* first attempt of <UpgradeScreen>
* changes to icons
* reverted changes back to initial state, needs fix: teams not showing
* WIP
* Fix weird reactnode error
* Fix loading text
* added upgradeTip to routing forms
* icon colors
* create and use hook to check if user has team plan
* use useTeamPlan for upgradeTeamsBadge
* replace huge svg with compressed jpeg
* responsive fixes
* Update packages/ui/components/badge/UpgradeTeamsBadge.tsx
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Give team plan features to E2E tests
* Allow option to make a user part of team int ests
* Remove flash of paywall for team user
* Add team user for typeform tests as well
Co-authored-by: Peer Richelsen <peer@cal.com>
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
* Removing env var to rely on db
* Restoring i18n keys, set loading moved
* Fixing tailwind-preset glob
* Wizard width fix for md+ screens
* Converting licenses options to radix radio
* Applying feedback + other tweaks
* Reverting this, not this PR related
* Unneeded code removal
* Reverting unneeded style change
* Applying feedback
* Removing licenseType
* Upgrades typescript
* Update yarn lock
* Typings
* Hotfix: ping,riverside,whereby and around not showing up in list (#6712)
* Hotfix: ping,riverside,whereby and around not showing up in list (#6712) (#6713)
* Adds deployment settings to DB (#6706)
* WIP
* Adds DeploymentTheme
* Add missing migrations
* Adds client extensions for deployment
* Cleanup
* Delete migration.sql
* Relying on both, env var and new model
* Restoring env example doc for backward compat
* Maximum call stack size exceeded fix?
* Revert upgrade
* Update index.ts
* Delete index.ts
* Not exposing license key, fixed radio behavior
* Covering undefined env var
* Self contained checkLicense
* Feedback
* Moar feedback
* Feedback
* Feedback
* Feedback
* Cleanup
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Peer Richelsen <peer@cal.com>
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
Co-authored-by: Nafees Nazik <84864519+G3root@users.noreply.github.com>
Co-authored-by: GitStart-Cal.com <121884634+gitstart-calcom@users.noreply.github.com>
Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Omar López <zomars@me.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
Co-authored-by: Harsh Singh <51085015+harshsinghatz@users.noreply.github.com>
Co-authored-by: Guest <guest@pop-os.localdomain>
Co-authored-by: root <harsh.singh@gocomet.com>
Co-authored-by: Luis Cadillo <luiscaf3r@gmail.com>
Co-authored-by: Mohammed Cherfaoui <hi@cherfaoui.dev>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
* added two new tips (#6915)
* [CAL-488] Timezone selection has a weird double dropdown (#6851)
Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com>
* fix: color and line height of icon (#6913)
* fix: use destination calendar email (#6886)
* fix: use destination calendar email
to display correct primary email
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: simplify logic
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: dropdown title in bookings page (#6924)
* fixes the broken max size of members on teams page (#6926)
* fix: display provider name instead of url (#6914)
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: add sortByLabel (#6797)
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Email Variables Bug (#6943)
* Remove _subject translations for zh-CN, needs retranslation
* minor timezone-select improvements (#6944)
* fixed timezone select positioning and hover
* fixed timezone select positioning and hover
* Give trackingId a default value because if user doesnt interact with trackingId input it is not set (#6945)
* Block /auth/:path, nothing else. (#6949)
* Block /auth/:path, nothing else.
* Also add /signup
* fix start icon in button (#6950)
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
* Fixes localisation of {EVENT_DATE} in workflows (#6907)
* translate {EVENT_DATE} variable to correct language
* fix locale for cron schedule reminder emails/sms
* fix type error
* add missing locale to attendees
* fix type error
* code clean up
* revert last commit
* using Intl for date translations
---------
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
* Allow account linking for Google and SAML providers (#6874)
* allow account linking for self-hosted instances, both Google and SAML are verified emails
* allow account linking for Google and SSO if emails match with existing username/password account
* Tweaked find user by email since we now have multiple providers (other than credentials provider)
* feat/payment-service-6438-cal-767 (#6677)
* WIP paymentService
* Changes for payment Service
* Fix for stripe payment flow
* Remove logs/comments
* Refactored refund for stripe app
* Move stripe handlePayment to own lib
* Move stripe delete payments to paymentService
* lint fix
* Change handleRefundError as generic function
* remove log
* remove logs
* remove logs
* Return stripe default export to lib/server
* Fixing types
* Fix types
* Upgrades typescript
* Update yarn lock
* Typings
* Hotfix: ping,riverside,whereby and around not showing up in list (#6712)
* Hotfix: ping,riverside,whereby and around not showing up in list (#6712) (#6713)
* Adds deployment settings to DB (#6706)
* WIP
* Adds DeploymentTheme
* Add missing migrations
* Adds client extensions for deployment
* Cleanup
* Revert "lint fix"
This reverts commit e1a2e4a357e58e6673c47399888ae2e00d1351a6.
* Add validation
* Revert changes removed in force push
* Removing abstract class and just leaving interface implementation
* Fix types for handlePayments
* Fix payment test appStore import
* Fix stripe metadata in event type
* Move migration to separate PR
* Revert "Move migration to separate PR"
This reverts commit 48aa64e0724a522d3cc2fefaaaee5792ee9cd9e6.
* Update packages/prisma/migrations/20230125175109_remove_type_from_payment_and_add_app_relationship/migration.sql
Co-authored-by: Omar López <zomars@me.com>
---------
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
* Small UI fixes for seats & destination calendars (#6859)
* Do not add former time for events on seats
* Default display destination calendar
* Add seats badge to event type item
* Add string
* Actively watch seats enabled option for requires confirmation
* Only show former time when there is a rescheduleUid
* fix: use typedquery hook in duplicate dialog (#6730)
* fix: use typedquery hook in duplicate dialog
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Update packages/features/eventtypes/components/DuplicateDialog.tsx
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Peer Richelsen <peer@cal.com>
Co-authored-by: Omar López <zomars@me.com>
* Fixing admin wizard step done (#6954)
* Feature/maintenance mode (#6930)
* Implement maintenance mode with Vercel Edge Config
* Error log is spam during development/ added \n in .env.example
* Exclude _next, /api for /maintenance page
* Re-instate previous config
* rtl: begone
* Added note to explain why /auth/login covers the maintenance page.
---------
Co-authored-by: Omar López <zomars@me.com>
* Update package.json
* I18N Caching (#6823)
* Caching Logic Changes
Enabled this function to change its cache value based on incoming paths value
* Invalidate I18N Cache
Invalidating the I18N cache when a user saves changes to their General settings
* Removes deprecated useLocale location
* Overriding the default getSchedule cache to have a revalidation time of 1 second
* Update apps/web/pages/api/trpc/[trpc].ts
* Updated cache values to match the comment
---------
Co-authored-by: zomars <zomars@me.com>
* feat: return `x-vercel-ip-timezone` in headers (#6849)
* feat: add trpc to matcher and pass vercel timezone header
* feat: pass request to context
* feat: return timezone in header
* refactor: split context
* fix: remove tsignore comment
* Update [trpc].ts
---------
Co-authored-by: zomars <zomars@me.com>
* log the json url for testing
* use WEBAPP_URL constant instead env.NEXT_PUBLIC_WEBAPP_URL
* remove the commented selectedCalendars var, it is not necessary
* Caching fixes
* Separate selectedDate slots from month slots
* Update [trpc].ts
* Log headers
* Update [trpc].ts
* Update package.json
* Fixes/trpc headers (#7045)
* Cache fixes
* Testing
* SWR breaks embed tests
* Prevent refetching day on month switch
* Skeleton fixes
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
Co-authored-by: Nafees Nazik <84864519+G3root@users.noreply.github.com>
Co-authored-by: Ben Hybert <53020786+Hybes@users.noreply.github.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: Peer Richelsen <peer@cal.com>
Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com>
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
Co-authored-by: Sai Deepesh <saideepesh000@gmail.com>
Co-authored-by: alannnc <alannnc@gmail.com>
Co-authored-by: Leo Giovanetti <hello@leog.me>
Co-authored-by: GitStart-Cal.com <121884634+gitstart-calcom@users.noreply.github.com>
Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com>
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Harsh Singh <51085015+harshsinghatz@users.noreply.github.com>
Co-authored-by: Guest <guest@pop-os.localdomain>
Co-authored-by: root <harsh.singh@gocomet.com>
Co-authored-by: Luis Cadillo <luiscaf3r@gmail.com>
Co-authored-by: Mohammed Cherfaoui <hi@cherfaoui.dev>
Co-authored-by: Joe Shajan <joeshajan1551@gmail.com>
Co-authored-by: Deepak Prabhakara <deepak@boxyhq.com>
Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
Co-authored-by: Aaron Presley <155617+AaronPresley@users.noreply.github.com>
2023-02-13 18:42:53 +00:00
import { useEffect , useMemo , useReducer , useState } from "react" ;
2021-09-22 19:52:38 +00:00
import { FormattedNumber , IntlProvider } from "react-intl" ;
2022-06-27 21:01:46 +00:00
import { z } from "zod" ;
2021-09-22 19:52:38 +00:00
2022-10-14 16:24:43 +00:00
import BookingPageTagManager from "@calcom/app-store/BookingPageTagManager" ;
import { getEventTypeAppData } from "@calcom/app-store/utils" ;
2023-02-16 22:39:57 +00:00
import dayjs from "@calcom/dayjs" ;
2022-04-25 04:33:00 +00:00
import {
2022-07-23 00:39:50 +00:00
useEmbedNonStylesConfig ,
2022-08-05 18:44:30 +00:00
useEmbedStyles ,
2022-12-13 07:23:26 +00:00
useEmbedUiConfig ,
2022-04-25 04:33:00 +00:00
useIsBackgroundTransparent ,
2022-08-05 18:44:30 +00:00
useIsEmbed ,
2022-05-27 15:37:02 +00:00
} from "@calcom/embed-core/embed-iframe" ;
2022-07-23 00:39:50 +00:00
import CustomBranding from "@calcom/lib/CustomBranding" ;
2022-04-08 05:33:24 +00:00
import classNames from "@calcom/lib/classNames" ;
2023-02-08 20:36:22 +00:00
import getPaymentAppData from "@calcom/lib/getPaymentAppData" ;
2022-04-14 21:25:24 +00:00
import { useLocale } from "@calcom/lib/hooks/useLocale" ;
2022-07-28 19:58:26 +00:00
import useTheme from "@calcom/lib/hooks/useTheme" ;
2022-08-12 19:29:29 +00:00
import notEmpty from "@calcom/lib/notEmpty" ;
2022-06-10 20:38:06 +00:00
import { getRecurringFreq } from "@calcom/lib/recurringStrings" ;
2022-07-28 19:58:26 +00:00
import { collectPageParameters , telemetryEventTypes , useTelemetry } from "@calcom/lib/telemetry" ;
2022-10-25 00:14:06 +00:00
import { detectBrowserTimeFormat , setIs24hClockInLocalStorage , TimeFormat } from "@calcom/lib/timeFormat" ;
2023-01-23 23:08:01 +00:00
import { HeadSeo } from "@calcom/ui" ;
2023-02-17 19:53:31 +00:00
import { FiCreditCard , FiRefreshCcw } from "@calcom/ui/components/icon" ;
2022-04-08 05:33:24 +00:00
2022-06-27 21:01:46 +00:00
import { timeZone as localStorageTimeZone } from "@lib/clock" ;
2021-09-22 19:52:38 +00:00
2023-02-16 22:39:57 +00:00
import type { Gate , GateState } from "@components/Gates" ;
import Gates from "@components/Gates" ;
2022-10-12 08:39:14 +00:00
import BookingDescription from "@components/booking/BookingDescription" ;
2023-02-17 19:53:31 +00:00
import { SlotPicker } from "@components/booking/SlotPicker" ;
2021-09-14 08:45:28 +00:00
2022-06-15 20:54:31 +00:00
import type { AvailabilityPageProps } from "../../../pages/[user]/[type]" ;
import type { DynamicAvailabilityPageProps } from "../../../pages/d/[link]/[slug]" ;
import type { AvailabilityTeamPageProps } from "../../../pages/team/[slug]/[type]" ;
2021-09-23 14:08:44 +00:00
2023-02-15 19:08:17 +00:00
const PoweredByCal = dynamic ( ( ) = > import ( "@components/ui/PoweredByCal" ) ) ;
2022-06-27 21:01:46 +00:00
2023-02-17 19:53:31 +00:00
const Toaster = dynamic ( ( ) = > import ( "react-hot-toast" ) . then ( ( mod ) = > mod . Toaster ) , { ssr : false } ) ;
/ * c o n s t S l o t P i c k e r = d y n a m i c ( ( ) = > i m p o r t ( " . . / S l o t P i c k e r " ) . t h e n ( ( m o d ) = > m o d . S l o t P i c k e r ) , {
ssr : false ,
loading : ( ) = > < div className = "mt-8 px-4 pb-4 sm:mt-0 sm:p-4 md:min-w-[300px] md:px-5 lg:min-w-[455px]" / > ,
} ) ; * /
const TimezoneDropdown = dynamic ( ( ) = > import ( "../TimezoneDropdown" ) . then ( ( mod ) = > mod . TimezoneDropdown ) , {
ssr : false ,
} ) ;
2022-06-15 20:54:31 +00:00
2022-06-27 21:01:46 +00:00
const dateQuerySchema = z . object ( {
rescheduleUid : z.string ( ) . optional ( ) . default ( "" ) ,
date : z.string ( ) . optional ( ) . default ( "" ) ,
timeZone : z.string ( ) . optional ( ) . default ( "" ) ,
} ) ;
2022-06-15 20:54:31 +00:00
2022-09-05 21:10:58 +00:00
export type Props = AvailabilityTeamPageProps | AvailabilityPageProps | DynamicAvailabilityPageProps ;
2022-10-19 21:25:03 +00:00
const AvailabilityPage = ( { profile , eventType , . . . restProps } : Props ) = > {
2022-06-15 20:54:31 +00:00
const router = useRouter ( ) ;
2022-10-19 21:25:03 +00:00
const isEmbed = useIsEmbed ( restProps . isEmbed ) ;
2022-06-27 21:01:46 +00:00
const query = dateQuerySchema . parse ( router . query ) ;
const { rescheduleUid } = query ;
2022-07-26 08:27:57 +00:00
useTheme ( profile . theme ) ;
2022-06-16 02:07:07 +00:00
const { t } = useLocale ( ) ;
2022-06-15 20:54:31 +00:00
const availabilityDatePickerEmbedStyles = useEmbedStyles ( "availabilityDatePicker" ) ;
2022-12-13 07:23:26 +00:00
//TODO: Plan to remove shouldAlignCentrallyInEmbed config
2022-06-15 20:54:31 +00:00
const shouldAlignCentrallyInEmbed = useEmbedNonStylesConfig ( "align" ) !== "left" ;
const shouldAlignCentrally = ! isEmbed || shouldAlignCentrallyInEmbed ;
const isBackgroundTransparent = useIsBackgroundTransparent ( ) ;
const [ timeZone , setTimeZone ] = useState < string > ( ) ;
2022-10-25 00:14:06 +00:00
const [ timeFormat , setTimeFormat ] = useState < TimeFormat > ( detectBrowserTimeFormat ) ;
const onTimeFormatChange = ( is24Hours : boolean ) = > {
setTimeFormat ( is24Hours ? TimeFormat.TWENTY_FOUR_HOUR : TimeFormat.TWELVE_HOUR ) ;
setIs24hClockInLocalStorage ( is24Hours ) ;
} ;
2022-10-14 19:15:03 +00:00
2022-09-05 21:10:58 +00:00
const [ gateState , gateDispatcher ] = useReducer (
( state : GateState , newState : Partial < GateState > ) = > ( {
. . . state ,
. . . newState ,
} ) ,
{ }
) ;
2022-02-23 12:37:15 +00:00
2022-06-15 20:54:31 +00:00
useEffect ( ( ) = > {
2022-06-27 21:01:46 +00:00
setTimeZone ( localStorageTimeZone ( ) || dayjs . tz . guess ( ) ) ;
2022-10-25 00:14:06 +00:00
} , [ ] ) ;
2022-06-27 21:01:46 +00:00
2022-06-15 20:54:31 +00:00
const [ recurringEventCount , setRecurringEventCount ] = useState ( eventType . recurringEvent ? . count ) ;
2022-02-23 12:37:15 +00:00
2022-06-15 20:54:31 +00:00
const telemetry = useTelemetry ( ) ;
useEffect ( ( ) = > {
2022-06-02 16:19:01 +00:00
if ( top !== window ) {
//page_view will be collected automatically by _middleware.ts
telemetry . event (
telemetryEventTypes . embedView ,
2022-05-11 05:14:08 +00:00
collectPageParameters ( "/availability" , { isTeamBooking : document.URL.includes ( "team/" ) } )
2022-06-02 16:19:01 +00:00
) ;
}
2021-09-14 08:45:28 +00:00
} , [ telemetry ] ) ;
2022-12-13 07:23:26 +00:00
const embedUiConfig = useEmbedUiConfig ( ) ;
2022-08-12 19:29:29 +00:00
// get dynamic user list here
2022-09-05 21:10:58 +00:00
const userList = eventType . users ? eventType . users . map ( ( user ) = > user . username ) . filter ( notEmpty ) : [ ] ;
2022-10-10 13:24:06 +00:00
2022-06-27 21:01:46 +00:00
const timezoneDropdown = useMemo (
2022-10-25 00:14:06 +00:00
( ) = > < TimezoneDropdown timeZone = { timeZone } onChangeTimeZone = { setTimeZone } / > ,
[ timeZone ]
2022-06-15 20:54:31 +00:00
) ;
2023-02-08 20:36:22 +00:00
const paymentAppData = getPaymentAppData ( eventType ) ;
2022-10-14 16:24:43 +00:00
const rainbowAppData = getEventTypeAppData ( eventType , "rainbow" ) || { } ;
2022-07-15 16:54:14 +00:00
const rawSlug = profile . slug ? profile . slug . split ( "/" ) : [ ] ;
if ( rawSlug . length > 1 ) rawSlug . pop ( ) ; //team events have team name as slug, but user events have [user]/[type] as slug.
2022-06-15 20:54:31 +00:00
2022-12-13 07:23:26 +00:00
const showEventTypeDetails = ( isEmbed && ! embedUiConfig . hideEventTypeDetails ) || ! isEmbed ;
2022-09-05 21:10:58 +00:00
// Define conditional gates here
const gates = [
// Rainbow gate is only added if the event has both a `blockchainId` and a `smartContractAddress`
2022-10-14 16:24:43 +00:00
rainbowAppData && rainbowAppData . blockchainId && rainbowAppData . smartContractAddress
2022-09-05 21:10:58 +00:00
? ( "rainbow" as Gate )
: undefined ,
] ;
2021-09-14 08:45:28 +00:00
return (
2022-10-14 16:24:43 +00:00
< Gates gates = { gates } appData = { rainbowAppData } dispatch = { gateDispatcher } >
2021-09-24 22:11:30 +00:00
< HeadSeo
2021-10-08 11:43:48 +00:00
title = { ` ${ rescheduleUid ? t ( "reschedule" ) : "" } ${ eventType . title } | ${ profile . name } ` }
description = { ` ${ rescheduleUid ? t ( "reschedule" ) : "" } ${ eventType . title } ` }
2022-10-18 17:46:22 +00:00
meeting = { {
title : eventType.title ,
profile : { name : ` ${ profile . name } ` , image : profile.image } ,
users : [
. . . ( eventType . users || [ ] ) . map ( ( user ) = > ( {
name : ` ${ user . name } ` ,
username : ` ${ user . username } ` ,
} ) ) ,
] ,
} }
2022-07-26 00:17:15 +00:00
nextSeoProps = { {
nofollow : eventType.hidden ,
noindex : eventType.hidden ,
} }
2021-09-24 22:11:30 +00:00
/ >
2022-10-14 16:24:43 +00:00
< BookingPageTagManager eventType = { eventType } / >
2022-03-05 15:37:46 +00:00
< CustomBranding lightVal = { profile . brandColor } darkVal = { profile . darkBrandColor } / >
2021-09-24 22:11:30 +00:00
< div >
< main
2022-04-25 04:33:00 +00:00
className = { classNames (
2022-12-13 07:23:26 +00:00
"flex flex-col md:mx-4" ,
2022-10-10 13:24:06 +00:00
shouldAlignCentrally ? "items-center" : "items-start" ,
! isEmbed && classNames ( "mx-auto my-0 ease-in-out md:my-24" )
2022-04-25 04:33:00 +00:00
) } >
2022-10-10 13:24:06 +00:00
< div >
< div
style = { availabilityDatePickerEmbedStyles }
className = { classNames (
isBackgroundTransparent
? ""
: "dark:bg-darkgray-100 sm:dark:border-darkgray-300 bg-white pb-4 md:pb-0" ,
2023-02-08 12:08:00 +00:00
"border-bookinglightest md:rounded-md md:border" ,
2022-10-10 13:24:06 +00:00
isEmbed && "mx-auto"
) } >
2023-02-08 12:08:00 +00:00
< div className = "md:flex" >
2022-12-13 07:23:26 +00:00
{ showEventTypeDetails && (
< div
className = { classNames (
"sm:dark:border-darkgray-200 flex flex-col border-gray-200 p-5 sm:border-r" ,
"min-w-full md:w-[230px] md:min-w-[230px]" ,
recurringEventCount && "xl:w-[380px] xl:min-w-[380px]"
) } >
< BookingDescription profile = { profile } eventType = { eventType } rescheduleUid = { rescheduleUid } >
{ ! rescheduleUid && eventType . recurringEvent && (
< div className = "flex items-start text-sm font-medium" >
2023-01-23 23:08:01 +00:00
< FiRefreshCcw className = "float-left mt-[7px] ml-[2px] inline-block h-4 w-4 ltr:mr-[10px] rtl:ml-[10px] " / >
2022-12-13 07:23:26 +00:00
< div >
< p className = "mb-1 -ml-2 inline px-2 py-1" >
{ getRecurringFreq ( { t , recurringEvent : eventType.recurringEvent } ) }
< / p >
< input
type = "number"
min = "1"
max = { eventType . recurringEvent . count }
className = "w-15 dark:bg-darkgray-200 h-7 rounded-sm border-gray-300 bg-white text-sm font-medium [appearance:textfield] ltr:mr-2 rtl:ml-2 dark:border-gray-500"
defaultValue = { eventType . recurringEvent . count }
onChange = { ( event ) = > {
setRecurringEventCount ( parseInt ( event ? . target . value ) ) ;
} }
/ >
< p className = "inline" >
{ t ( "occurrence" , {
count : recurringEventCount ,
} ) }
< / p >
< / div >
2022-06-16 02:07:07 +00:00
< / div >
2022-12-13 07:23:26 +00:00
) }
2023-02-08 20:36:22 +00:00
{ paymentAppData . price > 0 && (
2022-12-13 07:23:26 +00:00
< p className = "-ml-2 px-2 text-sm font-medium" >
2023-01-23 23:08:01 +00:00
< FiCreditCard className = "ml-[2px] -mt-1 inline-block h-4 w-4 ltr:mr-[10px] rtl:ml-[10px]" / >
2022-12-13 07:23:26 +00:00
< IntlProvider locale = "en" >
< FormattedNumber
2023-02-08 20:36:22 +00:00
value = { paymentAppData . price / 100.0 }
2022-12-13 07:23:26 +00:00
style = "currency"
2023-02-08 20:36:22 +00:00
currency = { paymentAppData . currency ? . toUpperCase ( ) }
2022-12-13 07:23:26 +00:00
/ >
< / IntlProvider >
< / p >
) }
{ timezoneDropdown }
< / BookingDescription >
{ / * T e m p o r a r i l y d i s a b l e d - b o o k i n g ? . s t a r t T i m e & & r e s c h e d u l e U i d & & (
2022-04-14 21:25:24 +00:00
< div >
2022-04-18 10:25:56 +00:00
< p
2022-08-24 20:18:42 +00:00
className = "mt-4 mb-3 text-gray-600 dark:text-darkgray-600"
2022-04-18 10:25:56 +00:00
data - testid = "former_time_p_desktop" >
2022-04-14 21:25:24 +00:00
{ t ( "former_time" ) }
< / p >
2022-08-24 20:18:42 +00:00
< p className = "text-gray-500 line-through dark:text-darkgray-600" >
2023-01-04 07:38:45 +00:00
< CalendarIcon className = "ltr:mr-[10px] rtl:ml-[10px] -mt-1 inline-block h-4 w-4 text-gray-500" / >
2022-04-14 21:25:24 +00:00
{ typeof booking . startTime === "string" && parseDate ( dayjs ( booking . startTime ) , i18n ) }
< / p >
< / div >
2022-06-15 20:54:31 +00:00
) * / }
2022-12-13 07:23:26 +00:00
< / div >
) }
2022-10-10 13:24:06 +00:00
< SlotPicker
weekStart = {
typeof profile . weekStart === "string"
? ( [
"Sunday" ,
"Monday" ,
"Tuesday" ,
"Wednesday" ,
"Thursday" ,
"Friday" ,
"Saturday" ,
] . indexOf ( profile . weekStart ) as 0 | 1 | 2 | 3 | 4 | 5 | 6 )
: profile . weekStart /* Allows providing weekStart as number */
}
eventType = { eventType }
timeFormat = { timeFormat }
2022-10-25 00:14:06 +00:00
onTimeFormatChange = { onTimeFormatChange }
2022-10-10 13:24:06 +00:00
timeZone = { timeZone }
users = { userList }
seatsPerTimeSlot = { eventType . seatsPerTimeSlot || undefined }
recurringEventCount = { recurringEventCount }
ethSignature = { gateState . rainbowToken }
/ >
2021-09-14 08:45:28 +00:00
< / div >
< / div >
2022-12-12 08:37:36 +00:00
{ /* FIXME: We don't show branding in Embed yet because we need to place branding on top of the main content. Keeping it outside the main content would have visibility issues because outside main content background is transparent */ }
{ ! restProps . isBrandingHidden && ! isEmbed && < PoweredByCal / > }
2022-06-16 02:07:07 +00:00
< / div >
2021-09-24 22:11:30 +00:00
< / main >
< / div >
2022-09-05 21:10:58 +00:00
< Toaster position = "bottom-right" / >
< / Gates >
2021-09-14 08:45:28 +00:00
) ;
} ;
export default AvailabilityPage ;