feat(feedback): add feedback button to tenders table
This commit introduces the ability for users to navigate to a feedback page directly from the tenders list. A new feedback icon and a corresponding button have been added to the actions column of the tenders table. Clicking this button redirects the user to the feedback page associated with that specific tender. To support this feature, the following changes were made: - Added a new `FeedbackIcon` SVG component. - Defined API endpoints and created query hooks for the feedback module. - Fixed a query key inconsistency for company details to ensure data is correctly refetched after updates.
This commit is contained in:
@@ -45,4 +45,9 @@ export const API_ENDPOINTS = {
|
||||
ASSIGN_COMPANY_TO_CUSTOMER: (id: string) =>
|
||||
`customers/${id}/companies/assign`,
|
||||
},
|
||||
FEEDBACK: {
|
||||
READ_ALL: "feedback",
|
||||
DETAILS: (id: string) => `feedback/${id}`,
|
||||
DELETE: (id: string) => `feedback/${id}`,
|
||||
},
|
||||
} as const;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import api from "../axios";
|
||||
import { API_ENDPOINTS } from "../endpoints";
|
||||
import { ApiResponse } from "../types";
|
||||
import { TFeedbackResponse } from "../types/Feedback";
|
||||
|
||||
export const feedbackService = {
|
||||
getFeedbacks: async (
|
||||
params: Record<string, any>,
|
||||
): Promise<TFeedbackResponse> => {
|
||||
try {
|
||||
return (await api.get(API_ENDPOINTS.FEEDBACK.READ_ALL, { params })).data;
|
||||
} catch (error) {
|
||||
console.error("ERROR Caught in feedback service => getFeedbacks", error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getSingleFeedback: async (
|
||||
id: string,
|
||||
): Promise<ApiResponse<TFeedbackResponse>> => {
|
||||
try {
|
||||
return (await api.get(API_ENDPOINTS.FEEDBACK.DETAILS(id))).data;
|
||||
} catch (error) {
|
||||
console.error(
|
||||
"ERROR Caught in feedback service => getSingleFeedback",
|
||||
error,
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
import { z } from "zod";
|
||||
import { TenderSchema } from "./Tenders";
|
||||
export const feedbackSchema = z.object({
|
||||
company_id: z.string(),
|
||||
created_at: z.number(),
|
||||
customer_id: z.string(),
|
||||
feedback_type: z.string(),
|
||||
id: z.string(),
|
||||
tender: TenderSchema.or(z.null()),
|
||||
updated_at: z.number(),
|
||||
});
|
||||
export const feedbackResponseSchema = z.object({
|
||||
data: z.array(feedbackSchema),
|
||||
});
|
||||
export type TFeedback = z.infer<typeof feedbackSchema>;
|
||||
export type TFeedbackResponse = z.infer<typeof feedbackResponseSchema>;
|
||||
@@ -52,7 +52,7 @@ export interface ICreateCompanyCredentials {
|
||||
export const companySchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
email: z.string().email().optional(),
|
||||
email: z.string().optional(),
|
||||
phone: z.string().optional(),
|
||||
website: z.string(),
|
||||
type: z.string(),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const TenderSchema = z.object({
|
||||
export const TenderSchema = z.object({
|
||||
id: z.string(),
|
||||
buyer_organization: z.object({
|
||||
name: z.string(),
|
||||
|
||||
Reference in New Issue
Block a user