Skip to content

Commit

Permalink
Fix: Label for last 12 months (#8257)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraggle authored Oct 25, 2024
1 parent 8f0f275 commit 080f838
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions front/components/assistant/conversation/SidebarMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ type AssistantSidebarMenuProps = {
owner: WorkspaceType;
};

type GroupLabel =
| "Today"
| "Yesterday"
| "Last Week"
| "Last Month"
| "Last 12 Months"
| "Older";

export function AssistantSidebarMenu({ owner }: AssistantSidebarMenuProps) {
const router = useRouter();
const { setSidebarOpen } = useContext(SidebarContext);
Expand Down Expand Up @@ -122,12 +130,12 @@ export function AssistantSidebarMenu({ owner }: AssistantSidebarMenuProps) {
const lastMonth = moment().subtract(1, "months").startOf("day");
const lastYear = moment().subtract(1, "years").startOf("day");

const groups: { [key: string]: ConversationType[] } = {
const groups: Record<GroupLabel, ConversationType[]> = {
Today: [],
Yesterday: [],
"Last Week": [],
"Last Month": [],
"Last Year": [],
"Last 12 Months": [],
Older: [],
};

Expand All @@ -153,7 +161,7 @@ export function AssistantSidebarMenu({ owner }: AssistantSidebarMenuProps) {

const conversationsByDate = conversations.length
? groupConversationsByDate(conversations)
: {};
: ({} as Record<GroupLabel, ConversationType[]>);

const { setAnimate } = useContext(InputBarContext);

Expand Down Expand Up @@ -295,7 +303,8 @@ export function AssistantSidebarMenu({ owner }: AssistantSidebarMenuProps) {
)}
{conversationsByDate &&
Object.keys(conversationsByDate).map((dateLabel) => {
const conversations = conversationsByDate[dateLabel];
const conversations =
conversationsByDate[dateLabel as GroupLabel];
return (
conversations.length > 0 && (
<React.Fragment key={dateLabel}>
Expand Down

0 comments on commit 080f838

Please sign in to comment.