Compare commits
4 Commits
e073cfcad1
...
8400ec7632
| Author | SHA1 | Date | |
|---|---|---|---|
| 8400ec7632 | |||
| d72d635702 | |||
| b41265842f | |||
| b8f338dbd5 |
@@ -1,3 +1,13 @@
|
|||||||
export function Agent({side}: {side: "T" | "CT"}) {
|
import { Surface } from "@heroui/react";
|
||||||
return <>{side}</>
|
|
||||||
}
|
export function Agent({ agent_id }: { agent_id: string }) {
|
||||||
|
return (
|
||||||
|
<Surface className="bg-[#1f2937] flex justify-center flex-1 min-h-0 p-4">
|
||||||
|
<img
|
||||||
|
src={`/skins/${agent_id}_big.png`}
|
||||||
|
className="pointer-events-none object-contain object-bottom h-full w-full"
|
||||||
|
alt="Agent image"
|
||||||
|
/>
|
||||||
|
</Surface>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,12 +4,22 @@ import { Agent } from "./agent";
|
|||||||
import { Weapon } from "./weapon";
|
import { Weapon } from "./weapon";
|
||||||
import { useNotification } from "~/hooks/notification";
|
import { useNotification } from "~/hooks/notification";
|
||||||
|
|
||||||
|
interface SkinInfo {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
color: string;
|
||||||
|
display: string;
|
||||||
|
paint_index: number;
|
||||||
|
float: number;
|
||||||
|
pattern: number;
|
||||||
|
}
|
||||||
|
|
||||||
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<SkinInfo>();
|
||||||
const [gloves, setGloves] = useState({ name: "", color: "", display: "", paint_index: 0, float: 0.0, pattern: 0 });
|
const [gloves, setGloves] = useState<SkinInfo>();
|
||||||
const [knife, setKnife] = useState({ name: "", color: "", display: "", paint_index: 0, float: 0.0, pattern: 0 });
|
const [knife, setKnife] = useState<SkinInfo>();
|
||||||
const [weapons, setWeapons] = useState([]);
|
const [weapons, setWeapons] = useState<Array<SkinInfo>>([]);
|
||||||
const { notify } = useNotification();
|
const { notify } = useNotification();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -50,7 +60,46 @@ export function Inventory({ side }: { side: "T" | "CT" }) {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
setGloves(response[0])
|
setGloves(response[0]);
|
||||||
|
|
||||||
|
response = await fetch(
|
||||||
|
`${import.meta.env.VITE_BASE_API_URL}/skin?team=${side}`,
|
||||||
|
{ credentials: "include" },
|
||||||
|
)
|
||||||
|
.then((r) => r.json())
|
||||||
|
.catch((e) => {
|
||||||
|
notify(
|
||||||
|
{
|
||||||
|
type: "danger",
|
||||||
|
loading: false,
|
||||||
|
title: "An error occured.",
|
||||||
|
message: `An error occured: ${e}`,
|
||||||
|
},
|
||||||
|
10000,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
setWeapons(response);
|
||||||
|
|
||||||
|
response = await fetch(
|
||||||
|
`${import.meta.env.VITE_BASE_API_URL}/agent?team=${side}`,
|
||||||
|
{ credentials: "include" },
|
||||||
|
)
|
||||||
|
.then((r) => r.json())
|
||||||
|
.catch((e) => {
|
||||||
|
notify(
|
||||||
|
{
|
||||||
|
type: "danger",
|
||||||
|
loading: false,
|
||||||
|
title: "An error occured.",
|
||||||
|
message: `An error occured: ${e}`,
|
||||||
|
},
|
||||||
|
10000,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
setAgent(response);
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -68,11 +117,11 @@ export function Inventory({ side }: { side: "T" | "CT" }) {
|
|||||||
className="flex flex-col rounded-xl w-1/3 p-4 gap-2"
|
className="flex flex-col rounded-xl w-1/3 p-4 gap-2"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
>
|
>
|
||||||
<Skeleton className="flex-1 h-40 w-full rounded-xl" />
|
<Skeleton className="flex-1 h-55 w-full rounded-xl" />
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Skeleton className="flex-1 h-40 rounded-xl" />
|
<Skeleton className="flex-1 h-55 rounded-xl" />
|
||||||
<Skeleton className="flex-1 h-40 rounded-xl" />
|
<Skeleton className="flex-1 h-55 rounded-xl" />
|
||||||
<Skeleton className="flex-1 h-40 rounded-xl" />
|
<Skeleton className="flex-1 h-55 rounded-xl" />
|
||||||
</div>
|
</div>
|
||||||
</Surface>
|
</Surface>
|
||||||
<Surface
|
<Surface
|
||||||
@@ -81,7 +130,10 @@ export function Inventory({ side }: { side: "T" | "CT" }) {
|
|||||||
>
|
>
|
||||||
<div className="absolute inset-4 flex-1 grid grid-cols-5 gap-2 overflow-y-scroll">
|
<div className="absolute inset-4 flex-1 grid grid-cols-5 gap-2 overflow-y-scroll">
|
||||||
{Array.from({ length: 50 }, (_, index) => (
|
{Array.from({ length: 50 }, (_, index) => (
|
||||||
<Skeleton key={index} className="flex-1 h-40 rounded-xl" />
|
<Skeleton
|
||||||
|
key={index}
|
||||||
|
className="flex-1 h-55 rounded-xl"
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</Surface>
|
</Surface>
|
||||||
@@ -91,31 +143,38 @@ export function Inventory({ side }: { side: "T" | "CT" }) {
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-1 gap-2 min-h-0">
|
<div className="flex flex-1 gap-2 min-h-0">
|
||||||
<Surface
|
<Surface
|
||||||
className="flex flex-col rounded-xl w-1/3 p-4 gap-2"
|
className="flex flex-col rounded-xl w-1/3 p-4 gap-2 min-h-0"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
>
|
>
|
||||||
<Agent side={side}></Agent>
|
{agent && <Agent agent_id={agent["name"]}></Agent>}
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Weapon
|
{knife && (
|
||||||
weapon_id={knife["name"]}
|
<Weapon
|
||||||
color={knife["color"]}
|
weapon_id={knife["name"]}
|
||||||
paint_index={knife["paint_index"]}
|
color={knife["color"]}
|
||||||
display={knife["display"]}
|
paint_index={knife["paint_index"]}
|
||||||
float={knife["float"]}
|
display={knife["display"]}
|
||||||
pattern={knife["pattern"]}
|
float={knife["float"]}
|
||||||
></Weapon>
|
pattern={knife["pattern"]}
|
||||||
<Weapon
|
></Weapon>
|
||||||
weapon_id={gloves["name"]}
|
)}
|
||||||
color={gloves["color"]}
|
{gloves && (
|
||||||
paint_index={gloves["paint_index"]}
|
<Weapon
|
||||||
display={gloves["display"]}
|
weapon_id={gloves["name"]}
|
||||||
float={gloves["float"]}
|
color={gloves["color"]}
|
||||||
pattern={gloves["pattern"]}
|
paint_index={gloves["paint_index"]}
|
||||||
></Weapon>
|
display={gloves["display"]}
|
||||||
<Weapon
|
float={gloves["float"]}
|
||||||
weapon_id={"agent-4730"}
|
pattern={gloves["pattern"]}
|
||||||
color="#8847ff"
|
></Weapon>
|
||||||
></Weapon>
|
)}
|
||||||
|
{agent && (
|
||||||
|
<Weapon
|
||||||
|
weapon_id={agent["name"]}
|
||||||
|
color={agent["color"]}
|
||||||
|
display={agent["display"]}
|
||||||
|
></Weapon>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Surface>
|
</Surface>
|
||||||
<Surface
|
<Surface
|
||||||
@@ -123,11 +182,15 @@ export function Inventory({ side }: { side: "T" | "CT" }) {
|
|||||||
variant="secondary"
|
variant="secondary"
|
||||||
>
|
>
|
||||||
<div className="absolute inset-4 flex-1 grid grid-cols-5 gap-2 overflow-y-scroll">
|
<div className="absolute inset-4 flex-1 grid grid-cols-5 gap-2 overflow-y-scroll">
|
||||||
{Array.from({ length: 50 }, (_, index) => (
|
{weapons.map((v, i) => (
|
||||||
<Weapon
|
<Weapon
|
||||||
key={index}
|
key={i}
|
||||||
weapon_id="weapon_ak47"
|
weapon_id={v.name}
|
||||||
color="#e4ae39"
|
color={v.color}
|
||||||
|
paint_index={v.paint_index}
|
||||||
|
display={v.display}
|
||||||
|
float={v.float}
|
||||||
|
pattern={v.pattern}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ export function Weapon({
|
|||||||
weapon_id,
|
weapon_id,
|
||||||
color,
|
color,
|
||||||
display = "Weapon",
|
display = "Weapon",
|
||||||
float = 0,
|
float,
|
||||||
pattern = 0,
|
pattern,
|
||||||
paint_index = 0,
|
paint_index = 0,
|
||||||
}: {
|
}: {
|
||||||
weapon_id: string;
|
weapon_id: string;
|
||||||
@@ -27,21 +27,24 @@ export function Weapon({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
src={`/skins/${weapon_id}_${paint_index}.png`}
|
src={`/skins/${weapon_id}_${paint_index || 0}.png`}
|
||||||
className="pointer-events-none object-contain object-bottom h-full"
|
className="pointer-events-none object-contain object-bottom h-full"
|
||||||
|
alt="Weapon image"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className={`h-1 w-full`}
|
className={`h-1 w-full`}
|
||||||
style={{ background: `${color}` }}
|
style={{ background: `${color}` }}
|
||||||
></div>
|
></div>
|
||||||
<Typography.Heading level={6} className="px-2 text-wrap">
|
<Typography.Heading level={6} className="px-2 py-1 text-wrap">
|
||||||
{display}
|
{display}
|
||||||
</Typography.Heading>
|
</Typography.Heading>
|
||||||
<Float float={float} />
|
{float !== undefined && <Float float={float} />}
|
||||||
<Typography.Paragraph className="px-2">
|
{pattern !== undefined && (
|
||||||
Pattern: {pattern}
|
<Typography.Paragraph className="px-2">
|
||||||
</Typography.Paragraph>
|
Pattern: {pattern}
|
||||||
|
</Typography.Paragraph>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,11 +6,12 @@ import { Header } from "~/components/header";
|
|||||||
export default function Base({
|
export default function Base({
|
||||||
children,
|
children,
|
||||||
needsLogin = false,
|
needsLogin = false,
|
||||||
}: PropsWithChildren<{ needsLogin?: boolean }>) {
|
fixedHeight = false,
|
||||||
|
}: PropsWithChildren<{ needsLogin?: boolean, fixedHeight?: boolean }>) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="flex flex-col pt-20 min-h-dvh">
|
<div className={`flex flex-col pt-20 min-h-dvh ${fixedHeight && "h-dvh"}`}>
|
||||||
<div className="flex flex-col flex-1">
|
<div className="flex flex-col flex-1 min-h-0">
|
||||||
{needsLogin ? <Guard>{children}</Guard> : children}
|
{needsLogin ? <Guard>{children}</Guard> : children}
|
||||||
</div>
|
</div>
|
||||||
<Footer />
|
<Footer />
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { Inventory } from "~/components/inventory";
|
|||||||
export function InventoryPage() {
|
export function InventoryPage() {
|
||||||
const [side, setSide] = useState<"T" | "CT">("T");
|
const [side, setSide] = useState<"T" | "CT">("T");
|
||||||
return (
|
return (
|
||||||
<Base needsLogin>
|
<Base needsLogin fixedHeight>
|
||||||
<Surface
|
<Surface
|
||||||
className="flex flex-col flex-1 min-h-0 h-0 shadow-lg shadow-indigo-900 ring-1 ring-indigo-800 p-2 m-2 rounded-3xl gap-2"
|
className="flex flex-col flex-1 min-h-0 h-0 shadow-lg shadow-indigo-900 ring-1 ring-indigo-800 p-2 m-2 rounded-3xl gap-2"
|
||||||
variant="default"
|
variant="default"
|
||||||
|
|||||||
Reference in New Issue
Block a user