1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-09-25 00:21:28 +02:00

Clear chat only visible when there is chat

This commit is contained in:
Kamran Ahmed
2025-05-27 02:56:02 +01:00
parent f9584cae3c
commit 6af820bb71
2 changed files with 11 additions and 7 deletions

View File

@@ -11,7 +11,7 @@ function AIChatActionButton(props: AIChatActionButtonProps) {
return (
<button
className="flex hover:bg-gray-100 items-center gap-1 rounded-md border border-gray-200 px-2 py-1.5 text-xs"
className="flex items-center gap-1 rounded-md border border-gray-200 px-2 py-1.5 text-xs hover:bg-gray-100"
onClick={onClick}
>
<Icon className="size-3" />
@@ -23,10 +23,11 @@ function AIChatActionButton(props: AIChatActionButtonProps) {
type AIChatActionButtonsProps = {
onTellUsAboutYourSelf: () => void;
onClearChat: () => void;
messageCount: number;
};
export function AIChatActionButtons(props: AIChatActionButtonsProps) {
const { onTellUsAboutYourSelf, onClearChat } = props;
const { onTellUsAboutYourSelf, onClearChat, messageCount } = props;
return (
<div className="flex gap-2 px-4 pt-2">
@@ -35,11 +36,13 @@ export function AIChatActionButtons(props: AIChatActionButtonsProps) {
label="Tell us about your self"
onClick={onTellUsAboutYourSelf}
/>
<AIChatActionButton
icon={Trash2}
label="Clear chat"
onClick={onClearChat}
/>
{messageCount > 0 && (
<AIChatActionButton
icon={Trash2}
label="Clear chat"
onClick={onClearChat}
/>
)}
</div>
);
}

View File

@@ -543,6 +543,7 @@ export function RoadmapAIChat(props: RoadmapAIChatProps) {
{!isLimitExceeded && (
<AIChatActionButtons
onTellUsAboutYourSelf={() => {}}
messageCount={aiChatHistory.length}
onClearChat={() => {
setAiChatHistory([]);
}}