Skip to content

Commit

Permalink
roblox asset name
Browse files Browse the repository at this point in the history
  • Loading branch information
albertfolch-redeemeum committed Jan 16, 2025
1 parent 30cdd74 commit d8bbc08
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export const TokenGatedItem = ({
},
{ enabled: !!(erc1155Uri && erc1155Uri[0] && tokenIdForImage) }
);
const { data: { Name: RobloxItemName = "" } = {} } = useRobloxGetItemDetails({
const { data: { name: robloxItemName = "" } = {} } = useRobloxGetItemDetails({
itemId: robloxGatedAssetId || "",
options: {
enabled: !!robloxGatedAssetId
Expand Down Expand Up @@ -445,7 +445,7 @@ export const TokenGatedItem = ({
width="auto"
>
<Grid flexDirection="column" alignItems="flex-start">
{RobloxItemName || erc1155Info} {rangeText}
{robloxItemName || erc1155Info} {rangeText}
</Grid>
</Grid>
</Grid>
Expand Down
41 changes: 15 additions & 26 deletions packages/react-kit/src/hooks/roblox/useRobloxGetItemDetails.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useQuery } from "react-query";
import * as yup from "yup";
import { useRobloxConfigContext } from "./context/useRobloxConfigContext";

type UseRobloxGetItemDetailsProps = {
itemId: string;
Expand All @@ -9,41 +10,29 @@ type UseRobloxGetItemDetailsProps = {
};

const responseSchema = yup.object({
Name: yup.string().required()
name: yup.string().required()
});
type PayloadResponse = yup.InferType<typeof responseSchema>;
export const useRobloxGetItemDetails = ({
itemId,
options
}: UseRobloxGetItemDetailsProps) => {
const queryKey = ["roblox-item-details", itemId];
const { backendOrigin } = useRobloxConfigContext();
const queryKey = ["roblox-item-details", itemId, backendOrigin];
return useQuery(
queryKey,
async (): Promise<PayloadResponse> => {
// TODO:
// const endpoint = CONFIG.roblox.getItemDetailsEndpoint2({ itemId });
// const response = await fetch(endpoint);
// if (!response.ok) {
// console.error(
// `Error while fetching ${endpoint}, status = ${response.status.toString()}`
// );
// const endpoint2 = CONFIG.roblox.getItemDetailsEndpoint({ itemId });
// const response2 = await fetch(endpoint2);
// if (!response2.ok) {
// throw new Error(
// `Error while fetching ${endpoint2}, status = ${response2.status.toString()}`
// );
// }
// const jsonData = await response2.json();
// const validatedData = await responseSchema.validate(jsonData);
// return validatedData;
// }
// const jsonData = await response.json();
// const validatedData = await responseSchema.validate(jsonData);
// return validatedData;
return {
Name: "Name should be returned by the backend and not hardcoded"
};
const response = await fetch(
`${backendOrigin}/asset-details?assetId=${itemId}`
);
if (!response.ok) {
const errorMessage = `Error while fetching /asset-details, status = ${response.status.toString()}`;
console.error(errorMessage);
throw new Error(errorMessage);
}
const jsonData = await response.json();
const validatedData = await responseSchema.validate(jsonData);
return validatedData;
},
options
);
Expand Down

0 comments on commit d8bbc08

Please sign in to comment.