Skip to content

Commit

Permalink
Talent builder 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Haaxor1689 committed Oct 23, 2024
1 parent 345c6b8 commit a75a9f5
Show file tree
Hide file tree
Showing 68 changed files with 694 additions and 361 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"babel-plugin-react-compiler": "0.0.0-experimental-fe484b5-20240912",
"classnames": "^2.5.1",
"drizzle-orm": "^0.33.0",
"html-to-image": "^1.11.11",
"lodash-es": "^4.17.21",
"lucide-react": "^0.441.0",
"nanoid": "^5.0.7",
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added public/icons/ability_mage_firestarter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/ability_warrior_reprisal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/icons/class_druid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/icons/class_hunter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/icons/class_mage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/icons/class_paladin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/icons/class_priest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/icons/class_rogue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/icons/class_shaman.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/icons/class_warlock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/icons/class_warrior.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/inv_bishophat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/icons/inv_bloodmoon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/icons/inv_bulwark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/icons/inv_censer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/icons/inv_checkmate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/inv_corgi2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/inv_demonaxe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/inv_demonhornhelmet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/inv_demonhornshoulders.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/icons/inv_desecration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/icons/inv_draeneispear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/icons/inv_generic_anchor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/inv_jewelry_ring_gilneas.png
Binary file modified public/icons/inv_kirel.png
Binary file modified public/icons/inv_mallet.png
Binary file added public/icons/inv_misc_gem_felstone.png
Binary file modified public/icons/inv_nethraka.png
Binary file added public/icons/inv_pvppandarenserpentmount.png
Binary file modified public/icons/inv_riftcarver.png
Binary file modified public/icons/inv_theend.png
Binary file modified public/icons/inv_thunderfall.png
72 changes: 60 additions & 12 deletions public/icons/list.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
-1,
"inv_jewelry_ring_emerald"
],
[
-1,
"inv_jewelry_ring_gilneas"
],
[
-1,
"inv_jewelry_ring_gold"
Expand Down Expand Up @@ -159,6 +163,10 @@
-1,
"inv_nethraka"
],
[
-1,
"inv_pvppandarenserpentmount"
],
[
-1,
"inv_redgem"
Expand All @@ -179,14 +187,46 @@
-1,
"inv_weapon_bonebow2"
],
[
-1,
"inv_bishophat"
],
[
-1,
"inv_censer"
],
[
-1,
"inv_demonaxe"
],
[
-1,
"inv_demonhornhelmet"
],
[
-1,
"inv_demonhornshoulders"
],
[
-1,
"inv_mallet"
],
[
-1,
"ability_mage_firestarter"
],
[
2340,
"ability_warlock_power_overwhelming"
],
[
2349,
"ability_warrior_reprisal"
],
[
2341,
"ability_warrior_stalwartprotector"
],
[
-1,
"class_druid"
Expand Down Expand Up @@ -223,6 +263,14 @@
-1,
"class_warrior"
],
[
2333,
"inv_corgi2"
],
[
2342,
"inv_misc_gem_felstone"
],
[
-1,
"inv_ore_gold_01"
Expand Down Expand Up @@ -708,7 +756,7 @@
"spell_fire_bluefire"
],
[
-1,
2337,
"trade_archaeology_highbornesoulmirror"
],
[
Expand Down Expand Up @@ -2252,7 +2300,7 @@
"spell_holy_surgeoflight"
],
[
-1,
2335,
"spell_mage_focusingcrystal"
],
[
Expand Down Expand Up @@ -2496,7 +2544,7 @@
"garrison_upgrade"
],
[
-1,
2336,
"garrison_weaponupgrade"
],
[
Expand Down Expand Up @@ -2800,7 +2848,7 @@
"inv_pet_mechanicalchicken"
],
[
-1,
2344,
"inv_pet_monkey"
],
[
Expand Down Expand Up @@ -7176,7 +7224,7 @@
"inv_enchant_essencemagicsmall"
],
[
-1,
2334,
"inv_enchant_essencemysticallarge"
],
[
Expand Down Expand Up @@ -8840,7 +8888,7 @@
"inv_misc_book_07"
],
[
-1,
2331,
"inv_misc_book_08"
],
[
Expand Down Expand Up @@ -9532,7 +9580,7 @@
"inv_misc_gear_07"
],
[
-1,
2345,
"inv_misc_gear_08"
],
[
Expand Down Expand Up @@ -9828,7 +9876,7 @@
"inv_misc_herb_01"
],
[
-1,
2328,
"inv_misc_herb_02"
],
[
Expand Down Expand Up @@ -10040,7 +10088,7 @@
"inv_misc_leatherscrap_08"
],
[
-1,
2332,
"inv_misc_map_01"
],
[
Expand Down Expand Up @@ -10376,11 +10424,11 @@
"inv_misc_quiver_02"
],
[
-1,
2330,
"inv_misc_quiver_03"
],
[
-1,
2343,
"inv_misc_quiver_04"
],
[
Expand Down Expand Up @@ -11900,7 +11948,7 @@
"inv_sword_30"
],
[
-1,
2325,
"inv_sword_31"
],
[
Expand Down
33 changes: 18 additions & 15 deletions src/app/admin/PageContent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { Download, Upload, RotateCcw, User, Images } from 'lucide-react';
import { Download, Upload, User, Images } from 'lucide-react';
import { useState } from 'react';
import toast from 'react-hot-toast';

Expand All @@ -10,14 +10,15 @@ import TextButton from '~/components/styled/TextButton';
import useAsyncAction from '~/hooks/useAsyncAction';
import {
createTurtleWoWAccount,
exportClientTrees,
exportTable,
exportMissingIcons,
importClientTrees,
importTable,
regenerateIds
importTable
} from '~/server/api/routers/general';
import { downloadBlob } from '~/utils';
import {
exportCollection,
importCollection
} from '~/server/api/routers/collection';

import AdminModule from './AdminModule';

Expand All @@ -26,6 +27,8 @@ const PageContent = () => {

const [table, setTable] = useState('');
const [dbImport, setDbImport] = useState('');

const [collection, setCollection] = useState('');
const [clientImport, setClientImport] = useState('');

return (
Expand All @@ -40,13 +43,6 @@ const PageContent = () => {
>
Create TurtleWoW account
</TextButton>
<TextButton
icon={RotateCcw}
onClick={asyncAction(() => regenerateIds(undefined))}
disabled={disableInteractions}
>
Regenerate IDs
</TextButton>
<TextButton
icon={Images}
onClick={asyncAction(async () => {
Expand Down Expand Up @@ -99,7 +95,12 @@ const PageContent = () => {
</div>
</AdminModule>

<AdminModule title="Import trees from client">
<AdminModule title="Import/export collection">
<Input
placeholder="Collection name"
value={collection}
onChange={e => setCollection(e.currentTarget.value)}
/>
<Textarea
value={clientImport}
onChange={e => setClientImport(e.currentTarget.value)}
Expand All @@ -110,7 +111,9 @@ const PageContent = () => {
<div className="flex gap-2 self-end">
<TextButton
icon={Upload}
onClick={asyncAction(() => importClientTrees(clientImport))}
onClick={asyncAction(() =>
importCollection({ collection, json: clientImport })
)}
disabled={disableInteractions}
className="self-end"
>
Expand All @@ -119,7 +122,7 @@ const PageContent = () => {
<TextButton
icon={Download}
onClick={asyncAction(async () => {
const response = await exportClientTrees(undefined);
const response = await exportCollection(collection);
window.navigator.clipboard.writeText(response);
toast.success('Copied to clipboard');
})}
Expand Down
9 changes: 9 additions & 0 deletions src/app/c/[collection]/[class]/[index]/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Spinner from '~/components/styled/Spinner';

const Loading = () => (
<div className="my-6 flex grow items-center justify-center">
<Spinner />
</div>
);

export default Loading;
56 changes: 56 additions & 0 deletions src/app/c/[collection]/[class]/[index]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { notFound } from 'next/navigation';
import { z } from 'zod';

import TalentBuilder from '~/components/builder/TalentBuilder';
import { getOgInfo } from '~/server/api/routers/openGraph';
import { classMask, getIconPath } from '~/utils';
import { env } from '~/env';
import { getCollectionTree } from '~/server/api/routers/collection';

const ParamsSchema = z.object({
collection: z.string(),
class: z.preprocess(
v =>
Object.entries(classMask).find(
m => m[1].name.toLocaleLowerCase() === v
)?.[0] ?? 0,
z.coerce.number()
),
index: z.coerce.number()
});

type PageProps = {
params: z.infer<typeof ParamsSchema>;
};

export const generateMetadata = async ({ params }: PageProps) => {
const parsed = ParamsSchema.safeParse(params);
if (!parsed.success) return notFound();

const talentTree = await getCollectionTree(parsed.data);
if (!talentTree) return notFound();

const info = await getOgInfo(talentTree.id);
if (!info) return null;
return {
title: `${info.name} | Talent Builder`,
description: `Talent tree created by ${info.user.name}`,
icons: [{ rel: 'icon', url: env.DEPLOY_URL + getIconPath(info.icon) }]
};
};

const TalentTreePage = async ({ params }: PageProps) => {
const parsed = ParamsSchema.safeParse(params);
if (!parsed.success) {
console.dir(parsed.error, { depth: null });
return notFound();
}

console.log(parsed.data);
const talentTree = await getCollectionTree(parsed.data);
if (!talentTree) return notFound();

return <TalentBuilder defaultValues={talentTree} />;
};

export default TalentTreePage;
9 changes: 9 additions & 0 deletions src/app/c/[collection]/[class]/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Spinner from '~/components/styled/Spinner';

const Loading = () => (
<div className="my-6 flex grow items-center justify-center">
<Spinner />
</div>
);

export default Loading;
Loading

0 comments on commit a75a9f5

Please sign in to comment.