Skip to content

Commit

Permalink
fix: loading signup bug, removed email login, added sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
isaaclindenman committed Jan 21, 2024
1 parent 31466ec commit a90f436
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 70 deletions.
4 changes: 3 additions & 1 deletion frontend/public/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,9 @@
"resetPassword": "Reset Password",
"tos": "Terms of Service",
"unknownEmail": "User does not exist",
"userAgreementMessage": "By continuing you are agreeing to our"
"userAgreementMessage": "By continuing you are agreeing to our ",
"welcomeMessage": "Welcome to BaseMind",
"welcomeMessageDescription": "Get started with free credits, no credit card required."
},
"support": {
"api": "API",
Expand Down
50 changes: 50 additions & 0 deletions frontend/public/sitemap.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://basemind.ai/en</loc>
<lastmod>2024-01-21</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://basemind.ai/en/sign-in</loc>
<lastmod>2024-01-21</lastmod>
<changefreq>weekly</changefreq>
<priority>0.9</priority>
</url>
<url>
<loc>https://basemind.ai/en/privacy-policy</loc>
<lastmod>2024-01-21</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://basemind.ai/en/terms-of-service</loc>
<lastmod>2024-01-21</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://basemind.ai/en/support</loc>
<lastmod>2024-01-21</lastmod>
<changefreq>weekly</changefreq>
<priority>0.6</priority>
</url>
<url>
<loc>https://basemind.ai/en/projects/create</loc>
<lastmod>2024-01-21</lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://basemind.ai/en/settings</loc>
<lastmod>2024-01-21</lastmod>
<changefreq>weekly</changefreq>
<priority>0.4</priority>
</url>
<url>
<loc>https://basemind.ai/en/projects</loc>
<lastmod>2024-01-21</lastmod>
<changefreq>weekly</changefreq>
<priority>0.3</priority>
</url>
</urlset>
33 changes: 17 additions & 16 deletions frontend/src/app/[locale]/sign-in/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useRouter } from 'next/navigation';
import { useEffect, useState } from 'react';

import { LottieLoader } from '@/components/loader';
import { Logo } from '@/components/logo';
import { FirebaseLogin } from '@/components/sign-in/firebase-login';
import { LoginBanner } from '@/components/sign-in/login-banner';
import { marketingInfographic, Navigation } from '@/constants';
Expand All @@ -16,7 +15,7 @@ export default function SignIn() {
const user = useUser();
const router = useRouter();
const { initialized, page, identify } = useAnalytics();
const [isLoading, setIsLoading] = useState(true);
const [isLoading, setIsLoading] = useState(false);

useEffect(() => {
page(PageNames.Auth);
Expand All @@ -30,21 +29,23 @@ export default function SignIn() {

return (
<main data-testid="login-container" className="flex bg-base-100 h-full">
<LottieLoader />
<div className={`flex grow ${isLoading && 'hidden'}`}>
<div className="flex grow px-16 pt-16 pb-24 flex-col">
<Logo />
<FirebaseLogin
setLoading={(loadingValue) => {
setIsLoading(loadingValue);
}}
isInitialized={initialized}
/>
{isLoading ? (
<LottieLoader />
) : (
<div className="flex grow">
<div className="flex grow px-16 pt-16 pb-24 flex-col">
<FirebaseLogin
setLoading={(loadingValue) => {
setIsLoading(loadingValue);
}}
isInitialized={initialized}
/>
</div>
<div className="hidden lg:flex lg:h-screen lg:bg-base-200 lg:items-center lg:w-2/5">
<LoginBanner imageSrc={marketingInfographic} />
</div>
</div>
<div className="hidden lg:flex lg:h-screen lg:bg-base-200 lg:items-center lg:w-2/5">
<LoginBanner imageSrc={marketingInfographic} />
</div>
</div>
)}
</main>
);
}
25 changes: 25 additions & 0 deletions frontend/src/app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { MetadataRoute } from 'next';

import { Navigation } from '@/constants';

const BASE_URL = 'https://basemind.ai';
const SitemapArray = [
Navigation.Base,
Navigation.SignIn,
Navigation.PrivacyPolicy,
Navigation.TOS,
Navigation.Support,
Navigation.CreateProject,
Navigation.Settings,
Navigation.Projects,
];
export default function SiteMap(): MetadataRoute.Sitemap {
return SitemapArray.map((path, index) => {
return {
changeFrequency: 'weekly',
lastModified: new Date(),
priority: 1 - index,
url: BASE_URL + path,
};
});
}
14 changes: 1 addition & 13 deletions frontend/src/components/sign-in/firebase-login.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
EmailAuthProvider,
GithubAuthProvider,
GoogleAuthProvider,
signInWithPopup,
Expand Down Expand Up @@ -38,7 +37,6 @@ describe('FirebaseLogin tests', () => {
).toBeInTheDocument();
});

expect(screen.getByTestId('email-login-button')).toBeInTheDocument();
expect(screen.getByTestId('github-login-button')).toBeInTheDocument();
expect(screen.getByTestId('google-login-button')).toBeInTheDocument();

Expand All @@ -64,7 +62,6 @@ describe('FirebaseLogin tests', () => {
});

it.each([
['email-login-button', EmailAuthProvider],
['github-login-button', GithubAuthProvider],
['google-login-button', GoogleAuthProvider],
])(
Expand Down Expand Up @@ -113,7 +110,7 @@ describe('FirebaseLogin tests', () => {
let button: HTMLButtonElement;

await waitFor(() => {
button = screen.getByTestId('email-login-button');
button = screen.getByTestId('github-login-button');
expect(button).toBeInTheDocument();
});

Expand Down Expand Up @@ -142,13 +139,4 @@ describe('FirebaseLogin tests', () => {
getEnv().NEXT_PUBLIC_FRONTEND_HOST + Navigation.PrivacyPolicy,
);
});

it('should open the reset password modal when the reset password button is clicked', () => {
render(<FirebaseLogin setLoading={vi.fn()} isInitialized={true} />);
const resetPasswordButton: HTMLButtonElement = screen.getByTestId(
'reset-password-button',
);
fireEvent.click(resetPasswordButton);
expect(screen.getByTestId('password-reset-modal')).toBeInTheDocument();
});
});
55 changes: 16 additions & 39 deletions frontend/src/components/sign-in/firebase-login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ import { FirebaseError } from '@firebase/app';
import {
Auth,
AuthProvider,
EmailAuthProvider,
GithubAuthProvider,
GoogleAuthProvider,
sendEmailVerification,
sendPasswordResetEmail,
signInWithPopup,
User,
} from '@firebase/auth';
import { useClickAway } from '@uidotdev/usehooks';
import Image from 'next/image';
import Link from 'next/link';
import { useRouter } from 'next/navigation';
import { useTranslations } from 'next-intl';
import { LegacyRef, useEffect, useState } from 'react';
Expand Down Expand Up @@ -45,8 +44,6 @@ const authProviders: {
},
];

const emailProvider = new EmailAuthProvider();

export function FirebaseLogin({
setLoading,
isInitialized,
Expand Down Expand Up @@ -137,39 +134,19 @@ export function FirebaseLogin({
data-testid="firebase-login-container"
className="flex items-center h-full w-full justify-center"
>
<div className="flex flex-col justify-center gap-3 h-fit border-2 rounded border-neutral p-12">
<button
data-testid="email-login-button"
className="btn btn-rounded flex border-2 border-base-300 justify-center gap-2"
onClick={() => {
void handleLogin(emailProvider, sendEmailVerification);
}}
>
<Image
src="/images/email-logo.svg"
alt="Email logo"
height={Dimensions.Seven}
width={Dimensions.Seven}
/>
<span className="font-bold">Login with Email</span>
</button>
<div className="flex justify-end">
<button
className="btn btn-xs btn-link"
data-testid="reset-password-button"
onClick={() => {
setResetPWModalOpen(true);
}}
>
{t('forgotPassword')}
</button>
</div>
<div className="flex flex-col justify-center gap-3 h-fit border-1 rounded border-neutral p-12">
<h3 className="text-4xl font-bold text-center text-neutral-content">
{t('welcomeMessage')}
</h3>
<p className="text-center text-neutral-content">
{t('welcomeMessageDescription')}
</p>
<div className="card-section-divider" />
{authProviders.map(({ key, provider, size }) => (
<button
key={key.toLowerCase()}
data-testid={`${key.toLowerCase()}-login-button`}
className="btn btn-rounded flex border-2 border-base-300 justify-center gap-2"
className="btn btn-bloc"
onClick={() => {
void handleLogin(provider);
}}
Expand All @@ -186,24 +163,24 @@ export function FirebaseLogin({
<div className="card-section-divider" />
<div
data-testid="tos-and-privacy-policy-container"
className="text-xs text-center"
className="text-xs text-center text-neutral-content max-w-xs mx-auto"
>
<span>{t('userAgreementMessage')}</span>
<a
className="link link-primary"
<Link
className="link hover:link-accent"
href={host + Navigation.TOS}
data-testid="tos-link"
>
{t('tos')}
</a>
</Link>
<span>{` ${t('and')} `}</span>
<a
className="link link-primary"
<Link
className="link hover:link-accent"
href={host + Navigation.PrivacyPolicy}
data-testid="privacy-policy-link"
>
{t('privacyPolicy')}
</a>
</Link>
<span>.</span>
</div>
<div ref={ref as LegacyRef<HTMLDivElement>}>
Expand Down
1 change: 0 additions & 1 deletion frontend/src/constants/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export enum Navigation {
SignIn = '/en/sign-in',
Support = '/en/support',
TOS = '/en/terms-of-service',
Testing = '/en/projects/:projectId/testing',
}

export enum ExternalNavigation {
Expand Down

0 comments on commit a90f436

Please sign in to comment.