File size: 5,609 Bytes
f6f8d55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import { HtmlHistory } from "../../../utils/types";
import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover";
import { Button } from "../ui/button";

export default function History({
  history,
  setHtml,
}: {
  history: HtmlHistory[];
  setHtml: (html: string) => void;
}) {
  return (
    <Popover>
      <PopoverTrigger asChild>
        <Button variant="ghost" size="sm" className="max-lg:hidden">
          {history?.length} versions
        </Button>
      </PopoverTrigger>
      <PopoverContent
        className="!p-0 overflow-hidden !bg-neutral-900"
        align="start"
      >
        <header className="text-sm px-4 py-3 border-b gap-2 bg-neutral-950 border-neutral-800 font-semibold text-neutral-200">
          Version History
        </header>
        <main className="px-4 space-y-3">
          <ul className="max-h-[250px] overflow-y-auto">
            {history?.map((item, index) => (
              <li
                key={index}
                className="text-gray-300 text-xs py-2 border-b border-gray-800 last:border-0 flex items-center justify-between gap-2"
              >
                <div className="">
                  <span className="line-clamp-1">{item.prompt}</span>
                  <span className="text-gray-500 text-[10px]">
                    {new Date(item.createdAt).toLocaleDateString("en-US", {
                      month: "2-digit",
                      day: "2-digit",
                      year: "2-digit",
                    }) +
                      " " +
                      new Date(item.createdAt).toLocaleTimeString("en-US", {
                        hour: "2-digit",
                        minute: "2-digit",
                        second: "2-digit",
                        hour12: false,
                      })}
                  </span>
                </div>
                <button
                  className="bg-pink-500 text-white text-xs font-medium rounded-md px-2 py-1 transition-all duration-100 hover:bg-pink-600 cursor-pointer"
                  onClick={() => {
                    setHtml(item.html);
                  }}
                >
                  Select
                </button>
              </li>
            ))}
          </ul>
        </main>
      </PopoverContent>
    </Popover>
    // <div
    //         className="relative"
    //         onMouseEnter={() => setVisible(true)}
    //         onMouseLeave={() => setVisible(false)}
    //       >
    //         <button
    //           className={classNames(
    //             "text-gray-400 hover:text-gray-300 cursor-pointer text-sm nderline flex items-center justify-start gap-1",
    //             {
    //               "!text-gray-300": visible,
    //             }
    //           )}
    //         >
    //           <IoTimeOutline />
    //           {htmlHistory?.length} versions
    //         </button>
    //         <div
    //           className={classNames(
    //             "absolute bottom-0 left-0 min-w-sm w-full z-10 translate-y-full pt-2 transition-all duration-200",
    //             {
    //               "opacity-0 pointer-events-none": !visible,
    //             }
    //           )}
    //         >
    //           <div className="bg-gray-950 border border-gray-800 rounded-xl shadow-2xs p-4">
    //             <p className="text-xs font-bold text-white">Version History</p>
    //             <p className="text-gray-400 text-xs mt-1">
    //               This is a list of the full history of what AI has done to
    //               this.
    //             </p>
    //             <ul className="mt-2 max-h-[250px] overflow-y-auto">
    //               {htmlHistory?.map((item, index) => (
    //                 <li
    //                   key={index}
    //                   className="text-gray-300 text-xs py-2 border-b border-gray-800 last:border-0 flex items-center justify-between gap-2"
    //                 >
    //                   <div className="">
    //                     <span className="line-clamp-1">{item.prompt}</span>
    //                     <span className="text-gray-500 text-[10px]">
    //                       {new Date(item.createdAt).toLocaleDateString(
    //                         "en-US",
    //                         {
    //                           month: "2-digit",
    //                           day: "2-digit",
    //                           year: "2-digit",
    //                         }
    //                       ) +
    //                         " " +
    //                         new Date(item.createdAt).toLocaleTimeString(
    //                           "en-US",
    //                           {
    //                             hour: "2-digit",
    //                             minute: "2-digit",
    //                             second: "2-digit",
    //                             hour12: false,
    //                           }
    //                         )}
    //                     </span>
    //                   </div>
    //                   <button
    //                     className="bg-pink-500 text-white text-xs font-medium rounded-md px-2 py-1 transition-all duration-100 hover:bg-pink-600 cursor-pointer"
    //                     onClick={() => {
    //                       setHtml(item.html);
    //                     }}
    //                   >
    //                     Select
    //                   </button>
    //                 </li>
    //               ))}
    //             </ul>
    //           </div>
    //         </div>
    //       </div>
  );
}