'use client'
import React, { useState } from 'react'
import useSWR from 'swr'
import {
  ChevronDownIcon,
  ChevronUpIcon,
} from '@heroicons/react/24/outline'
import { fetchHistories } from '@/models/history'
import type { History as HistoryItem } from '@/models/history'
import Loading from '@/app/components/base/loading'
import { mockAPI } from '@/test/test_util'
mockAPI()
export type IHistoryProps = {
  dictionary: any
}
const HistoryCard = (
  { history }: { history: HistoryItem },
) => {
  return (
    
      
        {history.source}
      
      
      
        {history.target}
      
     
  )
}
const History = ({
  dictionary,
}: IHistoryProps) => {
  const { data, error } = useSWR('http://localhost:3000/api/histories', fetchHistories)
  const [showHistory, setShowHistory] = useState(false)
  const DivideLine = () => {
    return 
      {/* divider line */}
      
      
        {!showHistory ? 
 : 
}
        
{dictionary.app.textGeneration.history}
        {!showHistory ? 
 : 
}
      
failed to load
  if (!data)
    return 
  return showHistory
    ?  setShowHistory(v => !v)
    }>
      
      
        {data.histories.map((item: HistoryItem) =>
          )}