Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions mobile/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,26 @@
"**/*"
],
"ios": {
"supportsTablet": false
"supportsTablet": false,
"bundleIdentifier": "com.discoverly.app"
},
"android": {
"package": "com.discoverly.app",
"intentFilters": [
{
"action": "VIEW",
"data": [
{
"scheme": "discoverly"
}
],
"category": [
"BROWSABLE",
"DEFAULT"
]
}
]
},
"android": {},
"web": {
"bundler": "metro"
},
Expand Down
21 changes: 21 additions & 0 deletions mobile/app/(auth)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Redirect, Stack } from "expo-router"

Check warning on line 1 in mobile/app/(auth)/_layout.tsx

View workflow job for this annotation

GitHub Actions / mobile-checks

Insert `;`

Check warning on line 1 in mobile/app/(auth)/_layout.tsx

View workflow job for this annotation

GitHub Actions / mobile-checks

There should be at least one empty line between import groups
import { useAuthStore } from "../../src/store/useAuthStore"

Check warning on line 2 in mobile/app/(auth)/_layout.tsx

View workflow job for this annotation

GitHub Actions / mobile-checks

Insert `;`

export default function AuthLayout() {
const token = useAuthStore((state) => state.token)

Check warning on line 5 in mobile/app/(auth)/_layout.tsx

View workflow job for this annotation

GitHub Actions / mobile-checks

Insert `;`

if (token) {
return <Redirect href="/(tabs)/discover" />

Check warning on line 8 in mobile/app/(auth)/_layout.tsx

View workflow job for this annotation

GitHub Actions / mobile-checks

Insert `;`
}

return (
<Stack
screenOptions={{
headerShown: false,
}}
>
<Stack.Screen name="login" />
<Stack.Screen name="register" />
</Stack>
)

Check warning on line 20 in mobile/app/(auth)/_layout.tsx

View workflow job for this annotation

GitHub Actions / mobile-checks

Insert `;`
}
4 changes: 4 additions & 0 deletions mobile/app/(auth)/login.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { zodResolver } from "@hookform/resolvers/zod"

Check warning on line 1 in mobile/app/(auth)/login.tsx

View workflow job for this annotation

GitHub Actions / mobile-checks

Insert `;`
import { Link, useRouter } from "expo-router"

Check warning on line 2 in mobile/app/(auth)/login.tsx

View workflow job for this annotation

GitHub Actions / mobile-checks

Insert `;`
import { Controller, useForm } from "react-hook-form"

Check warning on line 3 in mobile/app/(auth)/login.tsx

View workflow job for this annotation

GitHub Actions / mobile-checks

Insert `;`
import { View } from "react-native"

Check warning on line 4 in mobile/app/(auth)/login.tsx

View workflow job for this annotation

GitHub Actions / mobile-checks

There should be at least one empty line between import groups
Expand All @@ -10,6 +10,7 @@
export default function LoginScreen() {
const router = useRouter()
const setToken = useAuthStore((state) => state.setToken)

const {
control,
handleSubmit,
Expand Down Expand Up @@ -43,6 +44,7 @@
<Typography variant="body" color={colors.muted}>
Sign in to continue matching with dishes around you.
</Typography>

<Controller
control={control}
name="email"
Expand All @@ -61,6 +63,7 @@
/>
)}
/>

<Controller
control={control}
name="password"
Expand All @@ -79,6 +82,7 @@
/>
)}
/>

<Button label="Sign In" loading={isSubmitting} onPress={handleSubmit(onSubmit)} />
<Link href="/(auth)/register">Go To Register</Link>
</View>
Expand Down
39 changes: 26 additions & 13 deletions mobile/app/(auth)/register.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { zodResolver } from "@hookform/resolvers/zod"
import { Link, useRouter } from "expo-router"
import { Controller, useForm } from "react-hook-form"
import { ScrollView, View } from "react-native"
import { ScrollView } from "react-native"
import { Button, Input, Typography } from "../../src/components"
import { useAuthStore } from "../../src/store/useAuthStore"
import { colors, spacing } from "../../src/theme/tokens"
Expand All @@ -10,6 +10,7 @@ import { type RegisterFormValues, registerSchema } from "../../src/validation/au
export default function RegisterScreen() {
const router = useRouter()
const setToken = useAuthStore((state) => state.setToken)

const {
control,
handleSubmit,
Expand Down Expand Up @@ -46,6 +47,7 @@ export default function RegisterScreen() {
<Typography variant="body" color={colors.muted}>
Create your account to start discovering meals instantly.
</Typography>

<Controller
control={control}
name="fullName"
Expand All @@ -61,6 +63,7 @@ export default function RegisterScreen() {
/>
)}
/>

<Controller
control={control}
name="email"
Expand All @@ -79,24 +82,33 @@ export default function RegisterScreen() {
/>
)}
/>

<Controller
control={control}
name="password"
render={({ field: { onChange, onBlur, value } }) => (
<Input
label="Password"
placeholder="Minimum 8 characters"
secureTextEntry
autoCapitalize="none"
autoComplete="password-new"
textContentType="newPassword"
value={value}
onChangeText={onChange}
onBlur={onBlur}
error={errors.password?.message}
/>
<>
<Input
label="Password"
placeholder="Minimum 8 characters"
secureTextEntry
autoCapitalize="none"
autoComplete="password-new"
textContentType="newPassword"
value={value}
onChangeText={onChange}
onBlur={onBlur}
error={errors.password?.message}
/>
{!errors.password?.message ? (
<Typography variant="caption" color={colors.muted}>
Minimum 8 characters
</Typography>
) : null}
</>
)}
/>

<Controller
control={control}
name="confirmPassword"
Expand All @@ -113,6 +125,7 @@ export default function RegisterScreen() {
/>
)}
/>

<Button label="Sign Up" loading={isSubmitting} onPress={handleSubmit(onSubmit)} />
<Link href="/(auth)/login">Back To Login</Link>
</ScrollView>
Expand Down
8 changes: 7 additions & 1 deletion mobile/app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { Tabs } from "expo-router"
import { Redirect, Tabs } from "expo-router"
import { useCartStore } from "../../src/store/useCartStore"
import { useAuthStore } from "../../src/store/useAuthStore"

export default function TabsLayout() {
const token = useAuthStore((state) => state.token)
const itemCount = useCartStore((state) => state.items.length)

if (!token) {
return <Redirect href="/(auth)/login" />
}

return (
<Tabs>
<Tabs.Screen name="discover" options={{ title: "Discover" }} />
Expand Down
20 changes: 18 additions & 2 deletions mobile/app/(tabs)/profile.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
import { Text, View } from "react-native"
import { useRouter } from "expo-router"
import { Pressable, Text, View } from "react-native"
import { useAuthStore } from "../../src/store/useAuthStore"

export default function ProfileScreen() {
const router = useRouter()
const logout = useAuthStore((state) => state.logout)

const onLogout = () => {
logout()
router.replace("/(auth)/login")
}

return (
<View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
<View style={{ flex: 1, alignItems: "center", justifyContent: "center", gap: 12 }}>
<Text>User Profile & Wallet.</Text>
<Pressable
onPress={onLogout}
style={{ backgroundColor: "#E53935", borderRadius: 10, paddingHorizontal: 14, paddingVertical: 10 }}
>
<Text style={{ color: "#fff", fontWeight: "700" }}>Logout</Text>
</Pressable>
</View>
)
}
5 changes: 4 additions & 1 deletion mobile/app/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Redirect } from "expo-router"
import { useAuthStore } from "../src/store/useAuthStore"

export default function IndexScreen() {
return <Redirect href="/(auth)/login" />
const token = useAuthStore((state) => state.token)

return <Redirect href={token ? "/(tabs)/discover" : "/(auth)/login"} />
}