Skip to content
On this page

useProductReviews ​

Definition ​

Composable for listing customer orders.

Basic usage ​

ts
const { 
 productReviews,
 addReview,
 loadProductReviews 
} = useProductReviews(product);

Signature ​

ts
export function useProductReviews(
  product: Ref<Schemas["Product"]>,
): UseProductReviewsReturn 

Parameters ​

NameTypeDescription
product
Ref<>

Return type ​

See UseProductReviewsReturn
ts
export type UseProductReviewsReturn = {
  /**
   * All reviews added to the product
   */
  productReviews: ComputedRef<Schemas["ProductReview"][]>;
  /**
   * Adds a review to the product
   * @param data `title` - review title, `content` - review content, `points` - review points (range of 1-5)
   * @returns
   */
  addReview(data: {
    title: string;
    content: string;
    points: number;
  }): Promise<void>;
  /**
   * Fetches the reviews list and assigns the result to the `productReviews` property
   * @param parameters {@link Schemas["Criteria"]}
   * @returns
   */
  loadProductReviews(parameters?: Schemas["Criteria"]): Promise<void>;
};

Properties ​

NameTypeDescription
productReviews
ComputedRef<Array<>>
All reviews added to the product

Methods ​

NameTypeDescription
addReview
Promise<void>
Adds a review to the product
loadProductReviews
Promise<void>
Fetches the reviews list and assigns the result to the `productReviews` property
useProductReviews has loaded