summaryrefslogtreecommitdiff
path: root/src/components/jet/item/ProductRatingsItem.svelte
blob: 0345993bbbe1cd77657268dcbd6ecb94b7b56cca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<script lang="ts">
    import type { Ratings } from '@jet-app/app-store/api/models';

    import RatingComponent from '@amp/web-app-components/src/components/Rating/Rating.svelte';
    import { getJet } from '~/jet/svelte';
    import { getI18n } from '~/stores/i18n';

    export let item: Ratings;

    const i18n = getI18n();
    const jet = getJet();
    const numberOfRatings = jet.localization.formattedCount(
        item.totalNumberOfRatings,
    );
</script>

<article>
    {#if item.totalNumberOfRatings === 0}
        {item.status}
    {:else}
        <RatingComponent
            averageRating={jet.localization.decimal(item.ratingAverage, 1)}
            ratingCount={item.totalNumberOfRatings}
            ratingCountText={$i18n.t('ASE.Web.AppStore.Ratings.CountText', {
                numberOfRatings: numberOfRatings,
            })}
            totalText={$i18n.t('ASE.Web.AppStore.Ratings.TotalText')}
            ratingCountsList={item.ratingCounts}
        />
    {/if}
</article>

<style>
    article {
        --ratingBarColor: var(--systemPrimary);
    }
</style>