feat: implement booking calendar view with weekly layout (#24563)
* feat: implement booking calendar view with weekly layout - Create reusable WeekCalendarView component that displays bookings in a weekly calendar format - Replace EmptyScreen in BookingsCalendar with the new calendar view - Calendar view includes: - Week navigation with Today, Previous, and Next buttons - 7-day week view with time slots from 12 AM to 11 PM - Bookings displayed as colored blocks positioned by time - Support for event type colors and status-based colors - Responsive design that fills the viewport - Hover tooltips showing booking details - Filters remain functional at the top of the view Co-Authored-By: [email protected] <[email protected]> * refactor: use existing Calendar component from weeklyview - Replace custom calendar implementation with the existing Calendar component - Use parseEventTypeColor to properly handle event type colors - Simplify implementation by leveraging existing calendar infrastructure - Maintain week navigation and filtering functionality Co-Authored-By: [email protected] <[email protected]> * fix imports * fix: replace isSameOrAfter with isAfter || isSame - isSameOrAfter method does not exist in dayjs - Use combination of isAfter and isSame instead Co-Authored-By: [email protected] <[email protected]> * remove useBookerTime dependency from weekly calendar view * modify date range filters * initial callback * sort events * clean up FilterBar * add showBackgroundPattern * update styles * update style * update styles * fix type error * fix error * update styles * update styles * update event colors * rename component * persist weekStart on the url * use FilterBar * apply feedback * extract BorderColor type * use client * clean up * adjust styles * color-code events * rename borderColor to color * restore class name * add feature flag * update class name --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
8d4dd0241a
commit
f00c14d0c1
26 files changed
+421
-120
No files matched your search
@@ -1,8 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { type Table } from "@tanstack/react-table";
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import { Fragment } from "react";
|
||||
|
||||
import { useDataTable, useFilterableColumns } from "../../hooks";
|
||||
import { ColumnFilterType } from "../../lib/types";
|
||||
@@ -12,9 +10,10 @@ import { FilterPopover } from "./FilterPopover";
|
||||
// Add the new ActiveFilters component
|
||||
interface ActiveFiltersProps<TData> {
|
||||
table: Table<TData>;
|
||||
columnIdsToHide?: string[];
|
||||
}
|
||||
|
||||
export function ActiveFilters<TData>({ table }: ActiveFiltersProps<TData>) {
|
||||
export function ActiveFilters<TData>({ table, columnIdsToHide }: ActiveFiltersProps<TData>) {
|
||||
const { activeFilters } = useDataTable();
|
||||
const filterableColumns = useFilterableColumns(table);
|
||||
|
||||
@@ -22,7 +21,12 @@ export function ActiveFilters<TData>({ table }: ActiveFiltersProps<TData>) {
|
||||
<>
|
||||
{activeFilters.map((filter) => {
|
||||
const column = filterableColumns.find((col) => col.id === filter.f);
|
||||
if (!column) return null;
|
||||
if (!column) {
|
||||
return null;
|
||||
}
|
||||
if (columnIdsToHide?.includes(column.id)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (column.type === ColumnFilterType.DATE_RANGE) {
|
||||
return (
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { type Table } from "@tanstack/react-table";
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import startCase from "lodash/startCase";
|
||||
import { forwardRef, useState } from "react";
|
||||
|
||||
@@ -17,17 +16,10 @@ import { useDataTable, useFilterableColumns } from "../../hooks";
|
||||
export interface AddFilterButtonProps<TData> {
|
||||
table: Table<TData>;
|
||||
variant?: "base" | "sm";
|
||||
hideWhenFilterApplied?: boolean;
|
||||
showWhenFilterApplied?: boolean;
|
||||
}
|
||||
|
||||
function AddFilterButtonComponent<TData>(
|
||||
{
|
||||
table,
|
||||
variant = "base",
|
||||
hideWhenFilterApplied = false,
|
||||
showWhenFilterApplied = false,
|
||||
}: AddFilterButtonProps<TData>,
|
||||
{ table, variant = "base" }: AddFilterButtonProps<TData>,
|
||||
ref: React.Ref<HTMLButtonElement>
|
||||
) {
|
||||
const { t } = useLocale();
|
||||
@@ -39,14 +31,6 @@ function AddFilterButtonComponent<TData>(
|
||||
(column) => !activeFilters?.some((filter) => filter.f === column.id)
|
||||
);
|
||||
|
||||
if (hideWhenFilterApplied && activeFilters?.length > 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (showWhenFilterApplied && activeFilters?.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (variant === "sm" && availableColumns.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,30 @@
|
||||
import { type Table } from "@tanstack/react-table";
|
||||
"use client";
|
||||
|
||||
import { type Table } from "@tanstack/react-table";
|
||||
import { useMemo } from "react";
|
||||
|
||||
import { useDataTable } from "../../hooks";
|
||||
import { ActiveFilters } from "./ActiveFilters";
|
||||
import { AddFilterButton } from "./AddFilterButton";
|
||||
|
||||
interface FilterBarProps<TData> {
|
||||
table: Table<TData>;
|
||||
columnIdsToHide?: string[];
|
||||
}
|
||||
|
||||
export function FilterBar<TData>({ table }: FilterBarProps<TData>) {
|
||||
export function FilterBar<TData>({ table, columnIdsToHide }: FilterBarProps<TData>) {
|
||||
const { activeFilters } = useDataTable();
|
||||
const displayedFilterCount = useMemo(() => {
|
||||
return (activeFilters ?? []).filter((filter) =>
|
||||
columnIdsToHide ? !columnIdsToHide.includes(filter.f) : true
|
||||
).length;
|
||||
}, [activeFilters, columnIdsToHide]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<AddFilterButton table={table} hideWhenFilterApplied />
|
||||
<ActiveFilters table={table} />
|
||||
<AddFilterButton table={table} variant="sm" showWhenFilterApplied />
|
||||
{displayedFilterCount === 0 && <AddFilterButton table={table} />}
|
||||
<ActiveFilters table={table} columnIdsToHide={columnIdsToHide} />
|
||||
{displayedFilterCount > 0 && <AddFilterButton table={table} variant="sm" />}
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user