mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-09 07:42:39 +02:00
feat: enhance date range selector with last indexed timestamp for improved user context
This commit is contained in:
parent
71b0e02676
commit
0ba70401e9
3 changed files with 18 additions and 1 deletions
|
|
@ -15,6 +15,7 @@ interface DateRangeSelectorProps {
|
||||||
onStartDateChange: (date: Date | undefined) => void;
|
onStartDateChange: (date: Date | undefined) => void;
|
||||||
onEndDateChange: (date: Date | undefined) => void;
|
onEndDateChange: (date: Date | undefined) => void;
|
||||||
allowFutureDates?: boolean; // Allow future dates for calendar connectors
|
allowFutureDates?: boolean; // Allow future dates for calendar connectors
|
||||||
|
lastIndexedAt?: string | null; // Last sync timestamp to show in default placeholder
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DateRangeSelector: FC<DateRangeSelectorProps> = ({
|
export const DateRangeSelector: FC<DateRangeSelectorProps> = ({
|
||||||
|
|
@ -23,7 +24,21 @@ export const DateRangeSelector: FC<DateRangeSelectorProps> = ({
|
||||||
onStartDateChange,
|
onStartDateChange,
|
||||||
onEndDateChange,
|
onEndDateChange,
|
||||||
allowFutureDates = false,
|
allowFutureDates = false,
|
||||||
|
lastIndexedAt,
|
||||||
}) => {
|
}) => {
|
||||||
|
// Get the placeholder text for start date based on whether connector was previously indexed
|
||||||
|
const getStartDatePlaceholder = () => {
|
||||||
|
if (lastIndexedAt) {
|
||||||
|
const date = new Date(lastIndexedAt);
|
||||||
|
const currentYear = new Date().getFullYear();
|
||||||
|
const indexedYear = date.getFullYear();
|
||||||
|
// Show year only if different from current year
|
||||||
|
const formatStr = indexedYear === currentYear ? "MMM d, HH:mm" : "MMM d, yyyy HH:mm";
|
||||||
|
const formattedDate = format(date, formatStr);
|
||||||
|
return `Since (${formattedDate})`;
|
||||||
|
}
|
||||||
|
return "Default (1 year ago)";
|
||||||
|
};
|
||||||
const handleLast30Days = () => {
|
const handleLast30Days = () => {
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
onStartDateChange(subDays(today, 30));
|
onStartDateChange(subDays(today, 30));
|
||||||
|
|
@ -73,7 +88,7 @@ export const DateRangeSelector: FC<DateRangeSelectorProps> = ({
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<CalendarIcon className="mr-2 h-4 w-4" />
|
<CalendarIcon className="mr-2 h-4 w-4" />
|
||||||
{startDate ? format(startDate, "PPP") : "Default (1 year ago)"}
|
{startDate ? format(startDate, "PPP") : getStartDatePlaceholder()}
|
||||||
</Button>
|
</Button>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent className="w-auto p-0 z-[100]" align="start">
|
<PopoverContent className="w-auto p-0 z-[100]" align="start">
|
||||||
|
|
|
||||||
|
|
@ -227,6 +227,7 @@ export const ConnectorEditView: FC<ConnectorEditViewProps> = ({
|
||||||
connector.connector_type === "COMPOSIO_GOOGLE_CALENDAR_CONNECTOR" ||
|
connector.connector_type === "COMPOSIO_GOOGLE_CALENDAR_CONNECTOR" ||
|
||||||
connector.connector_type === "LUMA_CONNECTOR"
|
connector.connector_type === "LUMA_CONNECTOR"
|
||||||
}
|
}
|
||||||
|
lastIndexedAt={connector.last_indexed_at}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -165,6 +165,7 @@ export const IndexingConfigurationView: FC<IndexingConfigurationViewProps> = ({
|
||||||
config.connectorType === "COMPOSIO_GOOGLE_CALENDAR_CONNECTOR" ||
|
config.connectorType === "COMPOSIO_GOOGLE_CALENDAR_CONNECTOR" ||
|
||||||
config.connectorType === "LUMA_CONNECTOR"
|
config.connectorType === "LUMA_CONNECTOR"
|
||||||
}
|
}
|
||||||
|
lastIndexedAt={connector?.last_indexed_at}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue