Skip to content

Commit

Permalink
WIP itemdiff
Browse files Browse the repository at this point in the history
  • Loading branch information
darthmaim committed Dec 26, 2023
1 parent 8d8ea57 commit b80e891
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions apps/web/app/[language]/item/diff/[a]/[b]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { notFound } from 'next/navigation';
import { Fragment } from 'react';
import { db } from '@/lib/prisma';
import { remember } from '@/lib/remember';
import { ClientItemTooltip, renderDefense, renderWeaponStrength } from '@/components/Item/ItemTooltip.client';
import { renderDefense, renderWeaponStrength } from '@/components/Item/ItemTooltip.client';
import { createTooltip } from '@/components/Item/ItemTooltip';
import type { Language } from '@gw2treasures/database';

Expand Down Expand Up @@ -71,7 +71,16 @@ export default async function ItemDiffPage({ params }: { params: { a: string, b:
<DiffLayoutRow left={renderWeaponStrength(tooltipA)} right={renderWeaponStrength(tooltipB)} changed={tooltipA.weaponStrength?.min !== tooltipB.weaponStrength?.min || tooltipA.weaponStrength?.max !== tooltipB.weaponStrength?.max}/>
<DiffLayoutRow left={renderDefense(tooltipA)} right={renderDefense(tooltipB)} changed={tooltipA.defense !== tooltipB.defense}/>

<DiffLayoutRow left={<ClientItemTooltip tooltip={tooltipA} hideTitle/>} right={<ClientItemTooltip tooltip={tooltipB} hideTitle/>}/>
{(tooltipA.attributes || tooltipB.attributes) && (
[...Array(Math.max(tooltipA.attributes?.length ?? 0, tooltipB.attributes?.length ?? 0)).keys()].map((_, i) => (
<DiffLayoutRow key={i}
left={tooltipA.attributes?.[i] && `+${tooltipA.attributes[i].value} ${tooltipA.attributes[i].label}`}
right={tooltipB.attributes?.[i] && `+${tooltipB.attributes[i].value} ${tooltipB.attributes[i].label}`}
changed={tooltipA.attributes?.[i].value !== tooltipB.attributes?.[i].value || tooltipA.attributes?.[i].label !== tooltipB.attributes?.[i].label}/>
))
)}

{/* <DiffLayoutRow left={<ClientItemTooltip tooltip={tooltipA} hideTitle/>} right={<ClientItemTooltip tooltip={tooltipB} hideTitle/>}/> */}

<DiffLayoutRow left={<Separator/>} right={<Separator/>}/>
<DiffLayoutRow left={<Json data={dataA} borderless/>} right={<Json data={dataB} borderless/>} changed/>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/components/Item/ItemTooltip.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface ClientItemTooltipProps {
hideTitle?: boolean;
};

function renderAttributes(attributes: ItemTooltip['attributes']) {
export function renderAttributes(attributes: ItemTooltip['attributes']) {
if(!attributes) {
return;
}
Expand Down

0 comments on commit b80e891

Please sign in to comment.