2022-10-20 05:09:52 +00:00
|
|
|
import { useAutoAnimate } from "@formkit/auto-animate/react";
|
2023-02-16 22:39:57 +00:00
|
|
|
import type { GetStaticPaths, GetStaticProps } from "next";
|
2022-10-20 05:09:52 +00:00
|
|
|
import { Fragment } from "react";
|
2023-08-09 22:54:51 +00:00
|
|
|
import React from "react";
|
2022-08-24 20:18:42 +00:00
|
|
|
import { z } from "zod";
|
|
|
|
|
|
|
|
import { WipeMyCalActionButton } from "@calcom/app-store/wipemycalother/components";
|
2023-08-09 22:54:51 +00:00
|
|
|
import { getLayout } from "@calcom/features/MainLayout";
|
|
|
|
import { FiltersContainer } from "@calcom/features/bookings/components/FiltersContainer";
|
2023-02-16 22:39:57 +00:00
|
|
|
import type { filterQuerySchema } from "@calcom/features/bookings/lib/useFilterQuery";
|
|
|
|
import { useFilterQuery } from "@calcom/features/bookings/lib/useFilterQuery";
|
2023-08-09 22:54:51 +00:00
|
|
|
import { ShellMain } from "@calcom/features/shell/Shell";
|
2022-08-24 20:18:42 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2023-08-02 09:35:48 +00:00
|
|
|
import { useParamsWithFallback } from "@calcom/lib/hooks/useParamsWithFallback";
|
2023-02-16 22:39:57 +00:00
|
|
|
import type { RouterOutputs } from "@calcom/trpc/react";
|
|
|
|
import { trpc } from "@calcom/trpc/react";
|
2023-08-09 22:54:51 +00:00
|
|
|
import { HorizontalTabs } from "@calcom/ui";
|
|
|
|
import type { VerticalTabItemProps, HorizontalTabItemProps } from "@calcom/ui";
|
2023-01-23 23:08:01 +00:00
|
|
|
import { Alert, Button, EmptyScreen } from "@calcom/ui";
|
2023-04-12 15:26:31 +00:00
|
|
|
import { Calendar } from "@calcom/ui/components/icon";
|
2022-08-24 20:18:42 +00:00
|
|
|
|
|
|
|
import { useInViewObserver } from "@lib/hooks/useInViewObserver";
|
|
|
|
|
2023-04-18 18:45:32 +00:00
|
|
|
import PageWrapper from "@components/PageWrapper";
|
2022-08-24 20:18:42 +00:00
|
|
|
import BookingListItem from "@components/booking/BookingListItem";
|
2022-11-01 13:29:01 +00:00
|
|
|
import SkeletonLoader from "@components/booking/SkeletonLoader";
|
2022-08-24 20:18:42 +00:00
|
|
|
|
2022-12-07 20:53:44 +00:00
|
|
|
import { ssgInit } from "@server/lib/ssg";
|
|
|
|
|
feat: Organizations (#8993)
* Initial commit
* Adding feature flag
* feat: Orgs Schema Changing `scopedMembers` to `orgUsers` (#9209)
* Change scopedMembers to orgMembers
* Change to orgUsers
* Letting duplicate slugs for teams to support orgs
* Covering null on unique clauses
* Supporting having the orgId in the session cookie
* feat: organization event type filter (#9253)
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Missing changes to support orgs schema changes
* feat: Onboarding process to create an organization (#9184)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Making sure we check requestedSlug now
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* feat: [CAL-1816] Organization subdomain support (#9345)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* Covering users and subteams, excluding non-org users
* Unpublished teams shows correctly
* Create subdomain in Vercel
* feedback
* Renaming Vercel env vars
* Vercel domain check before creation
* Supporting cal-staging.com
* Change to have vercel detect it
* vercel domain check data message error
* Remove check domain
* Making sure we check requestedSlug now
* Feedback and unneeded code
* Reverting unneeded changes
* Unneeded changes
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Vercel subdomain creation in PROD only
* Making sure we let localhost still work
* Feedback
* Type check fixes
* feat: Organization branding in side menu (#9279)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Org branding provider used in shell sidebar
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Using org avatar (temp)
* Not showing org logo if not set
* User onboarding with org branding (slug)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Feedback
* Org public profile
* Public profiles for team event types
* Added setup profile alert
* Using org avatar on subteams avatar
* Making sure we show the set up profile on org only
* Profile username availability rely on org hook
* Update apps/web/pages/team/[slug].tsx
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Update apps/web/pages/team/[slug].tsx
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* feat: Organization support for event types page (#9449)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Org branding provider used in shell sidebar
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Using org avatar (temp)
* Not showing org logo if not set
* User onboarding with org branding (slug)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Feedback
* Org public profile
* Public profiles for team event types
* Added setup profile alert
* Using org avatar on subteams avatar
* Processing orgs and children as profile options
* Reverting change not belonging to this PR
* Making sure we show the set up profile on org only
* Removing console.log
* Comparing memberships to choose the highest one
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Type errors
* Refactor and type fixes
* Update orgDomains.ts
* Feedback
* Reverting
* NIT
* fix issue getting org slug from domain
* Improving orgDomains util
* Host comes with port
* Update useRouterQuery.ts
* Feedback
* Feedback
* Feedback
* Feedback: SSR for user event-types to have org context
* chore: Cache node_modules (#9492)
* Adding check for cache hit
* Adding a separate install step first
* Put the restore cache steps back
* Revert the uses type for restoring cache
* Added step to restore nm cache
* Removed the cache-hit check
* Comments and naming
* Removed extra install command
* Updated the name of the linting step to be more clear
* Removes the need for useEffect here
* Feedback
* Feedback
* Cookie domain needs a dot
* Type fix
* Update apps/web/public/static/locales/en/common.json
Co-authored-by: Omar López <zomars@me.com>
* Update packages/emails/src/templates/OrganizationAccountVerifyEmail.tsx
* Feedback
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: Efraín Rochín <roae.85@gmail.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
2023-06-14 21:40:20 +00:00
|
|
|
type BookingListingStatus = z.infer<NonNullable<typeof filterQuerySchema>>["status"];
|
2022-11-10 23:40:01 +00:00
|
|
|
type BookingOutput = RouterOutputs["viewer"]["bookings"]["get"]["bookings"][0];
|
2022-08-24 20:18:42 +00:00
|
|
|
|
2022-12-02 10:08:12 +00:00
|
|
|
type RecurringInfo = {
|
|
|
|
recurringEventId: string | null;
|
|
|
|
count: number;
|
|
|
|
firstDate: Date | null;
|
|
|
|
bookings: { [key: string]: Date[] };
|
|
|
|
};
|
|
|
|
|
2023-08-09 22:54:51 +00:00
|
|
|
const tabs: (VerticalTabItemProps | HorizontalTabItemProps)[] = [
|
|
|
|
{
|
|
|
|
name: "upcoming",
|
|
|
|
href: "/bookings/upcoming",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "unconfirmed",
|
|
|
|
href: "/bookings/unconfirmed",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "recurring",
|
|
|
|
href: "/bookings/recurring",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "past",
|
|
|
|
href: "/bookings/past",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "cancelled",
|
|
|
|
href: "/bookings/cancelled",
|
|
|
|
},
|
|
|
|
];
|
2022-09-22 07:48:27 +00:00
|
|
|
const validStatuses = ["upcoming", "recurring", "past", "cancelled", "unconfirmed"] as const;
|
2022-08-24 20:18:42 +00:00
|
|
|
|
feat: Organizations (#8993)
* Initial commit
* Adding feature flag
* feat: Orgs Schema Changing `scopedMembers` to `orgUsers` (#9209)
* Change scopedMembers to orgMembers
* Change to orgUsers
* Letting duplicate slugs for teams to support orgs
* Covering null on unique clauses
* Supporting having the orgId in the session cookie
* feat: organization event type filter (#9253)
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Missing changes to support orgs schema changes
* feat: Onboarding process to create an organization (#9184)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Making sure we check requestedSlug now
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* feat: [CAL-1816] Organization subdomain support (#9345)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* Covering users and subteams, excluding non-org users
* Unpublished teams shows correctly
* Create subdomain in Vercel
* feedback
* Renaming Vercel env vars
* Vercel domain check before creation
* Supporting cal-staging.com
* Change to have vercel detect it
* vercel domain check data message error
* Remove check domain
* Making sure we check requestedSlug now
* Feedback and unneeded code
* Reverting unneeded changes
* Unneeded changes
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Vercel subdomain creation in PROD only
* Making sure we let localhost still work
* Feedback
* Type check fixes
* feat: Organization branding in side menu (#9279)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Org branding provider used in shell sidebar
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Using org avatar (temp)
* Not showing org logo if not set
* User onboarding with org branding (slug)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Feedback
* Org public profile
* Public profiles for team event types
* Added setup profile alert
* Using org avatar on subteams avatar
* Making sure we show the set up profile on org only
* Profile username availability rely on org hook
* Update apps/web/pages/team/[slug].tsx
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Update apps/web/pages/team/[slug].tsx
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* feat: Organization support for event types page (#9449)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Org branding provider used in shell sidebar
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Using org avatar (temp)
* Not showing org logo if not set
* User onboarding with org branding (slug)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Feedback
* Org public profile
* Public profiles for team event types
* Added setup profile alert
* Using org avatar on subteams avatar
* Processing orgs and children as profile options
* Reverting change not belonging to this PR
* Making sure we show the set up profile on org only
* Removing console.log
* Comparing memberships to choose the highest one
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Type errors
* Refactor and type fixes
* Update orgDomains.ts
* Feedback
* Reverting
* NIT
* fix issue getting org slug from domain
* Improving orgDomains util
* Host comes with port
* Update useRouterQuery.ts
* Feedback
* Feedback
* Feedback
* Feedback: SSR for user event-types to have org context
* chore: Cache node_modules (#9492)
* Adding check for cache hit
* Adding a separate install step first
* Put the restore cache steps back
* Revert the uses type for restoring cache
* Added step to restore nm cache
* Removed the cache-hit check
* Comments and naming
* Removed extra install command
* Updated the name of the linting step to be more clear
* Removes the need for useEffect here
* Feedback
* Feedback
* Cookie domain needs a dot
* Type fix
* Update apps/web/public/static/locales/en/common.json
Co-authored-by: Omar López <zomars@me.com>
* Update packages/emails/src/templates/OrganizationAccountVerifyEmail.tsx
* Feedback
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: Efraín Rochín <roae.85@gmail.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
2023-06-14 21:40:20 +00:00
|
|
|
const descriptionByStatus: Record<NonNullable<BookingListingStatus>, string> = {
|
2022-08-24 20:18:42 +00:00
|
|
|
upcoming: "upcoming_bookings",
|
|
|
|
recurring: "recurring_bookings",
|
|
|
|
past: "past_bookings",
|
|
|
|
cancelled: "cancelled_bookings",
|
2022-09-22 07:48:27 +00:00
|
|
|
unconfirmed: "unconfirmed_bookings",
|
2022-08-24 20:18:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const querySchema = z.object({
|
|
|
|
status: z.enum(validStatuses),
|
|
|
|
});
|
|
|
|
|
|
|
|
export default function Bookings() {
|
2023-08-02 09:35:48 +00:00
|
|
|
const params = useParamsWithFallback();
|
2022-12-22 12:35:01 +00:00
|
|
|
const { data: filterQuery } = useFilterQuery();
|
2023-08-02 09:35:48 +00:00
|
|
|
const { status } = params ? querySchema.parse(params) : { status: "upcoming" as const };
|
2022-08-24 20:18:42 +00:00
|
|
|
const { t } = useLocale();
|
|
|
|
|
2022-11-10 23:40:01 +00:00
|
|
|
const query = trpc.viewer.bookings.get.useInfiniteQuery(
|
2022-12-22 12:35:01 +00:00
|
|
|
{
|
|
|
|
limit: 10,
|
|
|
|
filters: {
|
|
|
|
...filterQuery,
|
|
|
|
status: filterQuery.status ?? status,
|
|
|
|
},
|
|
|
|
},
|
2022-11-10 23:40:01 +00:00
|
|
|
{
|
|
|
|
// first render has status `undefined`
|
2023-08-02 09:35:48 +00:00
|
|
|
enabled: true,
|
2022-11-10 23:40:01 +00:00
|
|
|
getNextPageParam: (lastPage) => lastPage.nextCursor,
|
|
|
|
}
|
|
|
|
);
|
2022-08-24 20:18:42 +00:00
|
|
|
|
2022-09-12 10:15:30 +00:00
|
|
|
// Animate page (tab) tranistions to look smoothing
|
2022-10-20 05:09:52 +00:00
|
|
|
|
2022-08-24 20:18:42 +00:00
|
|
|
const buttonInView = useInViewObserver(() => {
|
|
|
|
if (!query.isFetching && query.hasNextPage && query.status === "success") {
|
|
|
|
query.fetchNextPage();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const isEmpty = !query.data?.pages[0]?.bookings.length;
|
|
|
|
|
|
|
|
const shownBookings: Record<string, BookingOutput[]> = {};
|
|
|
|
const filterBookings = (booking: BookingOutput) => {
|
2022-10-06 19:23:22 +00:00
|
|
|
if (status === "recurring" || status == "unconfirmed" || status === "cancelled") {
|
2022-08-24 20:18:42 +00:00
|
|
|
if (!booking.recurringEventId) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (
|
|
|
|
shownBookings[booking.recurringEventId] !== undefined &&
|
|
|
|
shownBookings[booking.recurringEventId].length > 0
|
|
|
|
) {
|
|
|
|
shownBookings[booking.recurringEventId].push(booking);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
shownBookings[booking.recurringEventId] = [booking];
|
2023-02-03 22:03:35 +00:00
|
|
|
} else if (status === "upcoming") {
|
|
|
|
return new Date(booking.startTime).toDateString() !== new Date().toDateString();
|
2022-08-24 20:18:42 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
};
|
2022-09-12 10:15:30 +00:00
|
|
|
|
2022-12-02 10:08:12 +00:00
|
|
|
let recurringInfoToday: RecurringInfo | undefined;
|
|
|
|
|
|
|
|
const bookingsToday =
|
|
|
|
query.data?.pages.map((page) =>
|
|
|
|
page.bookings.filter((booking: BookingOutput) => {
|
|
|
|
recurringInfoToday = page.recurringInfo.find(
|
|
|
|
(info) => info.recurringEventId === booking.recurringEventId
|
|
|
|
);
|
|
|
|
return new Date(booking.startTime).toDateString() === new Date().toDateString();
|
|
|
|
})
|
|
|
|
)[0] || [];
|
|
|
|
|
2022-10-20 05:09:52 +00:00
|
|
|
const [animationParentRef] = useAutoAnimate<HTMLDivElement>();
|
2022-09-12 10:15:30 +00:00
|
|
|
|
2022-08-24 20:18:42 +00:00
|
|
|
return (
|
2023-08-09 22:54:51 +00:00
|
|
|
<ShellMain hideHeadingOnMobile heading={t("bookings")} subtitle={t("bookings_description")}>
|
|
|
|
<div className="flex flex-col">
|
|
|
|
<div className="flex flex-col flex-wrap lg:flex-row">
|
|
|
|
<HorizontalTabs tabs={tabs} />
|
|
|
|
<div className="max-w-full overflow-x-auto xl:ml-auto">
|
|
|
|
<FiltersContainer />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<main className="w-full">
|
|
|
|
<div className="flex w-full flex-col" ref={animationParentRef}>
|
|
|
|
{query.status === "error" && (
|
|
|
|
<Alert severity="error" title={t("something_went_wrong")} message={query.error.message} />
|
|
|
|
)}
|
|
|
|
{(query.status === "loading" || query.isPaused) && <SkeletonLoader />}
|
|
|
|
{query.status === "success" && !isEmpty && (
|
|
|
|
<>
|
|
|
|
{!!bookingsToday.length && status === "upcoming" && (
|
|
|
|
<div className="mb-6 pt-2 xl:pt-0">
|
|
|
|
<WipeMyCalActionButton bookingStatus={status} bookingsEmpty={isEmpty} />
|
|
|
|
<p className="text-subtle mb-2 text-xs font-medium uppercase leading-4">{t("today")}</p>
|
|
|
|
<div className="border-subtle overflow-hidden rounded-md border">
|
|
|
|
<table className="w-full max-w-full table-fixed">
|
|
|
|
<tbody className="bg-default divide-subtle divide-y" data-testid="today-bookings">
|
|
|
|
<Fragment>
|
|
|
|
{bookingsToday.map((booking: BookingOutput) => (
|
|
|
|
<BookingListItem
|
|
|
|
key={booking.id}
|
|
|
|
listingStatus={status}
|
|
|
|
recurringInfo={recurringInfoToday}
|
|
|
|
{...booking}
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</Fragment>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
<div className="pt-2 xl:pt-0">
|
|
|
|
<div className="border-subtle overflow-hidden rounded-md border">
|
2023-08-25 09:55:41 +00:00
|
|
|
<table data-testid={`${status}-bookings`} className="w-full max-w-full table-fixed">
|
2023-08-09 22:54:51 +00:00
|
|
|
<tbody className="bg-default divide-subtle divide-y" data-testid="bookings">
|
|
|
|
{query.data.pages.map((page, index) => (
|
|
|
|
<Fragment key={index}>
|
|
|
|
{page.bookings.filter(filterBookings).map((booking: BookingOutput) => {
|
|
|
|
const recurringInfo = page.recurringInfo.find(
|
|
|
|
(info) => info.recurringEventId === booking.recurringEventId
|
|
|
|
);
|
|
|
|
return (
|
|
|
|
<BookingListItem
|
|
|
|
key={booking.id}
|
|
|
|
listingStatus={status}
|
|
|
|
recurringInfo={recurringInfo}
|
|
|
|
{...booking}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</Fragment>
|
2022-12-02 10:08:12 +00:00
|
|
|
))}
|
2023-08-09 22:54:51 +00:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div className="text-default p-4 text-center" ref={buttonInView.ref}>
|
|
|
|
<Button
|
|
|
|
color="minimal"
|
|
|
|
loading={query.isFetchingNextPage}
|
|
|
|
disabled={!query.hasNextPage}
|
|
|
|
onClick={() => query.fetchNextPage()}>
|
|
|
|
{query.hasNextPage ? t("load_more_results") : t("no_more_results")}
|
|
|
|
</Button>
|
|
|
|
</div>
|
2022-12-02 10:08:12 +00:00
|
|
|
</div>
|
2023-08-09 22:54:51 +00:00
|
|
|
</>
|
2022-12-02 10:08:12 +00:00
|
|
|
)}
|
2023-08-09 22:54:51 +00:00
|
|
|
{query.status === "success" && isEmpty && (
|
|
|
|
<div className="flex items-center justify-center pt-2 xl:pt-0">
|
|
|
|
<EmptyScreen
|
|
|
|
Icon={Calendar}
|
|
|
|
headline={t("no_status_bookings_yet", { status: t(status).toLowerCase() })}
|
|
|
|
description={t("no_status_bookings_yet_description", {
|
|
|
|
status: t(status).toLowerCase(),
|
|
|
|
description: t(descriptionByStatus[status]),
|
|
|
|
})}
|
|
|
|
/>
|
2022-12-02 10:08:12 +00:00
|
|
|
</div>
|
2023-08-09 22:54:51 +00:00
|
|
|
)}
|
2022-08-24 20:18:42 +00:00
|
|
|
</div>
|
2023-08-09 22:54:51 +00:00
|
|
|
</main>
|
2022-08-24 20:18:42 +00:00
|
|
|
</div>
|
2023-08-09 22:54:51 +00:00
|
|
|
</ShellMain>
|
2022-08-24 20:18:42 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-04-18 18:45:32 +00:00
|
|
|
Bookings.PageWrapper = PageWrapper;
|
2023-08-09 22:54:51 +00:00
|
|
|
Bookings.getLayout = getLayout;
|
2023-04-18 18:45:32 +00:00
|
|
|
|
2022-12-07 20:53:44 +00:00
|
|
|
export const getStaticProps: GetStaticProps = async (ctx) => {
|
2022-08-24 20:18:42 +00:00
|
|
|
const params = querySchema.safeParse(ctx.params);
|
2022-12-07 20:53:44 +00:00
|
|
|
const ssg = await ssgInit(ctx);
|
2022-08-24 20:18:42 +00:00
|
|
|
|
|
|
|
if (!params.success) return { notFound: true };
|
|
|
|
|
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
status: params.data.status,
|
2022-12-07 20:53:44 +00:00
|
|
|
trpcState: ssg.dehydrate(),
|
2022-08-24 20:18:42 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getStaticPaths: GetStaticPaths = () => {
|
|
|
|
return {
|
|
|
|
paths: validStatuses.map((status) => ({
|
|
|
|
params: { status },
|
|
|
|
locale: "en",
|
|
|
|
})),
|
|
|
|
fallback: "blocking",
|
|
|
|
};
|
|
|
|
};
|