Testimonials
Shows the store's customer reviews, fetched by Salla's reviews web component, with type, sort, limit and privacy options.
import { Testimonials } from '@salla.sa/twilight-theme-engine/components/home';In plain words
Customer reviews: the store's own, the products', or both. Salla's reviews element fetches and draws them; you only choose which ones, in what order, how many, and whether to hide the customers' names and pictures.
It is the one home block that is lazy, so it goes inside <Suspense>.
Signature
const Testimonials: React.LazyExoticComponent<React.MemoExoticComponent<(props: {
data: {
type?: 'all' | 'store' | 'products'; // 'store'
sort?: 'top_rating' | 'random' | 'latest'; // 'latest'
limit?: string | number; // 10
hide_customer_info?: boolean; // false
display_all_url?: string; // any value shows a "view all" link
[key: string]: unknown;
};
}) => JSX.Element>>Try it live
import { Suspense } from 'react';
import { Testimonials } from '@salla.sa/twilight-theme-engine/components/home';
export function Reviews() {
return (
<Suspense fallback={null}>
<Testimonials data={{
limit: 6,
}} />
</Suspense>
);
}
Example
import { Suspense } from 'react';
import { Testimonials } from '@salla.sa/twilight-theme-engine/components/home';
export function Reviews() {
return (
<Suspense fallback={null}>
<Testimonials data={{ type: 'products', sort: 'top_rating', limit: 6 }} />
</Suspense>
);
}
How it behaves
It renders
SallaReviewsfrom@salla.sa/twilight-components-reactwithlimit,sortandtype, plusdisplayAllLinkandhideCustomerInfowhen set. The reviews are requested by that component through the SDK, in the browser.Registered as
testimonial(singular) inDefaultHomeComponents. The engine's product page also renders it, withdata={{}}.
Gotchas
packages/theme-engine/docs/HOME_COMPONENTS.md lists
sort: latest | best | oldestandtype: store | products | product. The component types aretop_rating | random | latestandall | store | products.display_all_urlonly switches the link on; the URL itself is not passed on.limitgoes throughparseInt: a value like"six"becomesNaN.