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.

1234567891011121314151617181920212223242526272829
  1. import { getSession } from 'next-auth/react';
  2. import ProfileContent from '../../components/profile-content/ProfileContent';
  3. import { LOGIN_PAGE } from '../../constants/pages';
  4. import { getOrdersForOwner } from '../../requests/orders/getOrdersForOwnerRequest';
  5. const ProfilePage = (props) => {
  6. return <ProfileContent orders={props.orders.orders}></ProfileContent>;
  7. };
  8. export async function getServerSideProps(context) {
  9. const session = await getSession({ req: context.req });
  10. if (!session) {
  11. return {
  12. redirect: {
  13. destination: LOGIN_PAGE,
  14. permanent: false,
  15. },
  16. };
  17. }
  18. const orders = await getOrdersForOwner(session.user._id);
  19. return {
  20. props: { orders },
  21. };
  22. }
  23. export default ProfilePage;