Skip to content

Commit

Permalink
Merge pull request #130 from Klimatbyran/fix/improve-empty-states-and…
Browse files Browse the repository at this point in the history
…-caching

Fix/improve empty states and caching
  • Loading branch information
Greenheart authored Jun 17, 2024
2 parents 8e3e7a7 + e2f9af1 commit 4b757f3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
13 changes: 10 additions & 3 deletions src/components/company/CompanyFacts.astro
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,16 @@ function getPeriod(company: CompanyData) {
)
}

<a href={company.url} class="self-start text-sm text-blue-500 underline">
Läs hållbarhetsrapport för {getPeriod(company)}
</a>
{
company.url && (
<a
href={company.url}
class="self-start text-sm text-blue-500 underline"
>
Läs hållbarhetsrapport för {getPeriod(company)}
</a>
)
}
</Card>

<!-- NOTE: Maybe add total emissions in this card instead -->
Expand Down
2 changes: 1 addition & 1 deletion src/components/company/CompanyGoals.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const { goals } = Astro.props
---

{
goals ? (
goals && goals.length ? (
<Card class="grid gap-8" level={1}>
<h2 class="pt-4 text-center text-3xl leading-none tracking-tight md:pt-0">
Mål
Expand Down
2 changes: 1 addition & 1 deletion src/components/company/CompanyInitiatives.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const { initiatives } = Astro.props
---

{
initiatives ? (
initiatives && initiatives.length ? (
<Card class="grid gap-8" level={1}>
<h2 class="pt-4 text-center text-3xl leading-none tracking-tight md:pt-0">
Initiativ
Expand Down
2 changes: 1 addition & 1 deletion src/lib/createCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function createCache<K, V>({ maxAge }: { maxAge: number }) {
},
get(key: K) {
const value = cache.get(key)
if (value) {
if (value && Date.now() - value.cachedAt < maxAge) {
return value.data
}
},
Expand Down

0 comments on commit 4b757f3

Please sign in to comment.