You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
613 B
30 lines
613 B
import { useRouter } from 'next/router';
|
|
import { URL_LEGACY } from '@services/constants';
|
|
import { useEffect } from 'react';
|
|
|
|
export async function getServerSideProps({ query, locale }) {
|
|
const { pid, tid: token } = query;
|
|
|
|
return {
|
|
props: {
|
|
token: token || null,
|
|
pid,
|
|
},
|
|
};
|
|
}
|
|
|
|
const Votes = ({ token, pid }) => {
|
|
const router = useRouter();
|
|
const url = token
|
|
? new URL(`/vote/${pid}/${token}`, URL_LEGACY)
|
|
: new URL(`/vote/${pid}`, URL_LEGACY);
|
|
|
|
useEffect(() => {
|
|
router.push(url.href);
|
|
}, []);
|
|
|
|
return <p>Redirecting to {url.href}</p>;
|
|
};
|
|
|
|
export default Votes;
|