-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
816f1be
commit f72035c
Showing
13 changed files
with
316 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
import { AggregateRating, Review } from "apps/commerce/types.ts"; | ||
import ReviewRating from "../ReviewRating.tsx"; | ||
import convertDate from "./convertDate.ts"; | ||
import { useDevice } from "@deco/deco/hooks"; | ||
import { clx } from "../../../sdk/clx.ts"; | ||
|
||
interface ReviewsProps { | ||
reviews?: Review[] | ||
aggregateRating?: AggregateRating | ||
} | ||
|
||
export default function Reviews({ reviews, aggregateRating }: ReviewsProps) { | ||
const device = useDevice() | ||
return ( | ||
<div class={clx( | ||
"desktop:max-h-[71.2%] w-full desktop:overflow-y-auto flex-1 snap-y custom-scrollbar desktop:pr-4", | ||
"mobile:flex mobile:flex-col mobile:gap-[26px]" | ||
)}> | ||
{device === "mobile" && ( | ||
<> | ||
<div class="flex flex-col gap-4"> | ||
<h3 class="font-bold text-black text-2xl">Avaliações de Clientes</h3> | ||
<ReviewRating reviewCount={aggregateRating?.reviewCount ?? 0} ratingValue={aggregateRating?.ratingValue ?? 0} typeTwo={true} size={20} /> | ||
</div> | ||
<hr /> | ||
</> | ||
)} | ||
<ul class="space-y-6 w-full mobile:max-h-[382px] overflow-y-auto snap-y custom-scrollbar mobile:pr-2"> | ||
{reviews?.map(review => ( | ||
<li class="flex flex-col gap-4 mobile:gap-6 w-full snap-start"> | ||
<div class="flex flex-col gap-4"> | ||
<ReviewRating reviewCount={0} ratingValue={review.reviewRating?.ratingValue ?? 0} size={16.67} /> | ||
<span class="font-bold text-black">{review.author![0].name}</span> | ||
<p class="text-sm text-black">{review.reviewBody}</p> | ||
<span class="text-xs text-[#999999]">{review.datePublished && convertDate(review.datePublished)}</span> | ||
</div> | ||
<hr /> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export default function convertDate(isoDate: string) { | ||
const date = new Date(isoDate); | ||
|
||
const options: Intl.DateTimeFormatOptions = { | ||
day: "numeric", | ||
month: "long", | ||
year: "numeric" | ||
}; | ||
|
||
const formattedDate = new Intl.DateTimeFormat("pt-BR", options).format(date); | ||
return formattedDate | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.