diff --git a/src/components/AmbassadorCard.tsx b/src/components/AmbassadorCard.tsx index eb292b2..75799f1 100644 --- a/src/components/AmbassadorCard.tsx +++ b/src/components/AmbassadorCard.tsx @@ -2,6 +2,7 @@ import { useCallback, useEffect, useRef, type Ref } from "react"; import type { CreateTypes } from "canvas-confetti"; import Confetti from "react-canvas-confetti"; +import { getSpecies } from "../../../data/src/ambassadors/species"; import { calculateAge, formatDate, isBirthday } from "../utils/dateManager"; import { useAmbassador } from "../hooks/useAmbassadors"; import { camelToKebab } from "../utils/helpers"; @@ -119,6 +120,8 @@ export default function AmbassadorCard(props: AmbassadorCardProps) { if (!ambassador) return null; + const species = getSpecies(ambassador.species); + return ( <> {birthday && } @@ -185,9 +188,9 @@ export default function AmbassadorCard(props: AmbassadorCardProps) {

Species

-

{ambassador.species}

+

{species.name}

- {ambassador.scientific}{" "} + {species.scientificName}{" "} ({ambassador.class.title}) @@ -252,20 +255,20 @@ export default function AmbassadorCard(props: AmbassadorCardProps) {

Native To

-

{ambassador.native.text}

+

{species.native.text}

Species Lifespan

Wild:{" "} - {"wild" in ambassador.lifespan && - ambassador.lifespan.wild !== undefined ? ( + {"wild" in species.lifespan && + species.lifespan.wild !== undefined ? ( <> ~ - {stringifyLifespan(ambassador.lifespan.wild)} years + {stringifyLifespan(species.lifespan.wild)} years ) : ( "Unknown" @@ -273,13 +276,13 @@ export default function AmbassadorCard(props: AmbassadorCardProps) {

Captivity:{" "} - {"captivity" in ambassador.lifespan && - ambassador.lifespan.captivity !== undefined ? ( + {"captivity" in species.lifespan && + species.lifespan.captivity !== undefined ? ( <> ~ - {stringifyLifespan(ambassador.lifespan.captivity)} years + {stringifyLifespan(species.lifespan.captivity)} years ) : ( "Unknown" diff --git a/src/hooks/useAmbassadors.tsx b/src/hooks/useAmbassadors.tsx index bb0011e..4b19fce 100644 --- a/src/hooks/useAmbassadors.tsx +++ b/src/hooks/useAmbassadors.tsx @@ -10,14 +10,18 @@ import { z } from "zod"; import allAmbassadors, { ambassadorSchema, -} from "@alveusgg/data/src/ambassadors/core"; -import { isActiveAmbassadorEntry } from "@alveusgg/data/src/ambassadors/filters"; -import { getClassification } from "@alveusgg/data/src/ambassadors/classification"; +} from "../../../data/src/ambassadors/core"; +import { isActiveAmbassadorEntry } from "../../../data/src/ambassadors/filters"; +import { getClassification } from "../../../data/src/ambassadors/classification"; import { getAmbassadorImages, ambassadorImageSchema, -} from "@alveusgg/data/src/ambassadors/images"; -import { getIUCNStatus } from "@alveusgg/data/src/iucn"; +} from "../../../data/src/ambassadors/images"; +import { getIUCNStatus } from "../../../data/src/iucn"; +import { + getSpecies, + speciesSchema, +} from "../../../data/src/ambassadors/species"; import { typeSafeObjectEntries, @@ -29,7 +33,7 @@ import winstonImage from "../assets/winston.png"; // These schema should match the type exposed by the API const apiAmbassadorSchema = ambassadorSchema.extend({ image: ambassadorImageSchema, - iucn: ambassadorSchema.shape.iucn.extend({ + iucn: speciesSchema.shape.iucn.extend({ title: z.string(), }), class: z.object({ @@ -65,6 +69,7 @@ const fallbackAmbassadors: Record = .filter(isActiveAmbassadorEntry) .map<[string, Ambassador]>(([key, val]) => { const image = getAmbassadorImages(key)[0]; + const species = getSpecies(val.species); return [ key, @@ -72,8 +77,8 @@ const fallbackAmbassadors: Record = ...val, image, iucn: { - ...val.iucn, - title: getIUCNStatus(val.iucn.status), + ...species.iucn, + title: getIUCNStatus(species.iucn.status), }, class: { name: val.class, @@ -136,8 +141,7 @@ const winston = { name: "mammalia", title: getClassification("mammalia"), }, - species: "Polar Bear", - scientific: "Twitchus memeticus", + species: "winston", sex: "Male", birth: "2020-04-01", arrival: "2022-12-01", @@ -152,14 +156,6 @@ const winston = { "Winston was rescued by the Ontario Zoo in Canada after it was noticed that he was watching streams too often and not touching grass. Originally on loan to Alveus for two years, he is now a permanent resident of Texas.", mission: "He is an ambassador for stream-life balance and encouraging all chatters to step away from their devices more often.", - native: { - text: "Twitch chat (including the Animals, Aquariums, & Zoos category), miscellaneous emote services", - source: - "https://clips.twitch.tv/TangibleFurryTortoiseBCWarrior-izyQ3nOgq1pYe1rc", // https://clips.twitch.tv/CleverSecretiveAntChocolateRain--zjm5eRw6zxG75Up - }, - lifespan: { - source: "", - }, clips: [], homepage: null, plush: null,