-
-
- {item?.reason?.emoji || "🏝️"}
-
-
-
-
- {dayjs.utc(item.start).format("ll")} - {dayjs.utc(item.end).format("ll")}
-
-
- {item.toUser?.username ? (
- ,
- }}
- />
- ) : (
- <>{t("ooo_not_forwarding")}>
- )}
-
- {item.notes && (
-
- {t("notes")}:
-
- {item.notes}
-
-
- )}
-
+ }),
+ columnHelper.display({
+ id: "actions",
+ size: 90,
+ cell: ({ row }) => {
+ const item = row.original;
+ return (
+ <>
+ {row.original && !isPending && !isFetching ? (
+
+
+
+
+
-
- ) : (
-
- )}
- >
- );
- },
- });
- columns.push({
- id: "actions",
- size: 90,
- cell: ({ row }) => {
- const item = row.original;
- return (
- <>
- {row.original && !isPending && !isFetching ? (
-
-
-
-
-
-
- ) : (
-
- )}
- >
- );
- },
- });
- return columns;
+ ) : (
+
+ )}
+ >
+ );
+ },
+ }),
+ ];
}, [selectedTab, isPending, isFetching]);
- const fetchMoreOnBottomReached = useCallback(
- (containerRefElement?: HTMLDivElement | null) => {
- if (containerRefElement) {
- const { scrollHeight, scrollTop, clientHeight } = containerRefElement;
- if (scrollHeight - scrollTop - clientHeight < 100 && !isFetching && totalFetched < totalRowCount) {
- fetchNextPage();
- }
- if (isFetching) {
- containerRefElement.classList.add("cursor-wait");
- } else {
- containerRefElement.classList.remove("cursor-wait");
- }
- }
- },
- [fetchNextPage, isFetching, totalFetched, totalRowCount]
- );
-
const table = useReactTable({
data: flatData,
columns: memoColumns,
+ initialState: {
+ columnVisibility: {
+ dateRange: false,
+ },
+ },
enableRowSelection: false,
- debugTable: true,
manualPagination: true,
getCoreRowModel: getCoreRowModel(),
+ getFilteredRowModel: getFilteredRowModel(),
});
- useEffect(() => {
- fetchMoreOnBottomReached(tableContainerRef.current);
- }, [fetchMoreOnBottomReached]);
-
const deleteOutOfOfficeEntryMutation = trpc.viewer.outOfOfficeEntryDelete.useMutation({
onSuccess: () => {
showToast(t("success_deleted_entry_out_of_office"), "success");
@@ -300,60 +327,67 @@ export const OutOfOfficeEntriesList = () => {
return (
<>
- {data === null ||
- (data?.pages?.length !== 0 && data?.pages[0].meta.totalRowCount === 0 && searchTerm === "") ||
- (data === undefined && !isPending) ? (
-
}
- customIcon={
-
-
-
-
-
-
-
-
-
z
+
setSearchTerm(value)} />}
+ ToolbarRight={
+ <>
+
+
+
+ >
+ }
+ EmptyView={
+ }
+ customIcon={
+
-
- }
+ }
+ />
+ }
+ />
+ {openModal && (
+
{
+ setOpenModal(false);
+ setCurrentlyEditingOutOfOfficeEntry(null);
+ }}
+ currentlyEditingOutOfOfficeEntry={currentlyEditingOutOfOfficeEntry}
/>
- ) : (
-
- fetchMoreOnBottomReached(e.target as HTMLDivElement)}>
-
- setSearchTerm(value)} />
-
-
- {openModal && (
- {
- setOpenModal(false);
- setCurrentlyEditingOutOfOfficeEntry(null);
- }}
- currentlyEditingOutOfOfficeEntry={currentlyEditingOutOfOfficeEntry}
- />
- )}
-
)}
>
);
-};
+}
diff --git a/packages/trpc/server/routers/loggedInViewer/outOfOfficeEntriesList.handler.ts b/packages/trpc/server/routers/loggedInViewer/outOfOfficeEntriesList.handler.ts
index 00e1b3a57c..8689205ccb 100644
--- a/packages/trpc/server/routers/loggedInViewer/outOfOfficeEntriesList.handler.ts
+++ b/packages/trpc/server/routers/loggedInViewer/outOfOfficeEntriesList.handler.ts
@@ -16,7 +16,14 @@ type GetOptions = {
export const outOfOfficeEntriesList = async ({ ctx, input }: GetOptions) => {
const t = await getTranslation(ctx.user.locale, "common");
- const { cursor, limit, fetchTeamMembersEntries, searchTerm } = input;
+ const {
+ cursor,
+ limit,
+ fetchTeamMembersEntries,
+ searchTerm,
+ endDateFilterStartRange,
+ endDateFilterEndRange,
+ } = input;
let fetchOOOEntriesForIds = [ctx.user.id];
let reportingUserIds = [0];
@@ -76,7 +83,8 @@ export const outOfOfficeEntriesList = async ({ ctx, input }: GetOptions) => {
in: fetchOOOEntriesForIds,
},
end: {
- gte: new Date().toISOString(),
+ gte: endDateFilterStartRange ?? new Date().toISOString(),
+ lte: endDateFilterEndRange,
},
...(searchTerm
? {
diff --git a/packages/trpc/server/routers/loggedInViewer/outOfOfficeEntriesList.schema.ts b/packages/trpc/server/routers/loggedInViewer/outOfOfficeEntriesList.schema.ts
index 72b76b7e1f..f06bef177d 100644
--- a/packages/trpc/server/routers/loggedInViewer/outOfOfficeEntriesList.schema.ts
+++ b/packages/trpc/server/routers/loggedInViewer/outOfOfficeEntriesList.schema.ts
@@ -5,6 +5,8 @@ export const ZOutOfOfficeEntriesListSchema = z.object({
cursor: z.number().nullish(),
fetchTeamMembersEntries: z.boolean().optional().default(false),
searchTerm: z.string().optional(),
+ endDateFilterStartRange: z.string().optional(),
+ endDateFilterEndRange: z.string().optional(),
});
export type TOutOfOfficeEntriesListSchema = z.infer;