diff --git a/front/API.ts b/front/API.ts index da93cb7..8fdda06 100644 --- a/front/API.ts +++ b/front/API.ts @@ -127,12 +127,24 @@ export default class API { body: registrationInput, method: "POST", }); + // In the Future we should move autheticate out of this function + // and maybe create a new function to create and login in one go return API.authenticate({ username: registrationInput.username, password: registrationInput.password, }); } + public static async createAndGetGuestAccount(): Promise { + let response = await API.fetch({ + route: "/auth/guest", + method: "POST", + }); + if (!response.ok) throw new APIError("Error while creating guest account", response.status, "guestAccountCreationError"); + if (!response.access_token) throw new APIError("No access token", response.status); + return response.access_token; + } + /*** * Retrieve information of the currently authentified user */ diff --git a/front/Navigation.tsx b/front/Navigation.tsx index bb176dc..1c31bcf 100644 --- a/front/Navigation.tsx +++ b/front/Navigation.tsx @@ -6,6 +6,7 @@ import { RootState, useSelector } from './state/Store'; import { translate } from './i18n/i18n'; import SongLobbyView from './views/SongLobbyView'; import AuthenticationView from './views/AuthenticationView'; +import StartPageView from './views/StartPageView'; import HomeView from './views/HomeView'; import SearchView from './views/SearchView'; import SetttingsNavigator from './views/settings/SettingsView'; @@ -29,6 +30,7 @@ const protectedRoutes = () => ({ }) as const; const publicRoutes = () => ({ + Start: { component: StartPageView, options: { title: translate('welcome') } }, Login: { component: AuthenticationView, options: { title: translate('signInBtn') } }, }) as const; diff --git a/front/models/User.ts b/front/models/User.ts index aaf5e28..c6331a6 100644 --- a/front/models/User.ts +++ b/front/models/User.ts @@ -5,6 +5,7 @@ import UserSettings from "./UserSettings"; interface User extends Model { name: string; email: string; + isGuest: boolean; xp: number; premium: boolean; metrics: Metrics; diff --git a/front/views/StartPageView.tsx b/front/views/StartPageView.tsx new file mode 100644 index 0000000..afc352a --- /dev/null +++ b/front/views/StartPageView.tsx @@ -0,0 +1,58 @@ +import React from "react"; +import { View, Text, Stack, Box, Button, Pressable, useBreakpointValue } from "native-base"; +import { useNavigation } from "../Navigation"; + +const StartPageView = () => { + const navigation = useNavigation(); + const screenSize = useBreakpointValue({ base: "small", md: "big" }); + return ( + + StartPage + + + + Login + + + + + Guest + + + + + ); +}; + +export default StartPageView;