* refactor: enable infinite scrolling for all * chore: remove unused code * fix: tests * chore: type err * chore: update email embed test * chore: update tests * chore: update tests * chore: fix horizontal tabitem * chore * fix: conflicts * chore: conflict * fix: E2E tests * chore: remove idle * fix test --------- Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com>
26 lines
767 B
TypeScript
26 lines
767 B
TypeScript
import type { GetServerSideProps, GetServerSidePropsContext } from "next";
|
|
import { notFound, redirect } from "next/navigation";
|
|
|
|
export const withAppDirSsr =
|
|
<T extends Record<string, any>>(getServerSideProps: GetServerSideProps<T>) =>
|
|
async (context: GetServerSidePropsContext) => {
|
|
const ssrResponse = await getServerSideProps(context);
|
|
|
|
if ("redirect" in ssrResponse) {
|
|
redirect(ssrResponse.redirect.destination);
|
|
}
|
|
if ("notFound" in ssrResponse) {
|
|
notFound();
|
|
}
|
|
|
|
const props = await Promise.resolve(ssrResponse.props);
|
|
|
|
return {
|
|
...props,
|
|
// includes dehydratedState required for future page trpcPropvider
|
|
...("trpcState" in props && {
|
|
dehydratedState: props.trpcState,
|
|
}),
|
|
};
|
|
};
|