mirror of
https://github.com/MODSetter/SurfSense.git
synced 2025-09-01 18:19:08 +00:00
allow future events indexing for google calendar connector
This commit is contained in:
parent
07f42270a5
commit
d70ebf9669
2 changed files with 30 additions and 6 deletions
|
@ -40,6 +40,7 @@ import {
|
|||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { EnumConnectorName } from "@/contracts/enums/connector";
|
||||
import { useSearchSourceConnectors } from "@/hooks/useSearchSourceConnectors";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
|
@ -61,6 +62,7 @@ export default function ConnectorsPage() {
|
|||
const router = useRouter();
|
||||
const params = useParams();
|
||||
const searchSpaceId = params.search_space_id as string;
|
||||
const today = new Date();
|
||||
|
||||
const { connectors, isLoading, error, deleteConnector, indexConnector } =
|
||||
useSearchSourceConnectors();
|
||||
|
@ -139,6 +141,28 @@ export default function ConnectorsPage() {
|
|||
}
|
||||
};
|
||||
|
||||
const getDisabledEndDates = (date: Date) => {
|
||||
const connector = connectors.find((c) => c.id === selectedConnectorForIndexing);
|
||||
|
||||
switch (connector?.connector_type) {
|
||||
case EnumConnectorName.GOOGLE_CALENDAR_CONNECTOR:
|
||||
return startDate ? date < startDate : false;
|
||||
default:
|
||||
return date > today || (startDate ? date < startDate : false);
|
||||
}
|
||||
};
|
||||
|
||||
const getDisabledStartDates = (date: Date) => {
|
||||
const connector = connectors.find((c) => c.id === selectedConnectorForIndexing);
|
||||
|
||||
switch (connector?.connector_type) {
|
||||
case EnumConnectorName.GOOGLE_CALENDAR_CONNECTOR:
|
||||
return endDate ? date > endDate : false;
|
||||
default:
|
||||
return date > today || (endDate ? date > endDate : false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="container mx-auto py-8 max-w-6xl">
|
||||
<motion.div
|
||||
|
@ -342,7 +366,7 @@ export default function ConnectorsPage() {
|
|||
mode="single"
|
||||
selected={startDate}
|
||||
onSelect={setStartDate}
|
||||
disabled={(date) => date > new Date() || (endDate ? date > endDate : false)}
|
||||
disabled={getDisabledStartDates}
|
||||
initialFocus
|
||||
/>
|
||||
</PopoverContent>
|
||||
|
@ -369,9 +393,7 @@ export default function ConnectorsPage() {
|
|||
mode="single"
|
||||
selected={endDate}
|
||||
onSelect={setEndDate}
|
||||
disabled={(date) =>
|
||||
date > new Date() || (startDate ? date < startDate : false)
|
||||
}
|
||||
disabled={getDisabledEndDates}
|
||||
initialFocus
|
||||
/>
|
||||
</PopoverContent>
|
||||
|
@ -393,7 +415,6 @@ export default function ConnectorsPage() {
|
|||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
const today = new Date();
|
||||
const thirtyDaysAgo = new Date(today);
|
||||
thirtyDaysAgo.setDate(today.getDate() - 30);
|
||||
setStartDate(thirtyDaysAgo);
|
||||
|
@ -406,7 +427,6 @@ export default function ConnectorsPage() {
|
|||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
const today = new Date();
|
||||
const yearAgo = new Date(today);
|
||||
yearAgo.setFullYear(today.getFullYear() - 1);
|
||||
setStartDate(yearAgo);
|
||||
|
|
|
@ -10,6 +10,10 @@ export const getConnectorTypeDisplay = (type: string): string => {
|
|||
JIRA_CONNECTOR: "Jira",
|
||||
DISCORD_CONNECTOR: "Discord",
|
||||
LINKUP_API: "Linkup",
|
||||
CONFLUENCE_CONNECTOR: "Confluence",
|
||||
CLICKUP_CONNECTOR: "ClickUp",
|
||||
GOOGLE_CALENDAR_CONNECTOR: "Google Calendar",
|
||||
GOOGLE_GMAIL_CONNECTOR: "Google Gmail",
|
||||
};
|
||||
return typeMap[type] || type;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue