Skip to content

Commit

Permalink
Format Fix
Browse files Browse the repository at this point in the history
Signed-off-by: Sauradip Ghosh <[email protected]>
  • Loading branch information
Sauradip07 committed Aug 19, 2024
1 parent 95d6dad commit 7cb0220
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 90 deletions.
4 changes: 3 additions & 1 deletion src/frontend/components/chat-bottom-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ const ChatBottomBar = ({ onSend }: Props) => {
size="icon"
variant="default"
className={`rounded-full flex-shrink-0 transition-opacity duration-200 ${
message.content.trim() ? 'opacity-100' : 'opacity-50'
message.content.trim()
? 'opacity-100'
: 'opacity-50'
}`}
type="button"
onClick={handleSubmit}
Expand Down
42 changes: 21 additions & 21 deletions src/frontend/components/historyData.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
export const historyData = [
{
id: 1,
title: "What is hyperledge...",
},
{
id: 2,
title: "How to install hyperledger fabric",
},
{
id: 3,
title: "How to deploy hyperledger fabric",
},
{
id: 4,
title: "How to run hyperledger fabric",
},
{
id: 5,
title: "How to ensure data privacy",
},
];
{
id: 1,
title: 'What is hyperledge...'
},
{
id: 2,
title: 'How to install hyperledger fabric'
},
{
id: 3,
title: 'How to deploy hyperledger fabric'
},
{
id: 4,
title: 'How to run hyperledger fabric'
},
{
id: 5,
title: 'How to ensure data privacy'
}
];
156 changes: 88 additions & 68 deletions src/frontend/components/sidebarHistory.tsx
Original file line number Diff line number Diff line change
@@ -1,83 +1,103 @@
"use client";
import React, { useEffect, useState } from "react";
import { DropdownMenuCheckboxItemProps } from "@radix-ui/react-dropdown-menu";
import { Button } from "@/components/ui/button";
'use client';
import React, {
useEffect,
useState
} from 'react';
import { DropdownMenuCheckboxItemProps } from '@radix-ui/react-dropdown-menu';
import { Button } from '@/components/ui/button';
import {
DropdownMenu,
DropdownMenuCheckboxItem,
DropdownMenuContent,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { EllipsisVertical, Pencil, Pin, Trash2 } from "lucide-react";
DropdownMenu,
DropdownMenuCheckboxItem,
DropdownMenuContent,
DropdownMenuSeparator,
DropdownMenuTrigger
} from '@/components/ui/dropdown-menu';
import {
EllipsisVertical,
Pencil,
Pin,
Trash2
} from 'lucide-react';

// Import the mock data
import { historyData as mockHistoryData } from "./historyData";
import { historyData as mockHistoryData } from './historyData';

type Props = {};
type Checked = DropdownMenuCheckboxItemProps["checked"];
type Checked =
DropdownMenuCheckboxItemProps['checked'];

const SidebarHistory = (props: Props) => {
const [checkedItems, setCheckedItems] = useState<Record<number, Checked>>({});
const [historyData, setHistoryData] = useState<
{ id: number; title: string }[]
>([]);
const [checkedItems, setCheckedItems] =
useState<Record<number, Checked>>({});
const [historyData, setHistoryData] = useState<
{ id: number; title: string }[]
>([]);

useEffect(() => {
setHistoryData(mockHistoryData);
}, []);
useEffect(() => {
setHistoryData(mockHistoryData);
}, []);

const handleCheckedChange = (id: number) => {
setCheckedItems((prevCheckedItems) => ({
...prevCheckedItems,
[id]: !prevCheckedItems[id],
}));
};
const handleCheckedChange = (id: number) => {
setCheckedItems((prevCheckedItems) => ({
...prevCheckedItems,
[id]: !prevCheckedItems[id]
}));
};

const truncateTitle = (title: string) => {
return title.length > 17 ? title.slice(0, 17) + "..." : title;
};
const truncateTitle = (title: string) => {
return title.length > 17
? title.slice(0, 17) + '...'
: title;
};

return (
<div className="mt-10">
{historyData.map((item) => (
<div
key={item.id}
className="flex justify-between mt-1 p-3 border-none rounded-lg font-semibold bg-slate-800 hover:bg-slate-800 cursor-pointer">
<div className="my-auto overflow-hidden">
{truncateTitle(item.title)}
</div>
return (
<div className="mt-10">
{historyData.map((item) => (
<div
key={item.id}
className="flex justify-between mt-1 p-3 border-none rounded-lg font-semibold bg-slate-800 hover:bg-slate-800 cursor-pointer"
>
<div className="my-auto overflow-hidden">
{truncateTitle(item.title)}
</div>

<button>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="outline"
className="p-0 m-0 text-white bg-slate-800 hover:bg-slate-800 hover:text-white font-semibold border-none">
<EllipsisVertical />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-56">
<DropdownMenuSeparator />
<DropdownMenuCheckboxItem
checked={!!checkedItems[item.id]}
onCheckedChange={() => handleCheckedChange(item.id)}>
<Pin className="mr-2" /> Pin
</DropdownMenuCheckboxItem>
<DropdownMenuCheckboxItem>
<Pencil className="mr-2" />
Rename
</DropdownMenuCheckboxItem>
<DropdownMenuCheckboxItem>
<Trash2 className="mr-2" /> Delete
</DropdownMenuCheckboxItem>
</DropdownMenuContent>
</DropdownMenu>
</button>
</div>
))}
</div>
);
<button>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="outline"
className="p-0 m-0 text-white bg-slate-800 hover:bg-slate-800 hover:text-white font-semibold border-none"
>
<EllipsisVertical />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-56">
<DropdownMenuSeparator />
<DropdownMenuCheckboxItem
checked={
!!checkedItems[item.id]
}
onCheckedChange={() =>
handleCheckedChange(item.id)
}
>
<Pin className="mr-2" /> Pin
</DropdownMenuCheckboxItem>
<DropdownMenuCheckboxItem>
<Pencil className="mr-2" />
Rename
</DropdownMenuCheckboxItem>
<DropdownMenuCheckboxItem>
<Trash2 className="mr-2" />{' '}
Delete
</DropdownMenuCheckboxItem>
</DropdownMenuContent>
</DropdownMenu>
</button>
</div>
))}
</div>
);
};

export default SidebarHistory;

0 comments on commit 7cb0220

Please sign in to comment.