feat: add public employee profile view and implement ratings review page components
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import { ApiError } from "@core/Models/Server.Error.model";
|
||||
import {
|
||||
FindPublicCompanyEmployeesParams,
|
||||
FindPublicEmployeeParams,
|
||||
PublicCompanyEmployeeView,
|
||||
PublicEmployeeView,
|
||||
} from "@core/Models/Employees.model";
|
||||
import ApiRequest from "@services/Api.Service";
|
||||
import * as Yup from "yup";
|
||||
|
||||
const schemaFindPublicCompanyEmployees = Yup.object().shape({
|
||||
companyId: Yup.string().required("No se ha proporcionado la organización."),
|
||||
});
|
||||
|
||||
const schemaFindPublicEmployee = Yup.object().shape({
|
||||
employeeId: Yup.string().required("No se ha proporcionado el profesional."),
|
||||
});
|
||||
|
||||
export const findPublicCompanyEmployees = async (
|
||||
data: FindPublicCompanyEmployeesParams
|
||||
): Promise<PublicCompanyEmployeeView[]> => {
|
||||
return new Promise<PublicCompanyEmployeeView[]>((resolve, reject) => {
|
||||
schemaFindPublicCompanyEmployees
|
||||
.validate(data, { abortEarly: true })
|
||||
.then(() => {
|
||||
resolve(ApiRequest.post<PublicCompanyEmployeeView[]>("employees/public-by-company", data));
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(new ApiError(500, error.message));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const findPublicEmployee = async (
|
||||
data: FindPublicEmployeeParams
|
||||
): Promise<PublicEmployeeView> => {
|
||||
return new Promise<PublicEmployeeView>((resolve, reject) => {
|
||||
schemaFindPublicEmployee
|
||||
.validate(data, { abortEarly: true })
|
||||
.then(() => {
|
||||
resolve(ApiRequest.post<PublicEmployeeView>("employees/public-by-id", data));
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(new ApiError(500, error.message));
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -11,8 +11,8 @@ import {
|
||||
RATING_COMMENT_MAX_LENGTH,
|
||||
RatingTargetSummaryParams,
|
||||
RatingTargetSummaryResult,
|
||||
RatingTargetReviewItem,
|
||||
RatingTargetReviewsParams,
|
||||
RatingTargetReviewsResult,
|
||||
RatingTargetType,
|
||||
} from "@core/Models/Ratings.model";
|
||||
import * as Yup from "yup";
|
||||
@@ -48,6 +48,8 @@ const schemaRatingTargetSummary = Yup.object().shape({
|
||||
});
|
||||
|
||||
const schemaRatingTargetReviews = schemaRatingTargetSummary.shape({
|
||||
page: Yup.number().integer().min(1),
|
||||
pageSize: Yup.number().integer().min(1).max(20),
|
||||
limit: Yup.number().integer().min(1).max(20),
|
||||
});
|
||||
|
||||
@@ -118,12 +120,12 @@ export const ratingTargetSummary = async (data: RatingTargetSummaryParams): Prom
|
||||
});
|
||||
};
|
||||
|
||||
export const ratingTargetReviews = async (data: RatingTargetReviewsParams): Promise<RatingTargetReviewItem[]> => {
|
||||
return new Promise<RatingTargetReviewItem[]>((resolve, reject) => {
|
||||
export const ratingTargetReviews = async (data: RatingTargetReviewsParams): Promise<RatingTargetReviewsResult> => {
|
||||
return new Promise<RatingTargetReviewsResult>((resolve, reject) => {
|
||||
schemaRatingTargetReviews
|
||||
.validate(data, { abortEarly: true })
|
||||
.then(() => {
|
||||
resolve(ApiRequest.post<RatingTargetReviewItem[]>("ratings/target-reviews", data));
|
||||
resolve(ApiRequest.post<RatingTargetReviewsResult>("ratings/target-reviews", data));
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(new ApiError(500, error.message));
|
||||
|
||||
Reference in New Issue
Block a user