builds page fetches

This commit is contained in:
Kalle (Sendou) 2020-11-11 12:23:27 +02:00
parent 3cf5dccbca
commit 0075853bb3
19 changed files with 1216 additions and 183 deletions

View File

@ -3,7 +3,7 @@ import GearImage from "components/common/GearImage";
import WeaponImage from "components/common/WeaponImage";
import { abilityMarkdownCodes } from "lib/lists/abilityMarkdownCodes";
import { gearMarkdownCodes } from "lib/lists/gearMarkdownCodes";
import { weaponMarkdownCodes } from "lib/lists/weaponMarkdownCodes";
import { codeToWeapon } from "lib/lists/weaponCodes";
import Image from "next/image";
const modeCodes: Record<string, string> = {
@ -21,8 +21,8 @@ interface EmojiProps {
const Emoji: React.FC<EmojiProps> = (props) => {
const value = props.value.replace(/:/g, "").toLowerCase();
const keyWeapon = value as keyof typeof weaponMarkdownCodes;
const weaponName = weaponMarkdownCodes[keyWeapon];
const keyWeapon = value as keyof typeof codeToWeapon;
const weaponName = codeToWeapon[keyWeapon];
if (!!weaponName) return <WeaponImage name={weaponName} size={32} isInline />;
const keyAbility = value as keyof typeof abilityMarkdownCodes;

View File

@ -0,0 +1,57 @@
import { Select, Tag, TagCloseButton, TagLabel } from "@chakra-ui/core";
import { useLingui } from "@lingui/react";
import { weaponsWithHeroCategorizedLocalized } from "lib/lists/weaponsWithHero";
import WeaponImage from "./WeaponImage";
interface Props {
name: string;
value: string[];
onChange: (value: string[]) => void;
}
const WeaponSelector: React.FC<Props> = ({ name, value, onChange }) => {
const { i18n } = useLingui();
return (
<>
<Select
name={name}
onChange={(e) => {
if (!!e.target.value && !value.includes(e.target.value))
onChange(value.concat(e.target.value));
}}
>
{weaponsWithHeroCategorizedLocalized.map((wpnCategory) => (
<optgroup key={wpnCategory.name} label={i18n._(wpnCategory.name)}>
{wpnCategory.weapons.map((wpn) => (
<option key={wpn} value={wpn}>
{i18n._(wpn)}
</option>
))}
</optgroup>
))}
</Select>
{value.map((wpn) => (
<Tag
size="small"
key={wpn}
borderRadius="full"
variant="outline"
p={1}
m={2}
>
<TagLabel>
<WeaponImage name={wpn} size={32} />
</TagLabel>
<TagCloseButton
borderRadius="full"
onClick={() =>
onChange(value.filter((wpnSelected) => wpnSelected !== wpn))
}
/>
</Tag>
))}
</>
);
};
export default WeaponSelector;

View File

@ -1,55 +1,45 @@
import { Select, Tag, TagCloseButton, TagLabel } from "@chakra-ui/core";
import { Select } from "@chakra-ui/core";
import { useLingui } from "@lingui/react";
import { weaponsWithHeroCategorizedLocalized } from "lib/lists/weaponsWithHero";
import WeaponImage from "./WeaponImage";
interface Props {
name: string;
value: string[];
onChange: (value: string[]) => void;
name?: string;
value: string;
excludeAlt?: boolean;
onChange: (value: string) => void;
}
const WeaponSelector: React.FC<Props> = ({ name, value, onChange }) => {
const WeaponSelector: React.FC<Props> = ({
name,
value,
onChange,
excludeAlt,
}) => {
const { i18n } = useLingui();
return (
<>
<Select
value={value}
name={name}
onChange={(e) => {
if (!!e.target.value && !value.includes(e.target.value))
onChange(value.concat(e.target.value));
}}
onChange={(e) => onChange(e.target.value)}
>
{weaponsWithHeroCategorizedLocalized.map((wpnCategory) => (
<optgroup key={wpnCategory.name} label={i18n._(wpnCategory.name)}>
{wpnCategory.weapons.map((wpn) => (
<option key={wpn} value={wpn}>
{i18n._(wpn)}
</option>
))}
{wpnCategory.weapons.map((wpn) => {
if (
(excludeAlt && wpn.includes("Hero")) ||
wpn.includes("Octo Shot")
)
return null;
return (
<option key={wpn} value={wpn}>
{i18n._(wpn)}
</option>
);
})}
</optgroup>
))}
</Select>
{value.map((wpn) => (
<Tag
size="small"
key={wpn}
borderRadius="full"
variant="outline"
p={1}
m={2}
>
<TagLabel>
<WeaponImage name={wpn} size={32} />
</TagLabel>
<TagCloseButton
borderRadius="full"
onClick={() =>
onChange(value.filter((wpnSelected) => wpnSelected !== wpn))
}
/>
</Tag>
))}
</>
);
};

View File

@ -21,7 +21,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { t, Trans } from "@lingui/macro";
import { useLingui } from "@lingui/react";
import MarkdownTextarea from "components/common/MarkdownTextarea";
import WeaponSelector from "components/common/WeaponSelector";
import WeaponSelector from "components/common/MultiWeaponSelector";
import { countries } from "countries-list";
import { getToastOptions } from "lib/getToastOptions";
import { sendData } from "lib/postData";

283
lib/lists/weaponCodes.ts Normal file
View File

@ -0,0 +1,283 @@
export const codeToWeapon = {
"sploosh-o-matic": "Sploosh-o-matic",
"neo_sploosh-o-matic": "Neo Sploosh-o-matic",
"sploosh-o-matic_7": "Sploosh-o-matic 7",
splattershot_jr: "Splattershot Jr.",
custom_splattershot_jr: "Custom Splattershot Jr.",
kensa_splattershot_jr: "Kensa Splattershot Jr.",
"splash-o-matic": "Splash-o-matic",
"neo_splash-o-matic": "Neo Splash-o-matic",
aerospray_mg: "Aerospray MG",
aerospray_rg: "Aerospray RG",
aerospray_pg: "Aerospray PG",
splattershot: "Splattershot",
hero_shot_replica: "Hero Shot Replica",
tentatek_splattershot: "Tentatek Splattershot",
octo_shot_replica: "Octo Shot Replica",
kensa_splattershot: "Kensa Splattershot",
"52_gal": ".52 Gal",
"52_gal_deco": ".52 Gal Deco",
kensa_52_gal: "Kensa .52 Gal",
"n-zap_85": "N-ZAP '85",
"n-zap_89": "N-ZAP '89",
"n-zap_83": "N-ZAP '83",
splattershot_pro: "Splattershot Pro",
forge_splattershot_pro: "Forge Splattershot Pro",
kensa_splattershot_pro: "Kensa Splattershot Pro",
"96_gal": ".96 Gal",
"96_gal_deco": ".96 Gal Deco",
jet_squelcher: "Jet Squelcher",
custom_jet_squelcher: "Custom Jet Squelcher",
"l-3_nozzlenose": "L-3 Nozzlenose",
"l-3_nozzlenose_d": "L-3 Nozzlenose D",
"kensa_l-3_nozzlenose": "Kensa L-3 Nozzlenose",
"h-3_nozzlenose": "H-3 Nozzlenose",
"h-3_nozzlenose_d": "H-3 Nozzlenose D",
"cherry_h-3_nozzlenose": "Cherry H-3 Nozzlenose",
squeezer: "Squeezer",
foil_squeezer: "Foil Squeezer",
luna_blaster: "Luna Blaster",
luna_blaster_neo: "Luna Blaster Neo",
kensa_luna_blaster: "Kensa Luna Blaster",
blaster: "Blaster",
hero_blaster_replica: "Hero Blaster Replica",
custom_blaster: "Custom Blaster",
range_blaster: "Range Blaster",
custom_range_blaster: "Custom Range Blaster",
grim_range_blaster: "Grim Range Blaster",
rapid_blaster: "Rapid Blaster",
rapid_blaster_deco: "Rapid Blaster Deco",
kensa_rapid_blaster: "Kensa Rapid Blaster",
rapid_blaster_pro: "Rapid Blaster Pro",
rapid_blaster_pro_deco: "Rapid Blaster Pro Deco",
clash_blaster: "Clash Blaster",
clash_blaster_neo: "Clash Blaster Neo",
carbon_roller: "Carbon Roller",
carbon_roller_deco: "Carbon Roller Deco",
splat_roller: "Splat Roller",
hero_roller_replica: "Hero Roller Replica",
"krak-on_splat_roller": "Krak-On Splat Roller",
kensa_splat_roller: "Kensa Splat Roller",
dynamo_roller: "Dynamo Roller",
gold_dynamo_roller: "Gold Dynamo Roller",
kensa_dynamo_roller: "Kensa Dynamo Roller",
flingza_roller: "Flingza Roller",
foil_flingza_roller: "Foil Flingza Roller",
inkbrush: "Inkbrush",
inkbrush_nouveau: "Inkbrush Nouveau",
permanent_inkbrush: "Permanent Inkbrush",
octobrush: "Octobrush",
herobrush_replica: "Herobrush Replica",
octobrush_nouveau: "Octobrush Nouveau",
kensa_octobrush: "Kensa Octobrush",
classic_squiffer: "Classic Squiffer",
new_squiffer: "New Squiffer",
fresh_squiffer: "Fresh Squiffer",
splat_charger: "Splat Charger",
hero_charger_replica: "Hero Charger Replica",
firefin_splat_charger: "Firefin Splat Charger",
kensa_charger: "Kensa Charger",
splatterscope: "Splatterscope",
firefin_splatterscope: "Firefin Splatterscope",
kensa_splatterscope: "Kensa Splatterscope",
"e-liter_4k": "E-liter 4K",
"custom_e-liter_4k": "Custom E-liter 4K",
"e-liter_4k_scope": "E-liter 4K Scope",
"custom_e-liter_4k_scope": "Custom E-liter 4K Scope",
bamboozler_14_mk_i: "Bamboozler 14 Mk I",
bamboozler_14_mk_ii: "Bamboozler 14 Mk II",
bamboozler_14_mk_iii: "Bamboozler 14 Mk III",
goo_tuber: "Goo Tuber",
custom_goo_tuber: "Custom Goo Tuber",
slosher: "Slosher",
hero_slosher_replica: "Hero Slosher Replica",
slosher_deco: "Slosher Deco",
soda_slosher: "Soda Slosher",
"tri-slosher": "Tri-Slosher",
"tri-slosher_nouveau": "Tri-Slosher Nouveau",
sloshing_machine: "Sloshing Machine",
sloshing_machine_neo: "Sloshing Machine Neo",
kensa_sloshing_machine: "Kensa Sloshing Machine",
bloblobber: "Bloblobber",
bloblobber_deco: "Bloblobber Deco",
explosher: "Explosher",
custom_explosher: "Custom Explosher",
mini_splatling: "Mini Splatling",
zink_mini_splatling: "Zink Mini Splatling",
kensa_mini_splatling: "Kensa Mini Splatling",
heavy_splatling: "Heavy Splatling",
hero_splatling_replica: "Hero Splatling Replica",
heavy_splatling_deco: "Heavy Splatling Deco",
heavy_splatling_remix: "Heavy Splatling Remix",
hydra_splatling: "Hydra Splatling",
custom_hydra_splatling: "Custom Hydra Splatling",
ballpoint_splatling: "Ballpoint Splatling",
ballpoint_splatling_nouveau: "Ballpoint Splatling Nouveau",
nautilus_47: "Nautilus 47",
nautilus_79: "Nautilus 79",
dapple_dualies: "Dapple Dualies",
dapple_dualies_nouveau: "Dapple Dualies Nouveau",
clear_dapple_dualies: "Clear Dapple Dualies",
splat_dualies: "Splat Dualies",
hero_dualies_replicas: "Hero Dualie Replicas",
enperry_splat_dualies: "Enperry Splat Dualies",
kensa_splat_dualies: "Kensa Splat Dualies",
glooga_dualies: "Glooga Dualies",
glooga_dualies_deco: "Glooga Dualies Deco",
kensa_glooga_dualies: "Kensa Glooga Dualies",
dualie_squelchers: "Dualie Squelchers",
custom_dualie_squelchers: "Custom Dualie Squelchers",
dark_tetra_dualies: "Dark Tetra Dualies",
light_tetra_dualies: "Light Tetra Dualies",
splat_brella: "Splat Brella",
hero_brella_replica: "Hero Brella Replica",
sorella_brella: "Sorella Brella",
tenta_brella: "Tenta Brella",
tenta_sorella_brella: "Tenta Sorella Brella",
tenta_camo_brella: "Tenta Camo Brella",
undercover_brella: "Undercover Brella",
undercover_sorella_brella: "Undercover Sorella Brella",
kensa_undercover_brella: "Kensa Undercover Brella",
} as const;
export const weaponToCode = {
"Sploosh-o-matic": "sploosh-o-matic",
"Neo Sploosh-o-matic": "neo_sploosh-o-matic",
"Sploosh-o-matic 7": "sploosh-o-matic_7",
"Splattershot Jr.": "splattershot_jr",
"Custom Splattershot Jr.": "custom_splattershot_jr",
"Kensa Splattershot Jr.": "kensa_splattershot_jr",
"Splash-o-matic": "splash-o-matic",
"Neo Splash-o-matic": "neo_splash-o-matic",
"Aerospray MG": "aerospray_mg",
"Aerospray RG": "aerospray_rg",
"Aerospray PG": "aerospray_pg",
Splattershot: "splattershot",
"Hero Shot Replica": "hero_shot_replica",
"Tentatek Splattershot": "tentatek_splattershot",
"Octo Shot Replica": "octo_shot_replica",
"Kensa Splattershot": "kensa_splattershot",
".52 Gal": "52_gal",
".52 Gal Deco": "52_gal_deco",
"Kensa .52 Gal": "kensa_52_gal",
"N-ZAP '85": "n-zap_85",
"N-ZAP '89": "n-zap_89",
"N-ZAP '83": "n-zap_83",
"Splattershot Pro": "splattershot_pro",
"Forge Splattershot Pro": "forge_splattershot_pro",
"Kensa Splattershot Pro": "kensa_splattershot_pro",
".96 Gal": "96_gal",
".96 Gal Deco": "96_gal_deco",
"Jet Squelcher": "jet_squelcher",
"Custom Jet Squelcher": "custom_jet_squelcher",
"L-3 Nozzlenose": "l-3_nozzlenose",
"L-3 Nozzlenose D": "l-3_nozzlenose_d",
"Kensa L-3 Nozzlenose": "kensa_l-3_nozzlenose",
"H-3 Nozzlenose": "h-3_nozzlenose",
"H-3 Nozzlenose D": "h-3_nozzlenose_d",
"Cherry H-3 Nozzlenose": "cherry_h-3_nozzlenose",
Squeezer: "squeezer",
"Foil Squeezer": "foil_squeezer",
"Luna Blaster": "luna_blaster",
"Luna Blaster Neo": "luna_blaster_neo",
"Kensa Luna Blaster": "kensa_luna_blaster",
Blaster: "blaster",
"Hero Blaster Replica": "hero_blaster_replica",
"Custom Blaster": "custom_blaster",
"Range Blaster": "range_blaster",
"Custom Range Blaster": "custom_range_blaster",
"Grim Range Blaster": "grim_range_blaster",
"Rapid Blaster": "rapid_blaster",
"Rapid Blaster Deco": "rapid_blaster_deco",
"Kensa Rapid Blaster": "kensa_rapid_blaster",
"Rapid Blaster Pro": "rapid_blaster_pro",
"Rapid Blaster Pro Deco": "rapid_blaster_pro_deco",
"Clash Blaster": "clash_blaster",
"Clash Blaster Neo": "clash_blaster_neo",
"Carbon Roller": "carbon_roller",
"Carbon Roller Deco": "carbon_roller_deco",
"Splat Roller": "splat_roller",
"Hero Roller Replica": "hero_roller_replica",
"Krak-On Splat Roller": "krak-on_splat_roller",
"Kensa Splat Roller": "kensa_splat_roller",
"Dynamo Roller": "dynamo_roller",
"Gold Dynamo Roller": "gold_dynamo_roller",
"Kensa Dynamo Roller": "kensa_dynamo_roller",
"Flingza Roller": "flingza_roller",
"Foil Flingza Roller": "foil_flingza_roller",
Inkbrush: "inkbrush",
"Inkbrush Nouveau": "inkbrush_nouveau",
"Permanent Inkbrush": "permanent_inkbrush",
Octobrush: "octobrush",
"Herobrush Replica": "herobrush_replica",
"Octobrush Nouveau": "octobrush_nouveau",
"Kensa Octobrush": "kensa_octobrush",
"Classic Squiffer": "classic_squiffer",
"New Squiffer": "new_squiffer",
"Fresh Squiffer": "fresh_squiffer",
"Splat Charger": "splat_charger",
"Hero Charger Replica": "hero_charger_replica",
"Firefin Splat Charger": "firefin_splat_charger",
"Kensa Charger": "kensa_charger",
Splatterscope: "splatterscope",
"Firefin Splatterscope": "firefin_splatterscope",
"Kensa Splatterscope": "kensa_splatterscope",
"E-liter 4K": "e-liter_4k",
"Custom E-liter 4K": "custom_e-liter_4k",
"E-liter 4K Scope": "e-liter_4k_scope",
"Custom E-liter 4K Scope": "custom_e-liter_4k_scope",
"Bamboozler 14 Mk I": "bamboozler_14_mk_i",
"Bamboozler 14 Mk II": "bamboozler_14_mk_ii",
"Bamboozler 14 Mk III": "bamboozler_14_mk_iii",
"Goo Tuber": "goo_tuber",
"Custom Goo Tuber": "custom_goo_tuber",
Slosher: "slosher",
"Hero Slosher Replica": "hero_slosher_replica",
"Slosher Deco": "slosher_deco",
"Soda Slosher": "soda_slosher",
"Tri-Slosher": "tri-slosher",
"Tri-Slosher Nouveau": "tri-slosher_nouveau",
"Sloshing Machine": "sloshing_machine",
"Sloshing Machine Neo": "sloshing_machine_neo",
"Kensa Sloshing Machine": "kensa_sloshing_machine",
Bloblobber: "bloblobber",
"Bloblobber Deco": "bloblobber_deco",
Explosher: "explosher",
"Custom Explosher": "custom_explosher",
"Mini Splatling": "mini_splatling",
"Zink Mini Splatling": "zink_mini_splatling",
"Kensa Mini Splatling": "kensa_mini_splatling",
"Heavy Splatling": "heavy_splatling",
"Hero Splatling Replica": "hero_splatling_replica",
"Heavy Splatling Deco": "heavy_splatling_deco",
"Heavy Splatling Remix": "heavy_splatling_remix",
"Hydra Splatling": "hydra_splatling",
"Custom Hydra Splatling": "custom_hydra_splatling",
"Ballpoint Splatling": "ballpoint_splatling",
"Ballpoint Splatling Nouveau": "ballpoint_splatling_nouveau",
"Nautilus 47": "nautilus_47",
"Nautilus 79": "nautilus_79",
"Dapple Dualies": "dapple_dualies",
"Dapple Dualies Nouveau": "dapple_dualies_nouveau",
"Clear Dapple Dualies": "clear_dapple_dualies",
"Splat Dualies": "splat_dualies",
"Hero Dualie Replicas": "hero_dualies_replicas",
"Enperry Splat Dualies": "enperry_splat_dualies",
"Kensa Splat Dualies": "kensa_splat_dualies",
"Glooga Dualies": "glooga_dualies",
"Glooga Dualies Deco": "glooga_dualies_deco",
"Kensa Glooga Dualies": "kensa_glooga_dualies",
"Dualie Squelchers": "dualie_squelchers",
"Custom Dualie Squelchers": "custom_dualie_squelchers",
"Dark Tetra Dualies": "dark_tetra_dualies",
"Light Tetra Dualies": "light_tetra_dualies",
"Splat Brella": "splat_brella",
"Hero Brella Replica": "hero_brella_replica",
"Sorella Brella": "sorella_brella",
"Tenta Brella": "tenta_brella",
"Tenta Sorella Brella": "tenta_sorella_brella",
"Tenta Camo Brella": "tenta_camo_brella",
"Undercover Brella": "undercover_brella",
"Undercover Sorella Brella": "undercover_sorella_brella",
"Kensa Undercover Brella": "kensa_undercover_brella",
};

View File

@ -1,141 +0,0 @@
export const weaponMarkdownCodes = {
"sploosh-o-matic": "Sploosh-o-matic",
"neo_sploosh-o-matic": "Neo Sploosh-o-matic",
"sploosh-o-matic_7": "Sploosh-o-matic 7",
splattershot_jr: "Splattershot Jr.",
custom_splattershot_jr: "Custom Splattershot Jr.",
kensa_splattershot_jr: "Kensa Splattershot Jr.",
"splash-o-matic": "Splash-o-matic",
"neo_splash-o-matic": "Neo Splash-o-matic",
aerospray_mg: "Aerospray MG",
aerospray_rg: "Aerospray RG",
aerospray_pg: "Aerospray PG",
splattershot: "Splattershot",
hero_shot_replica: "Hero Shot Replica",
tentatek_splattershot: "Tentatek Splattershot",
octo_shot_replica: "Octo Shot Replica",
kensa_splattershot: "Kensa Splattershot",
"52_gal": ".52 Gal",
"52_gal_deco": ".52 Gal Deco",
kensa_52_gal: "Kensa .52 Gal",
"n-zap_85": "N-ZAP '85",
"n-zap_89": "N-ZAP '89",
"n-zap_83": "N-ZAP '83",
splattershot_pro: "Splattershot Pro",
forge_splattershot_pro: "Forge Splattershot Pro",
kensa_splattershot_pro: "Kensa Splattershot Pro",
"96_gal": ".96 Gal",
"96_gal_deco": ".96 Gal Deco",
jet_squelcher: "Jet Squelcher",
custom_jet_squelcher: "Custom Jet Squelcher",
"l-3_nozzlenose": "L-3 Nozzlenose",
"l-3_nozzlenose_d": "L-3 Nozzlenose D",
"kensa_l-3_nozzlenose": "Kensa L-3 Nozzlenose",
"h-3_nozzlenose": "H-3 Nozzlenose",
"h-3_nozzlenose_d": "H-3 Nozzlenose D",
"cherry_h-3_nozzlenose": "Cherry H-3 Nozzlenose",
squeezer: "Squeezer",
foil_squeezer: "Foil Squeezer",
luna_blaster: "Luna Blaster",
luna_blaster_neo: "Luna Blaster Neo",
kensa_luna_blaster: "Kensa Luna Blaster",
blaster: "Blaster",
hero_blaster_replica: "Hero Blaster Replica",
custom_blaster: "Custom Blaster",
range_blaster: "Range Blaster",
custom_range_blaster: "Custom Range Blaster",
grim_range_blaster: "Grim Range Blaster",
rapid_blaster: "Rapid Blaster",
rapid_blaster_deco: "Rapid Blaster Deco",
kensa_rapid_blaster: "Kensa Rapid Blaster",
rapid_blaster_pro: "Rapid Blaster Pro",
rapid_blaster_pro_deco: "Rapid Blaster Pro Deco",
clash_blaster: "Clash Blaster",
clash_blaster_neo: "Clash Blaster Neo",
carbon_roller: "Carbon Roller",
carbon_roller_deco: "Carbon Roller Deco",
splat_roller: "Splat Roller",
hero_roller_replica: "Hero Roller Replica",
"krak-on_splat_roller": "Krak-On Splat Roller",
kensa_splat_roller: "Kensa Splat Roller",
dynamo_roller: "Dynamo Roller",
gold_dynamo_roller: "Gold Dynamo Roller",
kensa_dynamo_roller: "Kensa Dynamo Roller",
flingza_roller: "Flingza Roller",
foil_flingza_roller: "Foil Flingza Roller",
inkbrush: "Inkbrush",
inkbrush_nouveau: "Inkbrush Nouveau",
permanent_inkbrush: "Permanent Inkbrush",
octobrush: "Octobrush",
herobrush_replica: "Herobrush Replica",
octobrush_nouveau: "Octobrush Nouveau",
kensa_octobrush: "Kensa Octobrush",
classic_squiffer: "Classic Squiffer",
new_squiffer: "New Squiffer",
fresh_squiffer: "Fresh Squiffer",
splat_charger: "Splat Charger",
hero_charger_replica: "Hero Charger Replica",
firefin_splat_charger: "Firefin Splat Charger",
kensa_charger: "Kensa Charger",
splatterscope: "Splatterscope",
firefin_splatterscope: "Firefin Splatterscope",
kensa_splatterscope: "Kensa Splatterscope",
"e-liter_4k": "E-liter 4K",
"custom_e-liter_4k": "Custom E-liter 4K",
"e-liter_4k_scope": "E-liter 4K Scope",
"custom_e-liter_4k_scope": "Custom E-liter 4K Scope",
bamboozler_14_mk_i: "Bamboozler 14 Mk I",
bamboozler_14_mk_ii: "Bamboozler 14 Mk II",
bamboozler_14_mk_iii: "Bamboozler 14 Mk III",
goo_tuber: "Goo Tuber",
custom_goo_tuber: "Custom Goo Tuber",
slosher: "Slosher",
hero_slosher_replica: "Hero Slosher Replica",
slosher_deco: "Slosher Deco",
soda_slosher: "Soda Slosher",
"tri-slosher": "Tri-Slosher",
"tri-slosher_nouveau": "Tri-Slosher Nouveau",
sloshing_machine: "Sloshing Machine",
sloshing_machine_neo: "Sloshing Machine Neo",
kensa_sloshing_machine: "Kensa Sloshing Machine",
bloblobber: "Bloblobber",
bloblobber_deco: "Bloblobber Deco",
explosher: "Explosher",
custom_explosher: "Custom Explosher",
mini_splatling: "Mini Splatling",
zink_mini_splatling: "Zink Mini Splatling",
kensa_mini_splatling: "Kensa Mini Splatling",
heavy_splatling: "Heavy Splatling",
hero_splatling_replica: "Hero Splatling Replica",
heavy_splatling_deco: "Heavy Splatling Deco",
heavy_splatling_remix: "Heavy Splatling Remix",
hydra_splatling: "Hydra Splatling",
custom_hydra_splatling: "Custom Hydra Splatling",
ballpoint_splatling: "Ballpoint Splatling",
ballpoint_splatling_nouveau: "Ballpoint Splatling Nouveau",
nautilus_47: "Nautilus 47",
nautilus_79: "Nautilus 79",
dapple_dualies: "Dapple Dualies",
dapple_dualies_nouveau: "Dapple Dualies Nouveau",
clear_dapple_dualies: "Clear Dapple Dualies",
splat_dualies: "Splat Dualies",
hero_dualies_replicas: "Hero Dualie Replicas",
enperry_splat_dualies: "Enperry Splat Dualies",
kensa_splat_dualies: "Kensa Splat Dualies",
glooga_dualies: "Glooga Dualies",
glooga_dualies_deco: "Glooga Dualies Deco",
kensa_glooga_dualies: "Kensa Glooga Dualies",
dualie_squelchers: "Dualie Squelchers",
custom_dualie_squelchers: "Custom Dualie Squelchers",
dark_tetra_dualies: "Dark Tetra Dualies",
light_tetra_dualies: "Light Tetra Dualies",
splat_brella: "Splat Brella",
hero_brella_replica: "Hero Brella Replica",
sorella_brella: "Sorella Brella",
tenta_brella: "Tenta Brella",
tenta_sorella_brella: "Tenta Sorella Brella",
tenta_camo_brella: "Tenta Camo Brella",
undercover_brella: "Undercover Brella",
undercover_sorella_brella: "Undercover Sorella Brella",
kensa_undercover_brella: "Kensa Undercover Brella",
} as const;

View File

@ -0,0 +1,32 @@
import { PrismaClient } from "@prisma/client";
import { codeToWeapon } from "lib/lists/weaponCodes";
import { NextApiRequest, NextApiResponse } from "next";
import {
getBuildsByWeapon,
GetBuildsByWeaponData,
} from "prisma/queries/getBuildsByWeapon";
const prisma = new PrismaClient();
const weaponHandler = async (
req: NextApiRequest,
res: NextApiResponse<GetBuildsByWeaponData>
) => {
if (req.method !== "GET") {
return res.status(405).end();
}
const key = req.query.weapon as keyof typeof codeToWeapon;
const weapon = codeToWeapon[key];
if (!weapon) return res.status(400).end();
const builds = await getBuildsByWeapon({
prisma,
weapon,
});
res.status(200).json(builds);
};
export default weaponHandler;

View File

@ -0,0 +1,28 @@
import { t } from "@lingui/macro";
import Breadcrumbs from "components/common/Breadcrumbs";
import WeaponSelector from "components/common/WeaponSelector";
import { weaponToCode } from "lib/lists/weaponCodes";
import { useState } from "react";
import useSWR from "swr";
const BuildsPage = () => {
const [weapon, setWeapon] = useState("");
const { data } = useSWR(() => {
if (!weapon) return null;
const key = weapon as keyof typeof weaponToCode;
return `/api/builds/${weaponToCode[key]}`;
});
console.log({ data });
return (
<>
<Breadcrumbs pages={[{ name: t`Builds` }]} />
<WeaponSelector value={weapon} onChange={setWeapon} excludeAlt />
</>
);
};
export default BuildsPage;

View File

@ -144,6 +144,7 @@ const XSearchPage = ({ placements, monthOptions }: Props) => {
);
}, [variables]);
//FIXME: layout can be persistent between route changes
return (
<>
<Breadcrumbs pages={[{ name: t`Top 500 Browser` }]} />

View File

@ -0,0 +1,124 @@
# Migration `20201109002900-init`
This migration has been generated by Kalle (Sendou) at 11/9/2020, 2:29:00 AM.
You can check out the [state of the schema](./schema.prisma) after the migration.
## Database Steps
```sql
CREATE TYPE "public"."Ability" AS ENUM ('CB', 'LDE', 'OG', 'T', 'H', 'NS', 'TI', 'RP', 'AD', 'DR', 'SJ', 'OS', 'BDU', 'REC', 'RES', 'ISM', 'ISS', 'MPU', 'QR', 'QSJ', 'RSU', 'SSU', 'SCU', 'SPU', 'SS', 'BRU')
CREATE TABLE "public"."Build" (
"id" SERIAL,
"userId" integer NOT NULL ,
"weapon" text NOT NULL ,
"title" text ,
"description" text ,
"mainAbilities" "Ability"[] ,
"subAbilities" "Ability"[] ,
"abilityPoints" jsonb NOT NULL ,
"headGear" text ,
"clothingGear" text ,
"shoesGear" text ,
"top500" boolean NOT NULL ,
"jpn" boolean NOT NULL ,
PRIMARY KEY ("id")
)
CREATE INDEX "Build.weapon_index" ON "public"."Build"("weapon")
CREATE INDEX "Build.userId_index" ON "public"."Build"("userId")
CREATE INDEX "Build.abilityPoints_index" ON "public"."Build"("abilityPoints")
ALTER TABLE "public"."Build" ADD FOREIGN KEY("userId")REFERENCES "public"."User"("id") ON DELETE CASCADE ON UPDATE CASCADE
```
## Changes
```diff
diff --git schema.prisma schema.prisma
migration 20201103144752-init..20201109002900-init
--- datamodel.dml
+++ datamodel.dml
@@ -1,8 +1,8 @@
datasource db {
provider = "postgresql"
// FIXME: should use same .env system as Next.JS
- url = "***"
+ url = "***"
}
generator client {
provider = "prisma-client-js"
@@ -15,8 +15,9 @@
discordId String @unique
discordAvatar String?
profile Profile?
player Player?
+ Build Build[]
}
model Profile {
twitterName String?
@@ -56,9 +57,59 @@
}
model Player {
switchAccountId String @unique
- user User? @relation(fields: [userId], references: [id])
userId Int? @unique
name String
placements XRankPlacement[]
+ user User? @relation(fields: [userId], references: [id])
}
+
+enum Ability {
+ CB
+ LDE
+ OG
+ T
+ H
+ NS
+ TI
+ RP
+ AD
+ DR
+ SJ
+ OS
+ BDU
+ REC
+ RES
+ ISM
+ ISS
+ MPU
+ QR
+ QSJ
+ RSU
+ SSU
+ SCU
+ SPU
+ SS
+ BRU
+}
+
+model Build {
+ id Int @id @default(autoincrement())
+ userId Int
+ weapon String
+ title String?
+ description String?
+ mainAbilities Ability[]
+ subAbilities Ability[]
+ abilityPoints Json
+ headGear String?
+ clothingGear String?
+ shoesGear String?
+ top500 Boolean
+ jpn Boolean
+ user User @relation(fields: [userId], references: [id])
+
+ @@index(weapon)
+ @@index(userId)
+ @@index(abilityPoints)
+}
```

View File

@ -0,0 +1,115 @@
datasource db {
provider = "postgresql"
// FIXME: should use same .env system as Next.JS
url = "***"
}
generator client {
provider = "prisma-client-js"
}
model User {
id Int @id @default(autoincrement())
username String
discriminator String
discordId String @unique
discordAvatar String?
profile Profile?
player Player?
Build Build[]
}
model Profile {
twitterName String?
twitchName String?
youtubeId String?
country String?
sensMotion Float?
sensStick Float?
bio String?
weaponPool String[]
customUrlPath String? @unique
user User @relation(fields: [userId], references: [id])
userId Int @unique
}
enum RankedMode {
SZ
TC
RM
CB
}
model XRankPlacement {
id Int @id @default(autoincrement())
switchAccountId String
player Player @relation(fields: [switchAccountId], references: [switchAccountId])
playerName String
ranking Int
xPower Float
weapon String
mode RankedMode
month Int
year Int
@@unique([switchAccountId, mode, month, year])
}
model Player {
switchAccountId String @unique
userId Int? @unique
name String
placements XRankPlacement[]
user User? @relation(fields: [userId], references: [id])
}
enum Ability {
CB
LDE
OG
T
H
NS
TI
RP
AD
DR
SJ
OS
BDU
REC
RES
ISM
ISS
MPU
QR
QSJ
RSU
SSU
SCU
SPU
SS
BRU
}
model Build {
id Int @id @default(autoincrement())
userId Int
weapon String
title String?
description String?
mainAbilities Ability[]
subAbilities Ability[]
abilityPoints Json
headGear String?
clothingGear String?
shoesGear String?
top500 Boolean
jpn Boolean
user User @relation(fields: [userId], references: [id])
@@index(weapon)
@@index(userId)
@@index(abilityPoints)
}

View File

@ -0,0 +1,269 @@
{
"version": "0.3.14-fixed",
"steps": [
{
"tag": "CreateEnum",
"enum": "Ability",
"values": [
"CB",
"LDE",
"OG",
"T",
"H",
"NS",
"TI",
"RP",
"AD",
"DR",
"SJ",
"OS",
"BDU",
"REC",
"RES",
"ISM",
"ISS",
"MPU",
"QR",
"QSJ",
"RSU",
"SSU",
"SCU",
"SPU",
"SS",
"BRU"
]
},
{
"tag": "CreateModel",
"model": "Build"
},
{
"tag": "CreateField",
"model": "Build",
"field": "id",
"type": "Int",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Build",
"field": "id"
},
"directive": "id"
}
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Build",
"field": "id"
},
"directive": "default"
}
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "Build",
"field": "id"
},
"directive": "default"
},
"argument": "",
"value": "autoincrement()"
},
{
"tag": "CreateField",
"model": "Build",
"field": "userId",
"type": "Int",
"arity": "Required"
},
{
"tag": "CreateField",
"model": "Build",
"field": "weapon",
"type": "String",
"arity": "Required"
},
{
"tag": "CreateField",
"model": "Build",
"field": "title",
"type": "String",
"arity": "Optional"
},
{
"tag": "CreateField",
"model": "Build",
"field": "description",
"type": "String",
"arity": "Optional"
},
{
"tag": "CreateField",
"model": "Build",
"field": "mainAbilities",
"type": "Ability",
"arity": "List"
},
{
"tag": "CreateField",
"model": "Build",
"field": "subAbilities",
"type": "Ability",
"arity": "List"
},
{
"tag": "CreateField",
"model": "Build",
"field": "abilityPoints",
"type": "Json",
"arity": "Required"
},
{
"tag": "CreateField",
"model": "Build",
"field": "headGear",
"type": "String",
"arity": "Optional"
},
{
"tag": "CreateField",
"model": "Build",
"field": "clothingGear",
"type": "String",
"arity": "Optional"
},
{
"tag": "CreateField",
"model": "Build",
"field": "shoesGear",
"type": "String",
"arity": "Optional"
},
{
"tag": "CreateField",
"model": "Build",
"field": "top500",
"type": "Boolean",
"arity": "Required"
},
{
"tag": "CreateField",
"model": "Build",
"field": "jpn",
"type": "Boolean",
"arity": "Required"
},
{
"tag": "CreateField",
"model": "Build",
"field": "user",
"type": "User",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Build",
"field": "user"
},
"directive": "relation"
}
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "Build",
"field": "user"
},
"directive": "relation"
},
"argument": "fields",
"value": "[userId]"
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "Build",
"field": "user"
},
"directive": "relation"
},
"argument": "references",
"value": "[id]"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Model",
"model": "Build",
"arguments": [
{
"name": "",
"value": "weapon"
}
]
},
"directive": "index"
}
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Model",
"model": "Build",
"arguments": [
{
"name": "",
"value": "userId"
}
]
},
"directive": "index"
}
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Model",
"model": "Build",
"arguments": [
{
"name": "",
"value": "abilityPoints"
}
]
},
"directive": "index"
}
},
{
"tag": "CreateField",
"model": "User",
"field": "Build",
"type": "Build",
"arity": "List"
}
]
}

View File

@ -0,0 +1,39 @@
# Migration `20201109140409-init`
This migration has been generated by Kalle (Sendou) at 11/9/2020, 4:04:09 PM.
You can check out the [state of the schema](./schema.prisma) after the migration.
## Database Steps
```sql
ALTER TABLE "public"."Build" ADD COLUMN "updatedAt" timestamp(3) NOT NULL
```
## Changes
```diff
diff --git schema.prisma schema.prisma
migration 20201109002900-init..20201109140409-init
--- datamodel.dml
+++ datamodel.dml
@@ -1,8 +1,8 @@
datasource db {
provider = "postgresql"
// FIXME: should use same .env system as Next.JS
- url = "***"
+ url = "***"
}
generator client {
provider = "prisma-client-js"
@@ -106,8 +106,9 @@
clothingGear String?
shoesGear String?
top500 Boolean
jpn Boolean
+ updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id])
@@index(weapon)
@@index(userId)
```

View File

@ -0,0 +1,116 @@
datasource db {
provider = "postgresql"
// FIXME: should use same .env system as Next.JS
url = "***"
}
generator client {
provider = "prisma-client-js"
}
model User {
id Int @id @default(autoincrement())
username String
discriminator String
discordId String @unique
discordAvatar String?
profile Profile?
player Player?
Build Build[]
}
model Profile {
twitterName String?
twitchName String?
youtubeId String?
country String?
sensMotion Float?
sensStick Float?
bio String?
weaponPool String[]
customUrlPath String? @unique
user User @relation(fields: [userId], references: [id])
userId Int @unique
}
enum RankedMode {
SZ
TC
RM
CB
}
model XRankPlacement {
id Int @id @default(autoincrement())
switchAccountId String
player Player @relation(fields: [switchAccountId], references: [switchAccountId])
playerName String
ranking Int
xPower Float
weapon String
mode RankedMode
month Int
year Int
@@unique([switchAccountId, mode, month, year])
}
model Player {
switchAccountId String @unique
userId Int? @unique
name String
placements XRankPlacement[]
user User? @relation(fields: [userId], references: [id])
}
enum Ability {
CB
LDE
OG
T
H
NS
TI
RP
AD
DR
SJ
OS
BDU
REC
RES
ISM
ISS
MPU
QR
QSJ
RSU
SSU
SCU
SPU
SS
BRU
}
model Build {
id Int @id @default(autoincrement())
userId Int
weapon String
title String?
description String?
mainAbilities Ability[]
subAbilities Ability[]
abilityPoints Json
headGear String?
clothingGear String?
shoesGear String?
top500 Boolean
jpn Boolean
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id])
@@index(weapon)
@@index(userId)
@@index(abilityPoints)
}

View File

@ -0,0 +1,23 @@
{
"version": "0.3.14-fixed",
"steps": [
{
"tag": "CreateField",
"model": "Build",
"field": "updatedAt",
"type": "DateTime",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Build",
"field": "updatedAt"
},
"directive": "updatedAt"
}
}
]
}

View File

@ -1,3 +1,5 @@
# Prisma Migrate lockfile v1
20201103144752-init
20201103144752-init
20201109002900-init
20201109140409-init

View File

@ -0,0 +1,19 @@
import { PrismaClient } from "@prisma/client";
import { Unwrap } from "lib/types";
export type GetBuildsByWeaponData = Unwrap<
ReturnType<typeof getBuildsByWeapon>
>;
export const getBuildsByWeapon = async ({
prisma,
weapon,
}: {
prisma: PrismaClient;
weapon: string;
}) => {
return prisma.build.findMany({
where: { weapon },
orderBy: [{ top500: "desc" }, { jpn: "desc" }, { updatedAt: "desc" }],
});
};

View File

@ -16,6 +16,7 @@ model User {
discordAvatar String?
profile Profile?
player Player?
Build Build[]
}
model Profile {
@ -57,8 +58,59 @@ model XRankPlacement {
model Player {
switchAccountId String @unique
user User? @relation(fields: [userId], references: [id])
userId Int? @unique
name String
placements XRankPlacement[]
user User? @relation(fields: [userId], references: [id])
}
enum Ability {
CB
LDE
OG
T
H
NS
TI
RP
AD
DR
SJ
OS
BDU
REC
RES
ISM
ISS
MPU
QR
QSJ
RSU
SSU
SCU
SPU
SS
BRU
}
model Build {
id Int @id @default(autoincrement())
userId Int
weapon String
title String?
description String?
mainAbilities Ability[]
subAbilities Ability[]
abilityPoints Json
headGear String?
clothingGear String?
shoesGear String?
top500 Boolean
jpn Boolean
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id])
@@index(weapon)
@@index(userId)
@@index(abilityPoints)
}

View File

@ -77,7 +77,7 @@ const main = async () => {
mode: mode as "SZ" | "TC" | "RM" | "CB",
month: 12,
year: 2020,
ranking: Math.ceil((i + 1) / 4),
ranking,
xPower: 3000 - i * 0.5,
weapon: "Splattershot Jr.",
player:
@ -107,6 +107,30 @@ const main = async () => {
);
console.log("X Rank placements created");
await prisma.build.deleteMany({});
await prisma.build.create({
data: {
user: {
connect: {
id: testUser.id,
},
},
weapon: "Splattershot Jr.",
mainAbilities: ["SS", "SS", "SS"],
subAbilities: ["SS", "SS", "SS", "SS", "SS", "SS", "SS", "SS", "SS"],
title: "Amazing test build",
description: "Just testing.",
top500: true,
jpn: false,
abilityPoints: {
SS: 57,
},
},
});
console.log("Builds created");
};
main()