Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: home page render error #129

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/home/charts/charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ const renderPieLabel = (label, color) => {
export const HomeCharts = () => {
const { t } = useTranslation("home");
const theme = useTheme();
const { items = [] } = useRequest(apiRoutes.creatorshub.getStats(), "stats");

// const { items = [] } = useRequest(apiRoutes.creatorshub.getStats(), "stats");
const items = [];
const stats = items?.[0]?.nfts || {};
items.forEach((item, idx) => {
if (idx === 0) return;
Expand Down
23 changes: 12 additions & 11 deletions components/home/creators/creators.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ const StyledSlide = styled.div`

export const HomeCreators = () => {
const { t } = useTranslation("home");
const { items = [] } = useRequest(
apiRoutes.creatorshub.getCreators(),
"creators"
);
const { items } = useRequest(apiRoutes.creatorshub.getCreators(), "creators");
const theme = useTheme();

let visibleSlides = 8;
Expand All @@ -61,37 +58,41 @@ export const HomeCreators = () => {
isPlaying
interval={2000}
visibleSlides={visibleSlides}
totalSlides={items.length}
totalSlides={items?.length}
naturalSlideWidth={205}
naturalSlideHeight={205}
>
<Slider>
{items.map((c) => (
<Slide key={c.id}>
{items?.map((c) => (
<Slide key={c?.creator.id}>
<StyledSlide>
<Image
src={c.profile?.avatar || "/images/user-placeholder.png"}
src={
c?.creator.profile?.avatar || "/images/user-placeholder.png"
}
/>

<div className="card">
<Text
content={c.name || c.ethereumPublicAddr}
content={c?.creator.name || c?.creator.ethereumPublicAddr}
fontWeight="bold"
fontSize="lg"
mb={1}
noWrap
/>

<Text
content={c.profile.description || t("creators.creator")}
content={
c?.creator.profile?.description || t("creators.creator")
}
color="textSecondary"
fontSize="sm"
noWrap
/>

<Text color="textSecondary" fontSize="sm" mt={10}>
<H4
content={c.nfts.length || "0"}
content={c?.creator.nfts?.length || "0"}
color="textPrimary"
dInline
/>{" "}
Expand Down
21 changes: 10 additions & 11 deletions components/home/transactionsTable/transactionsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,40 +74,40 @@ const getRows = ({ nfts = [], t }) =>
.sort((n1, n2) => n1.createdAt - n2.createdAt)
.map((transaction) => {
const price =
transaction.priceType === "FIXED" ? (
<H4 content={centsToPrice(transaction.price)} />
transaction?.priceType === "FIXED" ? (
<H4 content={centsToPrice(transaction?.price)} />
) : (
t("table.custom")
);

return {
image: (
<StyledImage alt={transaction.title} src={transaction.coverSrc} />
<StyledImage alt={transaction?.title} src={transaction?.coverSrc} />
),
title: (
<RKLink
Component={Link}
href={{
pathname: "/",
query: {
id: transaction.id,
id: transaction?.id,
network: transaction?.contractNetwork || "maticTestnet",
contractName: transaction.contractName || "CustomERC1155",
contractName: transaction?.contractName || "CustomERC1155",
contractAddr: transaction?.contractAddr,
createdWith: transaction?.createdWith || "creatorshub",
},
}}
passHref
>
<H4 content={transaction.title} />
<H4 content={transaction?.title} />
</RKLink>
),
creator:
transaction.creator.username ||
transaction.creator.ethereumPublicAddr,
transaction?.creator?.username ||
transaction?.creator?.ethereumPublicAddr,
createdAt: (
<Text
content={date.format(transaction.createdAt)}
content={date.format(transaction?.createdAt)}
color="textSecondary"
/>
),
Expand All @@ -120,9 +120,8 @@ export const TransactionsTable = () => {
const debouncedQ = useDebounce(q, 1000);
const { items } = useRequest(
apiRoutes.creatorshub.getNfts(debouncedQ),
"nfts"
"allNfts"
);

return (
<StyledBox
headerRenderTitle={() => (
Expand Down
6 changes: 3 additions & 3 deletions routes/apiRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getBaseUrl } from "utils/url";

export const apiRoutes = {
creatorshub: {
getStats: () => `/api/public/stats`,
// getStats: () => `/api/public/stats`, //TODO improve stats logic or endpoint's
getNfts: (q) => `/api/public/nfts${q ? `?q=${q}` : ""}`,
getNft: (nftId) => `/api/public/nft/${nftId}`,
getCreators: () => `/api/public/creators`,
Expand All @@ -11,6 +11,6 @@ export const apiRoutes = {
createdWith
)}/api/public/nft/${nftId}/pdf?download=true&locale=${locale}`,
getNftTradingHistory: (nftId, createdWith) =>
`${getBaseUrl(createdWith)}/api/public/nft/${nftId}/trading_history`
}
`${getBaseUrl(createdWith)}/api/public/nft/${nftId}/trading_history`,
},
};