11"use client" ;
22
3+ import { useChatHistoryContext } from "@/(docs)/@docs/[lang]/[pageId]/chatHistory" ;
34import { ChatAreaStateUpdater } from "@/(docs)/chatAreaState" ;
4- import { getChatOne } from "@/lib/chatHistory" ;
5+ import { deleteChatAction } from "@/actions/deleteChat" ;
6+ import { ChatWithMessages } from "@/lib/chatHistory" ;
57import { LanguageEntry , MarkdownSection , PageEntry } from "@/lib/docs" ;
68import { Heading } from "@/markdown/heading" ;
79import { StyledMarkdown } from "@/markdown/markdown" ;
@@ -10,7 +12,7 @@ import Link from "next/link";
1012
1113interface Props {
1214 chatId : string ;
13- chatData : Awaited < ReturnType < typeof getChatOne > > ;
15+ chatData : ChatWithMessages ;
1416 targetLang : LanguageEntry | undefined ;
1517 targetPage : PageEntry | undefined ;
1618 targetSection : MarkdownSection | undefined ;
@@ -26,6 +28,10 @@ export function ChatAreaContent(props: Props) {
2628 ( a , b ) => new Date ( a . createdAt ) . getTime ( ) - new Date ( b . createdAt ) . getTime ( )
2729 ) ;
2830
31+ // useChatHistoryContext must be used within a ChatHistoryProvider
32+ // const { deleteChat } = useChatHistoryContext();
33+
34+
2935 return (
3036 < aside
3137 className = { clsx (
@@ -89,7 +95,12 @@ export function ChatAreaContent(props: Props) {
8995 </ div >
9096 < button
9197 className = "btn btn-error btn-soft btn-sm"
92- onClick = { ( ) => alert ( "TODO: チャットの削除機能" ) }
98+ onClick = { async ( ) => {
99+ if ( confirm ( "このチャットを削除してもよろしいですか?" ) ) {
100+ await deleteChatAction ( chatId ) ;
101+ // deleteChat(chatId);
102+ }
103+ } }
93104 >
94105 { /*<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->*/ }
95106 < svg
0 commit comments