mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* update styles for chain widgets on home page * update latest txs styles and slug creation algorithm * list of local txs * list of local blocks * local view for address internal tx tab * local view for address coin history * local view for address logs * local view for address token transfers * address details, kind of * [wip] local view for address contract tab * user ops views * chain popover * csv-export page * advanced filter page * block countdown pages * fixes for contract tab * refactor address txs and transfers tabs * refactor getServerSideProps * internal txs page * tokens and token transfers pages * simple tag for address page and details info placeholders * add chain icon to the local lists * show creator in contract tab * OP Superchain: local views for chains in the cluster Fixes #2827 * highlight current chain in the title of local entities * tokens nfts tab for address * allow entity icon to be an image * adjust cross-chain txs table and add placeholder to home page * cross-chain txs for address * fetch multichain config from microservice * fix skeleton in token transfers table * tests, pt.1 * wtf with gh * verified contracts page * change chain info in block and token page header * fix some tests * update styles for token icon with chain logo in header * fix links and address internal txs tab * update screenshots * fix margins for tx info button and chain icon in tx tables * add some tests * fix screenshots
86 lines
2.7 KiB
TypeScript
86 lines
2.7 KiB
TypeScript
import type { GetServerSideProps } from 'next';
|
|
import dynamic from 'next/dynamic';
|
|
import fetch from 'node-fetch';
|
|
import React from 'react';
|
|
|
|
import type { NextPageWithLayout } from 'nextjs/types';
|
|
import type { MarketplaceApp } from 'types/client/marketplace';
|
|
|
|
import type { Route } from 'nextjs-routes';
|
|
import type { Props } from 'nextjs/getServerSideProps/handlers';
|
|
import * as gSSP from 'nextjs/getServerSideProps/main';
|
|
import PageNextJs from 'nextjs/PageNextJs';
|
|
import detectBotRequest from 'nextjs/utils/detectBotRequest';
|
|
import fetchApi from 'nextjs/utils/fetchApi';
|
|
|
|
import config from 'configs/app';
|
|
import getQueryParamString from 'lib/router/getQueryParamString';
|
|
import LayoutApp from 'ui/shared/layout/LayoutApp';
|
|
|
|
const MarketplaceAppPage = dynamic(() => import('ui/pages/MarketplaceApp'), { ssr: false });
|
|
|
|
const pathname: Route['pathname'] = '/apps/[id]';
|
|
const feature = config.features.marketplace;
|
|
|
|
const Page: NextPageWithLayout<Props<typeof pathname>> = (props: Props<typeof pathname>) => {
|
|
return (
|
|
<PageNextJs pathname={ pathname } query={ props.query } apiData={ props.apiData }>
|
|
<MarketplaceAppPage/>
|
|
</PageNextJs>
|
|
);
|
|
};
|
|
|
|
Page.getLayout = function getLayout(page: React.ReactElement) {
|
|
return (
|
|
<LayoutApp>
|
|
{ page }
|
|
</LayoutApp>
|
|
);
|
|
};
|
|
|
|
export default Page;
|
|
|
|
export const getServerSideProps: GetServerSideProps<Props<typeof pathname>> = async(ctx) => {
|
|
const baseResponse = await gSSP.marketplace<typeof pathname>(ctx);
|
|
|
|
if (config.meta.og.enhancedDataEnabled && 'props' in baseResponse && feature.isEnabled) {
|
|
const botInfo = detectBotRequest(ctx.req);
|
|
|
|
if (botInfo?.type === 'social_preview') {
|
|
|
|
const appData = await(async() => {
|
|
if ('configUrl' in feature) {
|
|
const controller = new AbortController();
|
|
const timeout = setTimeout(() => {
|
|
controller.abort();
|
|
}, 1_000);
|
|
|
|
try {
|
|
const response = await fetch(feature.configUrl, { signal: controller.signal });
|
|
const appList = await response.json() as Array<MarketplaceApp>;
|
|
clearTimeout(timeout);
|
|
|
|
if (appList && Array.isArray(appList)) {
|
|
return appList.find(app => app.id === getQueryParamString(ctx.query.id));
|
|
}
|
|
} catch (error) {} finally {
|
|
clearTimeout(timeout);
|
|
}
|
|
} else {
|
|
return await fetchApi({
|
|
resource: 'admin:marketplace_dapp',
|
|
pathParams: { dappId: getQueryParamString(ctx.query.id), chainId: config.chain.id },
|
|
timeout: 1_000,
|
|
});
|
|
}
|
|
})();
|
|
|
|
(await baseResponse.props).apiData = appData && appData.title ? {
|
|
app_name: appData.title,
|
|
} : null;
|
|
}
|
|
}
|
|
|
|
return baseResponse;
|
|
};
|