-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'award-afrobitcoin-experiment' into main-to-awardABC
- Loading branch information
Showing
39 changed files
with
1,029 additions
and
37 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
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,60 @@ | ||
<script lang="ts"> | ||
import GoalProgress from './GoalProgress.svelte'; | ||
import { useI18n } from '$lib/i18n'; | ||
import type { Leaderboard } from '$lib/types/Leaderboard'; | ||
import type { Product } from '$lib/types/Product'; | ||
import type { Picture } from '$lib/types/Picture'; | ||
import { groupBy } from 'lodash-es'; | ||
import type { SetRequired } from 'type-fest'; | ||
import PictureComponent from './Picture.svelte'; | ||
let className = ''; | ||
export { className as class }; | ||
export let leaderboard: Pick< | ||
Leaderboard, | ||
'_id' | 'name' | 'progress' | 'endsAt' | 'mode' | 'beginsAt' | ||
>; | ||
export let products: Pick<Product, '_id' | 'name' | 'shortDescription'>[]; | ||
export let pictures: Picture[]; | ||
const { locale } = useI18n(); | ||
$: productById = Object.fromEntries(products.map((product) => [product._id, product])); | ||
$: picturesByProduct = groupBy( | ||
pictures.filter((picture): picture is SetRequired<Picture, 'productId'> => !!picture.productId), | ||
'productId' | ||
); | ||
leaderboard.progress.sort((a, b) => b.amount - a.amount); | ||
</script> | ||
|
||
{#each leaderboard.progress as progress} | ||
<div class="flex items-center {className}"> | ||
<div class="flex items-center flex-row gap-4"> | ||
<a href="/product/{progress.product}"> | ||
<PictureComponent | ||
picture={picturesByProduct[productById[progress.product]._id][0]} | ||
class="max-w-[68px] max-h-[68px]" | ||
/> | ||
</a> | ||
<div class="flex flex-col"> | ||
<a href="/product/{progress.product}" class="font-medium text-[22px] body-title"> | ||
{productById[progress.product].name} | ||
</a> | ||
<p class="hidden lg:contents">{productById[progress.product].shortDescription}</p> | ||
</div> | ||
</div> | ||
</div> | ||
<GoalProgress | ||
class="font-bold body-title" | ||
text={leaderboard.mode === 'moneyAmount' | ||
? Number(Math.max(0, progress.amount)) | ||
.toLocaleString($locale, { | ||
style: 'currency', | ||
currency: progress.currency, | ||
minimumFractionDigits: 0 | ||
}) | ||
.toString() | ||
: Math.max(progress.amount, 0).toString()} | ||
goal={leaderboard.progress[0].amount} | ||
progress={progress.amount} | ||
leaderboard={true} | ||
/> | ||
{/each} |
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
Oops, something went wrong.