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:
@@ -0,0 +1,36 @@
|
||||
import { useGetFeedback } from "@/hooks/queries";
|
||||
import { usePathname, useRouter } from "next/navigation";
|
||||
|
||||
interface IProps {
|
||||
id: string;
|
||||
paramKey: "tender_id" | "company_id" | "customer_id";
|
||||
}
|
||||
const useFeedbackTablePresenter = ({ id, paramKey }: IProps) => {
|
||||
const { data, isLoading } = useGetFeedback({ [paramKey]: id });
|
||||
const router = useRouter();
|
||||
const pathName = usePathname();
|
||||
const columns = [
|
||||
"row",
|
||||
"feedback type",
|
||||
"updated at",
|
||||
"created at",
|
||||
"actions",
|
||||
];
|
||||
const getShowcaseSectionTitle = () => {
|
||||
if (paramKey === "tender_id") {
|
||||
return `: ${data?.data?.[0]?.tender?.title}`;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
return {
|
||||
isLoading,
|
||||
feedback: data?.data,
|
||||
columns,
|
||||
pathName,
|
||||
router,
|
||||
getShowcaseSectionTitle,
|
||||
};
|
||||
};
|
||||
|
||||
export default useFeedbackTablePresenter;
|
||||
Reference in New Issue
Block a user