Skip to content

Commit

Permalink
fix(login): added const list of providers instead of fetching (#627)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubwiczkowski committed Aug 16, 2023
1 parent f84fcd0 commit 96debe1
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions apps/web/src/pages/auth/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,27 @@ import {
Text,
VStack,
} from '@chakra-ui/react';
import type { GetServerSideProps, InferGetServerSidePropsType } from 'next';
import type { GetServerSideProps } from 'next';
import { useRouter } from 'next/router';
import { getProviders, signIn } from 'next-auth/react';
import { signIn } from 'next-auth/react';
import { useTranslation } from 'next-i18next';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';

interface Props {}

interface Provider {
id: string;
name: string;
}

function Login({
providers,
}: InferGetServerSidePropsType<typeof getServerSideProps>) {
const providers: Provider[] = [
{
id: 'usos',
name: 'USOS',
},
];

function Login() {
const { t } = useTranslation('common');
const router = useRouter();
const { error } = router.query;
Expand Down Expand Up @@ -81,20 +88,12 @@ function Login({
);
}

export const getServerSideProps: GetServerSideProps<{
providers: Provider[];
}> = async ({ locale }) => {
const providerList = await getProviders();
const translations = await serverSideTranslations(locale ?? 'pl', ['common']);

if (providerList === null) {
return { props: { providers: [], ...translations } };
}

export const getServerSideProps: GetServerSideProps<Props> = async ({
locale,
}) => {
return {
props: {
providers: Object.values(providerList) as Provider[],
...translations,
...(await serverSideTranslations(locale ?? 'pl', ['common'])),
},
};
};
Expand Down

0 comments on commit 96debe1

Please sign in to comment.