feat(feedback): Add feedback view for companies and customers
This commit introduces the ability to view feedback associated with specific companies and customers directly from their respective tables. To support this, the `TenderFeedbackTable` has been refactored into a more generic `FeedbackTable` component. This new component accepts a `paramKey` prop (e.g., "tender_id", "company_id") to filter feedback for different entities. A new feedback icon has been added to the actions column in both the Companies and Customers tables, providing a direct link to the feedback page for each entry.
This commit is contained in:
@@ -1,85 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { ExclamationIcon } from "@/assets/icons";
|
||||
import { ShowcaseSection } from "@/components/Layouts/showcase-section";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
} from "@/components/ui/table";
|
||||
import TableSkeleton from "@/components/ui/TableSkeleton";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { unixToDate } from "@/utils/shared";
|
||||
import { TableRow } from "../../../ui/table";
|
||||
import useTenderFeedbackPresenter from "./useTenderFeedbackPresenter";
|
||||
|
||||
interface IProps {
|
||||
id: string;
|
||||
}
|
||||
|
||||
const TenderFeedbackTable = ({ id }: IProps) => {
|
||||
const { feedback, isLoading, columns, pathName, router } =
|
||||
useTenderFeedbackPresenter({ id });
|
||||
return (
|
||||
<ShowcaseSection
|
||||
title={!isLoading && `Tender: ${feedback?.[0].tender?.title}`}
|
||||
className="flex flex-col rounded-[10px] bg-white px-7.5 pb-4 pt-7.5 shadow-1 dark:bg-gray-dark dark:shadow-card"
|
||||
>
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
{columns.map((column) => (
|
||||
<TableHead className="capitalize" key={column} colSpan={100}>
|
||||
{column}
|
||||
</TableHead>
|
||||
))}
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
{isLoading && <TableSkeleton column={columns.length} />}
|
||||
<TableBody>
|
||||
{feedback?.map((item, index) =>
|
||||
!item ? (
|
||||
<h6 key={index}>No feedback is submitted for this tender</h6>
|
||||
) : (
|
||||
<TableRow
|
||||
key={item.id}
|
||||
className="odd:bg-gray-2 dark:odd:bg-gray-7"
|
||||
>
|
||||
<TableCell className="text-start" colSpan={100}>
|
||||
{index + 1}
|
||||
</TableCell>
|
||||
<TableCell className="uppercase" colSpan={100}>
|
||||
{item.feedback_type}
|
||||
</TableCell>
|
||||
<TableCell className="uppercase" colSpan={100}>
|
||||
{unixToDate(item.updated_at)}
|
||||
</TableCell>
|
||||
|
||||
<TableCell className="uppercase" colSpan={100}>
|
||||
{unixToDate(item.created_at)}
|
||||
</TableCell>
|
||||
<TableCell
|
||||
className={cn(`text flex gap-2 capitalize`)}
|
||||
colSpan={100}
|
||||
>
|
||||
<button
|
||||
className="text-gray-40 rounded-full bg-gray-dark bg-opacity-5 hover:text-green-dark dark:bg-gray dark:bg-opacity-5"
|
||||
onClick={() => {
|
||||
router.push(`${pathName}/${item.id}`);
|
||||
}}
|
||||
>
|
||||
<ExclamationIcon />
|
||||
</button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
),
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</ShowcaseSection>
|
||||
);
|
||||
};
|
||||
|
||||
export default TenderFeedbackTable;
|
||||
@@ -1,20 +0,0 @@
|
||||
"use client";
|
||||
import { useGetFeedback } from "@/hooks/queries";
|
||||
import { usePathname, useRouter } from "next/navigation";
|
||||
|
||||
const useTenderFeedbackPresenter = ({ id }: { id: string }) => {
|
||||
const { data, isLoading } = useGetFeedback({ tender_id: id });
|
||||
const router = useRouter();
|
||||
const pathName = usePathname();
|
||||
const columns = [
|
||||
"row",
|
||||
"feedback type",
|
||||
"updated at",
|
||||
|
||||
"created at",
|
||||
"actions",
|
||||
];
|
||||
return { feedback: data?.data, isLoading, columns, pathName, router };
|
||||
};
|
||||
|
||||
export default useTenderFeedbackPresenter;
|
||||
Reference in New Issue
Block a user