* refactor(holidays): improve code quality and address PR review feedback
- Move HolidaysView.tsx from /features to /apps/web/modules following
the pattern of keeping trpc-using components in /apps/web/modules
- Fix prisma import to use named import: `import { prisma }`
- Fix timezone bug in checkConflicts: use dayjs.utc() for consistent
date boundaries regardless of server timezone
- Fix toggleHoliday validation to include both current and next year
holidays, matching the holidays displayed to users
- Implement dependency injection pattern for holiday repository:
- Create PrismaHolidayRepository with instance methods
- Add HOLIDAY_REPOSITORY DI token and module
- Update containers to load holiday repository module
- Update calculateHolidayBlockedDates to use injected repository
- Remove stale HOLIDAY_CACHE_DAYS env declaration (now a constant)
- Update tests to mock repository instead of prisma directly
* feat(holidays): improve UI responsiveness and add country flags
- Add country flag emojis to holidays dropdown using Unicode regional
indicator symbols
- Handle edge cases for religious holidays (Hindu, Christian, etc.)
which dont have 2-letter country codes
- Increase country dropdown width to 180px for better readability
- Make OOO/Holidays tabs responsive: use Select dropdown on mobile,
ToggleGroup on desktop
- Make + Add button responsive: show only + icon on mobile,
full text on desktop
- Fix PrismaHolidayRepository import to use @calcom/prisma for
consistency with other repositories
* feat(holidays): add contextual emojis for holidays
- Add keyword-based emoji mapping for 80+ holidays
- Display holiday emojis in styled containers on settings page
- Add country flag emojis to dropdown using Unicode regional indicators
- Use dynamic emojis on booking page unavailable dates
* fix(holidays): address PR review feedback
- Fix emoji ordering: move Chinese/Lunar New Year before generic new year to prevent incorrect match
- Fix i18n: use t() instead of hardcoded text more in conflict warning
- Fix a11y: use sr-only pattern for mobile button to maintain screen reader accessibility
* fix failing test: packages/features/availability/lib/calculateHolidayBlockedDates.test.ts
* fix failing test: packages/features/availability/lib/calculateHolidayBlockedDates.test.ts
* fix failing tests and builds
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
"use client";
|
|
|
|
import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";
|
|
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { trpc } from "@calcom/trpc/react";
|
|
import useMeQuery from "@calcom/trpc/react/hooks/useMeQuery";
|
|
import type { ButtonProps } from "@calcom/ui/components/button";
|
|
import { Button } from "@calcom/ui/components/button";
|
|
|
|
import { OutOfOfficeTab } from "./OutOfOfficeToggleGroup";
|
|
|
|
const CreateNewOutOfOfficeEntryButton = ({
|
|
size,
|
|
onClick,
|
|
...rest
|
|
}: {
|
|
size?: ButtonProps["size"];
|
|
onClick: () => void;
|
|
"data-testid"?: string;
|
|
}) => {
|
|
const { t } = useLocale();
|
|
const me = useMeQuery();
|
|
const { data: orgData } = trpc.viewer.organizations.listCurrent.useQuery();
|
|
const isOrgAdminOrOwner = orgData && checkAdminOrOwner(orgData.user.role);
|
|
const hasTeamOOOAdminAccess = isOrgAdminOrOwner || me?.data?.isTeamAdminOrOwner;
|
|
|
|
const params = useCompatSearchParams();
|
|
const selectedTab = params?.get("type") ?? OutOfOfficeTab.MINE;
|
|
|
|
return (
|
|
<Button
|
|
color="primary"
|
|
size={size ?? "base"}
|
|
className="flex items-center justify-between px-2 md:px-4"
|
|
StartIcon="plus"
|
|
onClick={onClick}
|
|
data-testid={rest["data-testid"]}
|
|
disabled={selectedTab === OutOfOfficeTab.TEAM && !hasTeamOOOAdminAccess}>
|
|
<span className="sr-only md:not-sr-only md:inline">{t("add")}</span>
|
|
</Button>
|
|
);
|
|
};
|
|
|
|
export default CreateNewOutOfOfficeEntryButton;
|