Updated to use new api and new weapon display

This commit is contained in:
2026-09-08 18:26:28 +02:00
parent 843bf30cae
commit 77583597b5

View File

@@ -7,15 +7,15 @@ import { useNotification } from "~/hooks/notification";
export function Inventory({ side }: { side: "T" | "CT" }) { export function Inventory({ side }: { side: "T" | "CT" }) {
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [agent, setAgent] = useState({}); const [agent, setAgent] = useState({});
const [gloves, setGloves] = useState({ name: "", color: "", paint_index: 0 }); const [gloves, setGloves] = useState({ name: "", color: "", display: "", paint_index: 0, float: 0.0, pattern: 0 });
const [knife, setKnife] = useState({ name: "", color: "", paint_index: 0 }); const [knife, setKnife] = useState({ name: "", color: "", display: "", paint_index: 0, float: 0.0, pattern: 0 });
const [weapons, setWeapons] = useState([]); const [weapons, setWeapons] = useState([]);
const { notify } = useNotification(); const { notify } = useNotification();
useEffect(() => { useEffect(() => {
const fetch_weapons = async () => { const fetch_weapons = async () => {
let response = await fetch( let response = await fetch(
`${import.meta.env.VITE_BASE_API_URL}/knife?team=${side}`, `${import.meta.env.VITE_BASE_API_URL}/skin?team=${side}&category=Knives`,
{ credentials: "include" }, { credentials: "include" },
) )
.then((r) => r.json()) .then((r) => r.json())
@@ -31,10 +31,10 @@ export function Inventory({ side }: { side: "T" | "CT" }) {
); );
}); });
setKnife(response); setKnife(response[0]);
response = await fetch( response = await fetch(
`${import.meta.env.VITE_BASE_API_URL}/gloves?team=${side}`, `${import.meta.env.VITE_BASE_API_URL}/skin?team=${side}&category=Gloves`,
{ credentials: "include" }, { credentials: "include" },
) )
.then((r) => r.json()) .then((r) => r.json())
@@ -50,7 +50,7 @@ export function Inventory({ side }: { side: "T" | "CT" }) {
); );
}); });
setGloves(response) setGloves(response[0])
setLoading(false); setLoading(false);
}; };
@@ -100,11 +100,17 @@ export function Inventory({ side }: { side: "T" | "CT" }) {
weapon_id={knife["name"]} weapon_id={knife["name"]}
color={knife["color"]} color={knife["color"]}
paint_index={knife["paint_index"]} paint_index={knife["paint_index"]}
display={knife["display"]}
float={knife["float"]}
pattern={knife["pattern"]}
></Weapon> ></Weapon>
<Weapon <Weapon
weapon_id={gloves["name"]} weapon_id={gloves["name"]}
color={gloves["color"]} color={gloves["color"]}
paint_index={gloves["paint_index"]} paint_index={gloves["paint_index"]}
display={gloves["display"]}
float={gloves["float"]}
pattern={gloves["pattern"]}
></Weapon> ></Weapon>
<Weapon <Weapon
weapon_id={"agent-4730"} weapon_id={"agent-4730"}