add: add find pair page

This commit is contained in:
Andrew Besedin 2026-01-09 00:27:21 +03:00
parent fb005d6de5
commit 8eb7ce8201
2 changed files with 59 additions and 0 deletions

View file

@ -0,0 +1,53 @@
import { GetServerSideProps } from 'next';
import { findPairID } from '@/utils/methods';
import styles from '@/styles/404.module.scss';
export const getServerSideProps: GetServerSideProps = async (context) => {
const { first, second } = context.query;
if (!first || !second) {
return {
notFound: true, // Show a 404 page if parameters are missing
};
}
try {
const idFound = await findPairID(
first as string,
second as string,
context.req.headers.host as string,
);
console.log('ID found:', idFound);
if (typeof idFound === 'number') {
return {
redirect: {
destination: `/dex/trading/${idFound}`,
permanent: false,
},
};
}
return {
notFound: true,
};
} catch (error) {
console.error('Error fetching pair ID:', error);
return {
props: {
error: 'Failed to resolve the pair.',
},
};
}
};
const Page = ({ error }: { error?: string }) => {
return (
<div>
<h1 className={styles.title}>Error: {error}</h1>
</div>
);
};
export default Page;

View file

@ -0,0 +1,6 @@
.title {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}