feat add company links
continuous-integration/drone/push Build is passing

This commit is contained in:
AmirReza Jamali
2026-07-11 15:34:13 +03:30
parent 37aa916ad5
commit 624614f1a9
10 changed files with 278 additions and 33 deletions
+1
View File
@@ -33,6 +33,7 @@ export const API_ENDPOINTS = {
DELETE: (id: string) => `companies/${id}`,
DETAILS: (id: string) => `companies/${id}`,
DOCUMENTS: (id: string) => `companies/${id}/documents`,
LINKS: (id: string) => `companies/${id}/links`,
CATEGORIES: {
READ_ALL: "company-categories",
CREATE: "company-categories",
+18 -1
View File
@@ -6,6 +6,8 @@ import {
TCompaniesResponse,
TCompanyCategoryApiResponse,
TCreateCompanyCategoryCredentials,
IAddCompanyLinksResponse,
ICompanyLink,
UploadDocumentsData,
} from "../types";
@@ -87,10 +89,25 @@ export const companiesService = {
return response.data;
} catch (error) {
console.error("ERROR caught in Companies Services Upload Documents:", error);
console.error(
"ERROR caught in Companies Services Upload Documents:",
error,
);
throw error;
}
},
addLinks: async ({
id,
links,
}: {
id: string;
links: ICompanyLink[];
}): Promise<ApiResponse<IAddCompanyLinksResponse>> => {
const response = await api.post(API_ENDPOINTS.COMPANIES.LINKS(id), {
links,
});
return response.data;
},
deleteCompany: async (id: string) => {
try {
return (await api.delete(API_ENDPOINTS.COMPANIES.DELETE(id))).data;
+14
View File
@@ -28,6 +28,11 @@ export interface ITags {
cpv_codes: string[];
}
export interface ICompanyLink {
url: string;
title?: string | null;
}
export interface ICreateCompanyCredentials {
name: string;
email: string;
@@ -48,6 +53,7 @@ export interface ICreateCompanyCredentials {
contact_person: IContactPerson;
tags: ITags;
document_file_ids?: string[];
links?: ICompanyLink[];
}
export const companySchema = z.object({
@@ -92,6 +98,14 @@ export const companySchema = z.object({
cpv_codes: z.array(z.string()).optional(),
}),
document_file_ids: z.array(z.string()).optional(),
links: z
.array(
z.object({
url: z.string().url(),
title: z.string().nullable().optional(),
}),
)
.optional(),
});
export const companiesResponseSchema = z.object({
+20
View File
@@ -38,6 +38,16 @@ export interface ITags {
cpv_codes: string[];
}
export interface ICompanyLink {
url: string;
title?: string | null;
}
export interface IAddCompanyLinksResponse {
links: ICompanyLink[];
added: ICompanyLink[];
}
export interface ICreateCompanyCredentials {
name: string;
email: string;
@@ -58,6 +68,7 @@ export interface ICreateCompanyCredentials {
contact_person?: IContactPerson;
tags: ITags;
document_file_ids?: string[];
links?: ICompanyLink[];
}
export const companySchema = z.object({
@@ -110,6 +121,15 @@ export const companySchema = z.object({
cpv_codes: nullableStringArraySchema,
}),
document_file_ids: z.array(z.string()).or(z.null()).optional(),
links: z
.array(
z.object({
url: z.string().url(),
title: z.string().nullable().optional(),
}),
)
.or(z.null())
.optional(),
});
export const companiesResponseSchema = z.object({