refactor appeal for new and resume
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
// lib/routing/requireQueryParams.js
|
||||
// Simple query validator for getServerSideProps
|
||||
|
||||
export function requireQueryParams(query, requiredKeys = []) {
|
||||
const missing = requiredKeys.filter((k) => !query?.[k]);
|
||||
if (missing.length === 0) return { ok: true };
|
||||
|
||||
// Redirect to a generic error page you already have
|
||||
// (you can swap this destination later)
|
||||
const destination = `/error?missing=${encodeURIComponent(
|
||||
missing.join(",")
|
||||
)}`;
|
||||
return {
|
||||
ok: false,
|
||||
redirect: {
|
||||
destination,
|
||||
permanent: false,
|
||||
},
|
||||
missing,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user