-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1845 from GW2Treasures/feature/wintersday-wizards…
…-vault Improve wintersday pages
- Loading branch information
Showing
17 changed files
with
182 additions
and
24 deletions.
There are no files selected for viewing
47 changes: 44 additions & 3 deletions
47
apps/web/app/[language]/festival/wintersday/(index)/page.tsx
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 |
---|---|---|
@@ -1,32 +1,73 @@ | ||
import { Gw2Accounts } from '@/components/Gw2Api/Gw2Accounts'; | ||
import { Trans } from '@/components/I18n/Trans'; | ||
import { ItemInventoryTable } from '@/components/Item/ItemInventoryTable'; | ||
import { ItemTable } from '@/components/ItemTable/ItemTable'; | ||
import { ItemTableColumnsButton } from '@/components/ItemTable/ItemTableColumnsButton'; | ||
import { ItemTableContext } from '@/components/ItemTable/ItemTableContext'; | ||
import { PageLayout } from '@/components/Layout/PageLayout'; | ||
import { pageView } from '@/lib/pageView'; | ||
import { Headline } from '@gw2treasures/ui/components/Headline/Headline'; | ||
import type { Metadata } from 'next'; | ||
import { requiredScopes } from '../helper'; | ||
import { db } from '@/lib/prisma'; | ||
import { linkProperties } from '@/lib/linkProperties'; | ||
import { cache } from '@/lib/cache'; | ||
import { ItemLink } from '@/components/Item/ItemLink'; | ||
import type { PageProps } from '@/lib/next'; | ||
import { getTranslate } from '@/lib/translate'; | ||
import { Fragment } from 'react'; | ||
|
||
const itemIds = [ | ||
86601, | ||
86627, | ||
77604, | ||
]; | ||
|
||
const loadData = cache(async function loadData() { | ||
const [items] = await Promise.all([ | ||
db.item.findMany({ | ||
where: { id: { in: itemIds }}, | ||
select: linkProperties | ||
}) | ||
]); | ||
|
||
return { items }; | ||
}, ['wintersday-items'], { revalidate: 60 * 60 }); | ||
|
||
|
||
export default async function WintersdayPage() { | ||
const { items } = await loadData(); | ||
await pageView('festival/wintersday'); | ||
|
||
return ( | ||
<PageLayout> | ||
<ItemTableContext id="wintersday"> | ||
<p><Trans id="festival.wintersday.intro"/></p> | ||
<p><Trans id="festival.wintersday.description"/></p> | ||
<Headline actions={<ItemTableColumnsButton/>} id="items"><Trans id="navigation.items"/></Headline> | ||
<ItemTable query={{ where: { id: { in: itemIds }}}} defaultColumns={['item', 'rarity', 'type', 'buyPrice', 'buyPriceTrend', 'sellPrice', 'sellPriceTrend']}/> | ||
</ItemTableContext> | ||
|
||
<Gw2Accounts requiredScopes={requiredScopes} loading={null} loginMessage={<Trans id="festival.wintersday.items.login"/>} authorizationMessage={<Trans id="festival.wintersday.items.authorize"/>}> | ||
{items.map((item) => ( | ||
<Fragment key={item.id}> | ||
<Headline id={item.id.toString()}><ItemLink item={item}/></Headline> | ||
<ItemInventoryTable itemId={item.id}/> | ||
</Fragment> | ||
))} | ||
</Gw2Accounts> | ||
|
||
</PageLayout> | ||
); | ||
} | ||
|
||
export const metadata: Metadata = { | ||
title: 'Wintersday' | ||
}; | ||
export async function generateMetadata({ params }: PageProps): Promise<Metadata> { | ||
const { language } = await params; | ||
const t = getTranslate(language); | ||
|
||
return { | ||
title: { | ||
absolute: `${t('festival.wintersday')} · gw2treasures.com` | ||
} | ||
}; | ||
} |
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
64 changes: 64 additions & 0 deletions
64
apps/web/app/[language]/festival/wintersday/wizards-vault/page.tsx
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,64 @@ | ||
import { Gw2Accounts } from '@/components/Gw2Api/Gw2Accounts'; | ||
import { Trans } from '@/components/I18n/Trans'; | ||
import { PageLayout } from '@/components/Layout/PageLayout'; | ||
import { cache } from '@/lib/cache'; | ||
import { db } from '@/lib/prisma'; | ||
import type { Metadata } from 'next'; | ||
import { requiredScopes } from '../helper'; | ||
import { pageView } from '@/lib/pageView'; | ||
import Link from 'next/link'; | ||
import { WizardsVaultObjective } from '@/components/WizardsVault/WizardsVaultObjective'; | ||
import type { PageProps } from '@/lib/next'; | ||
import { getTranslate } from '@/lib/translate'; | ||
import { Icon } from '@gw2treasures/ui'; | ||
import { Notice } from '@gw2treasures/ui/components/Notice/Notice'; | ||
|
||
const objectiveIds: number[] = [ | ||
// TODO: add objective ids | ||
]; | ||
|
||
const loadData = cache(async function loadData() { | ||
const [objectives] = await Promise.all([ | ||
db.wizardsVaultObjective.findMany({ | ||
where: { OR: [{ id: { in: objectiveIds }}, { name_en: { startsWith: '(Festival)' }, removedFromApi: false }] }, | ||
}) | ||
]); | ||
|
||
return { objectives }; | ||
}, ['wintersday-wizards-vault-objectives'], { revalidate: 60 * 5 }); | ||
|
||
|
||
export default async function WintersdayAchievementsPage({ params }: PageProps) { | ||
const { language } = await params; | ||
const { objectives } = await loadData(); | ||
await pageView('festival/wintersday/wizwards-vault'); | ||
|
||
return ( | ||
<PageLayout> | ||
<Gw2Accounts requiredScopes={requiredScopes} loading={null} loginMessage={<Trans id="festival.wintersday.wizards-vault.login"/>} authorizationMessage={<Trans id="festival.wintersday.wizards-vault.authorize"/>}/> | ||
|
||
<p><Trans id="festival.wintersday.wizards-vault.description"/></p> | ||
|
||
{objectives.length > 0 ? objectives.map((objective) => ( | ||
<WizardsVaultObjective key={objective.id} objective={objective} language={language}/> | ||
)) : ( | ||
<Notice>No Wizard's Vault objectives for wintersday are available in the Guild Wars 2 API yet.</Notice> | ||
)} | ||
|
||
<p style={{ border: '1px solid var(--color-border)', marginTop: 48, padding: 16 }}> | ||
<Icon icon="wizards-vault"/>{' '} | ||
Visit the <Link href="/wizards-vault">Wizard's Vault page</Link> to view all your active Wizard's Vault objectives. | ||
</p> | ||
|
||
</PageLayout> | ||
); | ||
} | ||
|
||
export async function generateMetadata({ params }: PageProps): Promise<Metadata> { | ||
const { language } = await params; | ||
const t = getTranslate(language); | ||
|
||
return { | ||
title: t('navigation.wizardsVault') | ||
}; | ||
} |
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
4 changes: 4 additions & 0 deletions
4
apps/web/components/WizardsVault/WizardsVaultObjective.module.css
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,3 @@ | ||
.nowrap { | ||
white-space: nowrap; | ||
} |
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
"next-env.d.ts", | ||
"**/*.ts", | ||
"**/*.tsx", | ||
"**/*.module.css", | ||
".next/types/**/*.ts" | ||
], | ||
} |