Initial Mobile
@@ -6,6 +6,6 @@ export default defineConfig({
|
|||||||
schema: "./db/schema",
|
schema: "./db/schema",
|
||||||
out: "./db/migrations",
|
out: "./db/migrations",
|
||||||
dbCredentials: {
|
dbCredentials: {
|
||||||
url: secrets.DATABASE_URL,
|
url: secrets.DATABASE_URL || "postgres://postgres:wJw7aNpEBJdcxgoct6GXNpvY4Cn6ECqu@fedeo-db-001.vpn.internal:5432/fedeo",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -1,37 +1,70 @@
|
|||||||
version: "3"
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
web:
|
frontend:
|
||||||
image: reg.federspiel.software/fedeo/software:beta
|
image: git.federspiel.tech/flfeders/fedeo/frontend:dev
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
- INFISICAL_CLIENT_ID=abc
|
- NUXT_PUBLIC_API_BASE=https://app.fedeo.de/backend
|
||||||
- INFISICAL_CLIENT_SECRET=abc
|
- NUXT_PUBLIC_PDF_LICENSE=eyJkYXRhIjoiZXlKMElqb2laR1YyWld4dmNHVnlJaXdpWVhaMUlqb3hOemt3TmpNNU9UazVMQ0prYlNJNkltRndjQzVtWldSbGJ5NWtaU0lzSW00aU9pSXpOemt3Wm1Vek5UazBZbVU0TlRRNElpd2laWGh3SWpveE56a3dOak01T1RrNUxDSmtiWFFpT2lKemNHVmphV1pwWXlJc0luQWlPaUoyYVdWM1pYSWlmUT09Iiwic2lnbmF0dXJlIjoicWU4K0ZxQUJDNUp5bEJUU094Vkd5RTJMbk9UNmpyc2EyRStsN2tNNWhkM21KK2ZvVjYwaTFKeFdhZGtqSDRNWXZxQklMc0dpdWh5d2pMbUFjRHZuWGxOcTRMcXFLRm53dzVtaG1LK3lTeDRXbzVaS1loK1VZdFBzWUZjV3oyUHVGMmJraGJrVjJ6RzRlTGtRU09wdmJKY3JUZU1rN0N1VkN6Q1UraHF5T0ZVVXllWnRmaHlmcWswZEFFL0RMR1hvTDFSQXFjNkNkYU9FTDRTdC9Idy9DQnFieTE2aisvT3RxQUlLcy9NWTR6SVk3RTI3bWo4RUx5VjhXNkdXNXhqc0VUVzNKN0RRMUVlb3RhVlNLT29kc3pVRlhUYzVlbHVuSm04ZlcwM1ErMUhtSnpmWGoyS1dwM1dnamJDazZYSHozamFML2lOdUYvZFZNaWYvc2FoR3NnPT0ifQ==
|
||||||
|
networks:
|
||||||
|
- traefik
|
||||||
|
labels:
|
||||||
|
- "traefik.enable=true"
|
||||||
|
- "traefik.docker.network=traefik"
|
||||||
|
- "traefik.port=3000"
|
||||||
|
# Middlewares
|
||||||
|
- "traefik.http.middlewares.fedeo-frontend-redirect-web-secure.redirectscheme.scheme=https"
|
||||||
|
# Web Entrypoint
|
||||||
|
- "traefik.http.routers.fedeo-frontend.middlewares=fedeo-frontend-redirect-web-secure"
|
||||||
|
- "traefik.http.routers.fedeo-frontend.rule=Host(`app.fedeo.de`) && PathPrefix(`/`)"
|
||||||
|
- "traefik.http.routers.fedeo-frontend.entrypoints=web"
|
||||||
|
# Web Secure Entrypoint
|
||||||
|
- "traefik.http.routers.fedeo-frontend-secure.rule=Host(`app.fedeo.de`) && PathPrefix(`/`)"
|
||||||
|
- "traefik.http.routers.fedeo-frontend-secure.entrypoints=web-secured" #
|
||||||
|
- "traefik.http.routers.fedeo-frontend-secure.tls.certresolver=mytlschallenge"
|
||||||
backend:
|
backend:
|
||||||
image: reg.federspiel.software/fedeo/backend:main
|
image: git.federspiel.tech/flfeders/fedeo/backend:dev
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
- NUXT_PUBLIC_API_BASE=
|
- INFISICAL_CLIENT_ID=a6838bd6-9983-4bf4-9be2-ace830b9abdf
|
||||||
- NUXT_PUBLIC_PDF_LICENSE=
|
- INFISICAL_CLIENT_SECRET=4e3441acc0adbffd324aa50e668a95a556a3f55ec6bb85954e176e35a3392003
|
||||||
db:
|
- NODE_ENV=production
|
||||||
image: postgres
|
networks:
|
||||||
restart: always
|
- traefik
|
||||||
shm_size: 128mb
|
labels:
|
||||||
environment:
|
- "traefik.enable=true"
|
||||||
POSTGRES_PASSWORD: abc
|
- "traefik.docker.network=traefik"
|
||||||
POSTGRES_USER: sandelcom
|
- "traefik.port=3100"
|
||||||
POSTGRES_DB: sensorfy
|
# Middlewares
|
||||||
volumes:
|
- "traefik.http.middlewares.fedeo-backend-redirect-web-secure.redirectscheme.scheme=https"
|
||||||
- ./pg-data:/var/lib/postgresql/data
|
- "traefik.http.middlewares.fedeo-backend-strip.stripprefix.prefixes=/backend"
|
||||||
ports:
|
# Web Entrypoint
|
||||||
- "5432:5432"
|
- "traefik.http.routers.fedeo-backend.middlewares=fedeo-backend-redirect-web-secure"
|
||||||
|
- "traefik.http.routers.fedeo-backend.rule=Host(`app.fedeo.de`) && PathPrefix(`/backend`)"
|
||||||
|
- "traefik.http.routers.fedeo-backend.entrypoints=web"
|
||||||
|
# Web Secure Entrypoint
|
||||||
|
- "traefik.http.routers.fedeo-backend-secure.rule=Host(`app.fedeo.de`) && PathPrefix(`/backend`)"
|
||||||
|
- "traefik.http.routers.fedeo-backend-secure.entrypoints=web-secured" #
|
||||||
|
- "traefik.http.routers.fedeo-backend-secure.tls.certresolver=mytlschallenge"
|
||||||
|
- "traefik.http.routers.fedeo-backend-secure.middlewares=fedeo-backend-strip"
|
||||||
|
# db:
|
||||||
|
# image: postgres
|
||||||
|
# restart: always
|
||||||
|
# shm_size: 128mb
|
||||||
|
# environment:
|
||||||
|
# POSTGRES_PASSWORD: abc
|
||||||
|
# POSTGRES_USER: sandelcom
|
||||||
|
# POSTGRES_DB: sensorfy
|
||||||
|
# volumes:
|
||||||
|
# - ./pg-data:/var/lib/postgresql/data
|
||||||
|
# ports:
|
||||||
|
# - "5432:5432"
|
||||||
traefik:
|
traefik:
|
||||||
image: traefik:v2.2
|
image: traefik:v2.11
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
container_name: traefik
|
container_name: traefik
|
||||||
command:
|
command:
|
||||||
- "--api.insecure=false"
|
- "--api.insecure=false"
|
||||||
- "--api.dashboard=true"
|
- "--api.dashboard=false"
|
||||||
- "--api.debug=false"
|
- "--api.debug=false"
|
||||||
- "--providers.docker=true"
|
- "--providers.docker=true"
|
||||||
- "--providers.docker.exposedbydefault=false"
|
- "--providers.docker.exposedbydefault=false"
|
||||||
@@ -43,19 +76,18 @@ services:
|
|||||||
- "--accesslog.bufferingsize=5000"
|
- "--accesslog.bufferingsize=5000"
|
||||||
- "--accesslog.fields.defaultMode=keep"
|
- "--accesslog.fields.defaultMode=keep"
|
||||||
- "--accesslog.fields.headers.defaultMode=keep"
|
- "--accesslog.fields.headers.defaultMode=keep"
|
||||||
- "--certificatesresolvers.mytlschallenge.acme.tlschallenge=true" # <== Enable TLS-ALPN-01 to generate and renew ACME certs
|
- "--certificatesresolvers.mytlschallenge.acme.tlschallenge=true" #
|
||||||
- "--certificatesresolvers.mytlschallenge.acme.email=info@sandelcom.de" # <== Setting email for certs
|
- "--certificatesresolvers.mytlschallenge.acme.email=moin@fedeo.de"
|
||||||
- "--certificatesresolvers.mytlschallenge.acme.storage=/letsencrypt/acme.json" # <== Defining acme file to store cert information
|
- "--certificatesresolvers.mytlschallenge.acme.storage=/letsencrypt/acme.json"
|
||||||
ports:
|
ports:
|
||||||
- 80:80
|
- 80:80
|
||||||
- 8080:8080
|
|
||||||
- 443:443
|
- 443:443
|
||||||
volumes:
|
volumes:
|
||||||
- "./traefik/letsencrypt:/letsencrypt" # <== Volume for certs (TLS)
|
- "./traefik/letsencrypt:/letsencrypt" # <== Volume for certs (TLS)
|
||||||
- "/var/run/docker.sock:/var/run/docker.sock:ro"
|
- "/var/run/docker.sock:/var/run/docker.sock:ro"
|
||||||
- "./traefik/logs:/logs"
|
- "./traefik/logs:/logs"
|
||||||
labels:
|
networks:
|
||||||
#### Labels define the behavior and rules of the traefik proxy for this container ####
|
- traefik
|
||||||
- "traefik.enable=true" # <== Enable traefik on itself to view dashboard and assign subdomain to view it
|
networks:
|
||||||
- "traefik.http.routers.api.rule=Host(`srv1.drinkingteam.de`)" # <== Setting the domain for the dashboard
|
traefik:
|
||||||
- "traefik.http.routers.api.service=api@internal" # <== Enabling the api to be a service to access
|
external: false
|
||||||
1
mobile/.env
Normal file
@@ -0,0 +1 @@
|
|||||||
|
EXPO_PUBLIC_API_BASE=http://192.168.1.157:3100
|
||||||
1
mobile/.env.example
Normal file
@@ -0,0 +1 @@
|
|||||||
|
EXPO_PUBLIC_API_BASE=http://localhost:3100
|
||||||
43
mobile/.gitignore
vendored
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Expo
|
||||||
|
.expo/
|
||||||
|
dist/
|
||||||
|
web-build/
|
||||||
|
expo-env.d.ts
|
||||||
|
|
||||||
|
# Native
|
||||||
|
.kotlin/
|
||||||
|
*.orig.*
|
||||||
|
*.jks
|
||||||
|
*.p8
|
||||||
|
*.p12
|
||||||
|
*.key
|
||||||
|
*.mobileprovision
|
||||||
|
|
||||||
|
# Metro
|
||||||
|
.metro-health-check*
|
||||||
|
|
||||||
|
# debug
|
||||||
|
npm-debug.*
|
||||||
|
yarn-debug.*
|
||||||
|
yarn-error.*
|
||||||
|
|
||||||
|
# macOS
|
||||||
|
.DS_Store
|
||||||
|
*.pem
|
||||||
|
|
||||||
|
# local env files
|
||||||
|
.env*.local
|
||||||
|
|
||||||
|
# typescript
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
app-example
|
||||||
|
|
||||||
|
# generated native folders
|
||||||
|
/ios
|
||||||
|
/android
|
||||||
1
mobile/.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{ "recommendations": ["expo.vscode-expo-tools"] }
|
||||||
7
mobile/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"editor.codeActionsOnSave": {
|
||||||
|
"source.fixAll": "explicit",
|
||||||
|
"source.organizeImports": "explicit",
|
||||||
|
"source.sortMembers": "explicit"
|
||||||
|
}
|
||||||
|
}
|
||||||
50
mobile/README.md
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# Welcome to your Expo app 👋
|
||||||
|
|
||||||
|
This is an [Expo](https://expo.dev) project created with [`create-expo-app`](https://www.npmjs.com/package/create-expo-app).
|
||||||
|
|
||||||
|
## Get started
|
||||||
|
|
||||||
|
1. Install dependencies
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Start the app
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx expo start
|
||||||
|
```
|
||||||
|
|
||||||
|
In the output, you'll find options to open the app in a
|
||||||
|
|
||||||
|
- [development build](https://docs.expo.dev/develop/development-builds/introduction/)
|
||||||
|
- [Android emulator](https://docs.expo.dev/workflow/android-studio-emulator/)
|
||||||
|
- [iOS simulator](https://docs.expo.dev/workflow/ios-simulator/)
|
||||||
|
- [Expo Go](https://expo.dev/go), a limited sandbox for trying out app development with Expo
|
||||||
|
|
||||||
|
You can start developing by editing the files inside the **app** directory. This project uses [file-based routing](https://docs.expo.dev/router/introduction).
|
||||||
|
|
||||||
|
## Get a fresh project
|
||||||
|
|
||||||
|
When you're ready, run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run reset-project
|
||||||
|
```
|
||||||
|
|
||||||
|
This command will move the starter code to the **app-example** directory and create a blank **app** directory where you can start developing.
|
||||||
|
|
||||||
|
## Learn more
|
||||||
|
|
||||||
|
To learn more about developing your project with Expo, look at the following resources:
|
||||||
|
|
||||||
|
- [Expo documentation](https://docs.expo.dev/): Learn fundamentals, or go into advanced topics with our [guides](https://docs.expo.dev/guides).
|
||||||
|
- [Learn Expo tutorial](https://docs.expo.dev/tutorial/introduction/): Follow a step-by-step tutorial where you'll create a project that runs on Android, iOS, and the web.
|
||||||
|
|
||||||
|
## Join the community
|
||||||
|
|
||||||
|
Join our community of developers creating universal apps.
|
||||||
|
|
||||||
|
- [Expo on GitHub](https://github.com/expo/expo): View our open source platform and contribute.
|
||||||
|
- [Discord community](https://chat.expo.dev): Chat with Expo users and ask questions.
|
||||||
48
mobile/app.json
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
"expo": {
|
||||||
|
"name": "mobile",
|
||||||
|
"slug": "mobile",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"orientation": "portrait",
|
||||||
|
"icon": "./assets/images/icon.png",
|
||||||
|
"scheme": "mobile",
|
||||||
|
"userInterfaceStyle": "automatic",
|
||||||
|
"newArchEnabled": true,
|
||||||
|
"ios": {
|
||||||
|
"supportsTablet": true
|
||||||
|
},
|
||||||
|
"android": {
|
||||||
|
"adaptiveIcon": {
|
||||||
|
"backgroundColor": "#E6F4FE",
|
||||||
|
"foregroundImage": "./assets/images/android-icon-foreground.png",
|
||||||
|
"backgroundImage": "./assets/images/android-icon-background.png",
|
||||||
|
"monochromeImage": "./assets/images/android-icon-monochrome.png"
|
||||||
|
},
|
||||||
|
"edgeToEdgeEnabled": true,
|
||||||
|
"predictiveBackGestureEnabled": false
|
||||||
|
},
|
||||||
|
"web": {
|
||||||
|
"output": "static",
|
||||||
|
"favicon": "./assets/images/favicon.png"
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"expo-router",
|
||||||
|
[
|
||||||
|
"expo-splash-screen",
|
||||||
|
{
|
||||||
|
"image": "./assets/images/splash-icon.png",
|
||||||
|
"imageWidth": 200,
|
||||||
|
"resizeMode": "contain",
|
||||||
|
"backgroundColor": "#ffffff",
|
||||||
|
"dark": {
|
||||||
|
"backgroundColor": "#000000"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"experiments": {
|
||||||
|
"typedRoutes": true,
|
||||||
|
"reactCompiler": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
55
mobile/app/(tabs)/_layout.tsx
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
import { Redirect, Tabs } from 'expo-router';
|
||||||
|
|
||||||
|
import { HapticTab } from '@/components/haptic-tab';
|
||||||
|
import { IconSymbol } from '@/components/ui/icon-symbol';
|
||||||
|
import { Colors } from '@/constants/theme';
|
||||||
|
import { useColorScheme } from '@/hooks/use-color-scheme';
|
||||||
|
import { useAuth } from '@/src/providers/auth-provider';
|
||||||
|
|
||||||
|
export default function TabLayout() {
|
||||||
|
const colorScheme = useColorScheme();
|
||||||
|
const { isBootstrapping, token, requiresTenantSelection } = useAuth();
|
||||||
|
|
||||||
|
if (isBootstrapping) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!token) {
|
||||||
|
return <Redirect href="/login" />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requiresTenantSelection) {
|
||||||
|
return <Redirect href="/tenant-select" />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tabs
|
||||||
|
screenOptions={{
|
||||||
|
tabBarActiveTintColor: Colors[colorScheme ?? 'light'].tint,
|
||||||
|
headerShown: true,
|
||||||
|
tabBarButton: HapticTab,
|
||||||
|
}}>
|
||||||
|
<Tabs.Screen
|
||||||
|
name="index"
|
||||||
|
options={{
|
||||||
|
title: 'Aufgaben',
|
||||||
|
tabBarIcon: ({ color }) => <IconSymbol size={24} name="checklist" color={color} />,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Tabs.Screen
|
||||||
|
name="explore"
|
||||||
|
options={{
|
||||||
|
title: 'Konto',
|
||||||
|
tabBarIcon: ({ color }) => <IconSymbol size={24} name="person.crop.circle.fill" color={color} />,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Tabs.Screen
|
||||||
|
name="time"
|
||||||
|
options={{
|
||||||
|
title: 'Zeit',
|
||||||
|
tabBarIcon: ({ color }) => <IconSymbol size={24} name="clock.fill" color={color} />,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Tabs>
|
||||||
|
);
|
||||||
|
}
|
||||||
187
mobile/app/(tabs)/explore.tsx
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
import { Pressable, ScrollView, StyleSheet, Text, View } from 'react-native';
|
||||||
|
|
||||||
|
import { useAuth, useTokenStorageInfo } from '@/src/providers/auth-provider';
|
||||||
|
|
||||||
|
const PRIMARY = '#69c350';
|
||||||
|
|
||||||
|
export default function AccountScreen() {
|
||||||
|
const { token, user, tenants, activeTenantId, activeTenant, switchTenant, logout } = useAuth();
|
||||||
|
const storageInfo = useTokenStorageInfo();
|
||||||
|
|
||||||
|
const [switchingTenantId, setSwitchingTenantId] = useState<number | null>(null);
|
||||||
|
const [switchError, setSwitchError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const userId = String(user?.id || 'unbekannt');
|
||||||
|
|
||||||
|
async function onSwitchTenant(tenantId: number) {
|
||||||
|
setSwitchingTenantId(tenantId);
|
||||||
|
setSwitchError(null);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await switchTenant(tenantId);
|
||||||
|
} catch (err) {
|
||||||
|
setSwitchError(err instanceof Error ? err.message : 'Tenant konnte nicht gewechselt werden.');
|
||||||
|
} finally {
|
||||||
|
setSwitchingTenantId(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ScrollView contentContainerStyle={styles.container}>
|
||||||
|
<Text style={styles.title}>Konto</Text>
|
||||||
|
<Text style={styles.subtitle}>Session-Infos und Tenant-Wechsel.</Text>
|
||||||
|
|
||||||
|
<View style={styles.card}>
|
||||||
|
<Text style={styles.label}>Token vorhanden</Text>
|
||||||
|
<Text style={styles.value}>{token ? 'ja' : 'nein'}</Text>
|
||||||
|
|
||||||
|
<Text style={styles.label}>User ID</Text>
|
||||||
|
<Text style={styles.value}>{userId}</Text>
|
||||||
|
|
||||||
|
<Text style={styles.label}>Aktiver Tenant</Text>
|
||||||
|
<Text style={styles.value}>{activeTenant ? `${activeTenant.name} (#${activeTenantId})` : 'nicht gesetzt'}</Text>
|
||||||
|
|
||||||
|
<Text style={styles.label}>Storage Modus</Text>
|
||||||
|
<Text style={styles.value}>{storageInfo.mode}</Text>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View style={styles.card}>
|
||||||
|
<Text style={styles.sectionTitle}>Tenant wechseln</Text>
|
||||||
|
|
||||||
|
{switchError ? <Text style={styles.error}>{switchError}</Text> : null}
|
||||||
|
|
||||||
|
{tenants.map((tenant) => {
|
||||||
|
const tenantId = Number(tenant.id);
|
||||||
|
const isActive = tenantId === activeTenantId;
|
||||||
|
const isSwitching = switchingTenantId === tenantId;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Pressable
|
||||||
|
key={String(tenant.id)}
|
||||||
|
style={[
|
||||||
|
styles.tenantButton,
|
||||||
|
isActive ? styles.tenantButtonActive : null,
|
||||||
|
isSwitching ? styles.tenantButtonDisabled : null,
|
||||||
|
]}
|
||||||
|
onPress={() => onSwitchTenant(tenantId)}
|
||||||
|
disabled={isActive || switchingTenantId !== null}>
|
||||||
|
<View style={styles.tenantInfo}>
|
||||||
|
<Text style={styles.tenantName} numberOfLines={2} ellipsizeMode="tail">
|
||||||
|
{tenant.name}
|
||||||
|
</Text>
|
||||||
|
<Text style={styles.tenantMeta}>ID: {tenantId}</Text>
|
||||||
|
</View>
|
||||||
|
<View style={styles.tenantActionWrap}>
|
||||||
|
<Text style={styles.tenantAction}>{isActive ? 'Aktiv' : isSwitching ? 'Wechsel...' : 'Wechseln'}</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<Pressable style={styles.logoutButton} onPress={logout}>
|
||||||
|
<Text style={styles.logoutText}>Logout</Text>
|
||||||
|
</Pressable>
|
||||||
|
</ScrollView>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
flexGrow: 1,
|
||||||
|
backgroundColor: '#f9fafb',
|
||||||
|
padding: 16,
|
||||||
|
gap: 12,
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
fontSize: 24,
|
||||||
|
fontWeight: '700',
|
||||||
|
color: '#111827',
|
||||||
|
},
|
||||||
|
subtitle: {
|
||||||
|
color: '#6b7280',
|
||||||
|
},
|
||||||
|
card: {
|
||||||
|
backgroundColor: '#ffffff',
|
||||||
|
borderRadius: 12,
|
||||||
|
padding: 14,
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: '#e5e7eb',
|
||||||
|
gap: 8,
|
||||||
|
},
|
||||||
|
sectionTitle: {
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: '600',
|
||||||
|
color: '#111827',
|
||||||
|
marginBottom: 2,
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
fontSize: 12,
|
||||||
|
color: '#6b7280',
|
||||||
|
textTransform: 'uppercase',
|
||||||
|
},
|
||||||
|
value: {
|
||||||
|
fontSize: 16,
|
||||||
|
color: '#111827',
|
||||||
|
marginBottom: 2,
|
||||||
|
},
|
||||||
|
error: {
|
||||||
|
color: '#dc2626',
|
||||||
|
marginBottom: 4,
|
||||||
|
},
|
||||||
|
tenantButton: {
|
||||||
|
borderRadius: 10,
|
||||||
|
padding: 12,
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: '#d1d5db',
|
||||||
|
backgroundColor: '#ffffff',
|
||||||
|
flexDirection: 'row',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
alignItems: 'center',
|
||||||
|
},
|
||||||
|
tenantButtonActive: {
|
||||||
|
borderColor: PRIMARY,
|
||||||
|
backgroundColor: '#eff9ea',
|
||||||
|
},
|
||||||
|
tenantButtonDisabled: {
|
||||||
|
opacity: 0.6,
|
||||||
|
},
|
||||||
|
tenantInfo: {
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 0,
|
||||||
|
paddingRight: 10,
|
||||||
|
},
|
||||||
|
tenantName: {
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: '600',
|
||||||
|
color: '#111827',
|
||||||
|
flexShrink: 1,
|
||||||
|
},
|
||||||
|
tenantMeta: {
|
||||||
|
color: '#6b7280',
|
||||||
|
marginTop: 3,
|
||||||
|
},
|
||||||
|
tenantActionWrap: {
|
||||||
|
minWidth: 84,
|
||||||
|
alignItems: 'flex-end',
|
||||||
|
},
|
||||||
|
tenantAction: {
|
||||||
|
color: PRIMARY,
|
||||||
|
fontWeight: '600',
|
||||||
|
textAlign: 'right',
|
||||||
|
},
|
||||||
|
logoutButton: {
|
||||||
|
marginTop: 4,
|
||||||
|
backgroundColor: '#dc2626',
|
||||||
|
minHeight: 44,
|
||||||
|
borderRadius: 10,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
},
|
||||||
|
logoutText: {
|
||||||
|
color: '#ffffff',
|
||||||
|
fontWeight: '600',
|
||||||
|
fontSize: 16,
|
||||||
|
},
|
||||||
|
});
|
||||||
567
mobile/app/(tabs)/index.tsx
Normal file
@@ -0,0 +1,567 @@
|
|||||||
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
|
import {
|
||||||
|
ActivityIndicator,
|
||||||
|
KeyboardAvoidingView,
|
||||||
|
Modal,
|
||||||
|
Platform,
|
||||||
|
Pressable,
|
||||||
|
RefreshControl,
|
||||||
|
ScrollView,
|
||||||
|
StyleSheet,
|
||||||
|
Text,
|
||||||
|
TextInput,
|
||||||
|
View,
|
||||||
|
} from 'react-native';
|
||||||
|
|
||||||
|
import { createTask, fetchTasks, fetchTenantProfiles, Task, TaskStatus, updateTask } from '@/src/lib/api';
|
||||||
|
import { useAuth } from '@/src/providers/auth-provider';
|
||||||
|
|
||||||
|
const STATUSES: TaskStatus[] = ['Offen', 'In Bearbeitung', 'Abgeschlossen'];
|
||||||
|
const PRIMARY = '#69c350';
|
||||||
|
|
||||||
|
function normalizeStatus(status: unknown): TaskStatus {
|
||||||
|
if (status === 'In Bearbeitung' || status === 'Abgeschlossen') return status;
|
||||||
|
return 'Offen';
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTaskAssigneeId(task: Task): string | null {
|
||||||
|
return (task.userId || task.user_id || task.profile || null) as string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function TasksScreen() {
|
||||||
|
const { token, user, activeTenantId } = useAuth();
|
||||||
|
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [refreshing, setRefreshing] = useState(false);
|
||||||
|
const [saving, setSaving] = useState(false);
|
||||||
|
const [updatingTaskId, setUpdatingTaskId] = useState<number | null>(null);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const [tasks, setTasks] = useState<Task[]>([]);
|
||||||
|
const [profiles, setProfiles] = useState<{ id: string; label: string }[]>([]);
|
||||||
|
|
||||||
|
const [search, setSearch] = useState('');
|
||||||
|
const [statusFilter, setStatusFilter] = useState<'Alle' | TaskStatus>('Alle');
|
||||||
|
const [showCompleted, setShowCompleted] = useState(false);
|
||||||
|
|
||||||
|
const [showSearchPanel, setShowSearchPanel] = useState(false);
|
||||||
|
const [showFilterPanel, setShowFilterPanel] = useState(false);
|
||||||
|
|
||||||
|
const [createModalOpen, setCreateModalOpen] = useState(false);
|
||||||
|
const [createError, setCreateError] = useState<string | null>(null);
|
||||||
|
const [newTaskName, setNewTaskName] = useState('');
|
||||||
|
const [newTaskDescription, setNewTaskDescription] = useState('');
|
||||||
|
|
||||||
|
const currentUserId = useMemo(() => (user?.id ? String(user.id) : null), [user]);
|
||||||
|
|
||||||
|
const filteredTasks = useMemo(() => {
|
||||||
|
const needle = search.trim().toLowerCase();
|
||||||
|
|
||||||
|
return tasks
|
||||||
|
.filter((task) => {
|
||||||
|
const status = normalizeStatus(task.categorie);
|
||||||
|
if (!showCompleted && status === 'Abgeschlossen') return false;
|
||||||
|
const statusMatch = statusFilter === 'Alle' || status === statusFilter;
|
||||||
|
const textMatch =
|
||||||
|
!needle ||
|
||||||
|
[task.name, task.description, task.categorie].some((value) =>
|
||||||
|
String(value || '').toLowerCase().includes(needle)
|
||||||
|
);
|
||||||
|
return statusMatch && textMatch;
|
||||||
|
})
|
||||||
|
.sort((a, b) => Number(a.id) - Number(b.id));
|
||||||
|
}, [search, showCompleted, statusFilter, tasks]);
|
||||||
|
|
||||||
|
function getAssigneeLabel(task: Task): string {
|
||||||
|
const assigneeId = getTaskAssigneeId(task);
|
||||||
|
if (!assigneeId) return '-';
|
||||||
|
return profiles.find((profile) => profile.id === assigneeId)?.label || assigneeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
const loadTasks = useCallback(
|
||||||
|
async (showSpinner = true) => {
|
||||||
|
if (!token) return;
|
||||||
|
|
||||||
|
if (showSpinner) setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const [taskRows, profileRows] = await Promise.all([fetchTasks(token), fetchTenantProfiles(token)]);
|
||||||
|
setTasks(taskRows || []);
|
||||||
|
setProfiles(
|
||||||
|
(profileRows || [])
|
||||||
|
.map((profile) => {
|
||||||
|
const id = profile.user_id || (profile.id ? String(profile.id) : null);
|
||||||
|
const label = profile.full_name || profile.fullName || profile.email || id;
|
||||||
|
return id ? { id: String(id), label: String(label || id) } : null;
|
||||||
|
})
|
||||||
|
.filter((value): value is { id: string; label: string } => Boolean(value))
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
setError(err instanceof Error ? err.message : 'Aufgaben konnten nicht geladen werden.');
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
setRefreshing(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[token]
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!token || !activeTenantId) return;
|
||||||
|
void loadTasks(true);
|
||||||
|
}, [token, activeTenantId, loadTasks]);
|
||||||
|
|
||||||
|
async function onRefresh() {
|
||||||
|
if (!token) return;
|
||||||
|
setRefreshing(true);
|
||||||
|
await loadTasks(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeCreateModal() {
|
||||||
|
setCreateModalOpen(false);
|
||||||
|
setCreateError(null);
|
||||||
|
setNewTaskName('');
|
||||||
|
setNewTaskDescription('');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onCreateTask() {
|
||||||
|
if (!token) return;
|
||||||
|
|
||||||
|
const name = newTaskName.trim();
|
||||||
|
if (!name) {
|
||||||
|
setCreateError('Bitte einen Aufgabennamen eingeben.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setSaving(true);
|
||||||
|
setCreateError(null);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await createTask(token, {
|
||||||
|
name,
|
||||||
|
description: newTaskDescription.trim() || null,
|
||||||
|
categorie: 'Offen',
|
||||||
|
userId: currentUserId,
|
||||||
|
});
|
||||||
|
|
||||||
|
closeCreateModal();
|
||||||
|
await loadTasks(false);
|
||||||
|
} catch (err) {
|
||||||
|
setCreateError(err instanceof Error ? err.message : 'Aufgabe konnte nicht erstellt werden.');
|
||||||
|
} finally {
|
||||||
|
setSaving(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function setTaskStatus(task: Task, status: TaskStatus) {
|
||||||
|
if (!token || !task?.id) return;
|
||||||
|
if (normalizeStatus(task.categorie) === status) return;
|
||||||
|
|
||||||
|
setUpdatingTaskId(Number(task.id));
|
||||||
|
setError(null);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await updateTask(token, Number(task.id), { categorie: status });
|
||||||
|
setTasks((prev) => prev.map((item) => (item.id === task.id ? { ...item, categorie: status } : item)));
|
||||||
|
} catch (err) {
|
||||||
|
setError(err instanceof Error ? err.message : 'Status konnte nicht gesetzt werden.');
|
||||||
|
} finally {
|
||||||
|
setUpdatingTaskId(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={styles.screen}>
|
||||||
|
<ScrollView
|
||||||
|
contentContainerStyle={styles.container}
|
||||||
|
refreshControl={<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />}>
|
||||||
|
<View style={styles.topActions}>
|
||||||
|
<Pressable
|
||||||
|
style={[styles.topActionButton, showSearchPanel ? styles.topActionButtonActive : null]}
|
||||||
|
onPress={() => setShowSearchPanel((prev) => !prev)}>
|
||||||
|
<Text style={[styles.topActionText, showSearchPanel ? styles.topActionTextActive : null]}>Suche</Text>
|
||||||
|
</Pressable>
|
||||||
|
<Pressable
|
||||||
|
style={[styles.topActionButton, showFilterPanel ? styles.topActionButtonActive : null]}
|
||||||
|
onPress={() => setShowFilterPanel((prev) => !prev)}>
|
||||||
|
<Text style={[styles.topActionText, showFilterPanel ? styles.topActionTextActive : null]}>Filter</Text>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{showSearchPanel ? (
|
||||||
|
<View style={styles.panel}>
|
||||||
|
<TextInput
|
||||||
|
placeholder="Suche"
|
||||||
|
placeholderTextColor="#9ca3af"
|
||||||
|
style={styles.input}
|
||||||
|
value={search}
|
||||||
|
onChangeText={setSearch}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{showFilterPanel ? (
|
||||||
|
<View style={styles.panel}>
|
||||||
|
<View style={styles.filterRow}>
|
||||||
|
{(['Alle', 'Offen', 'In Bearbeitung'] as const).map((status) => (
|
||||||
|
<Pressable
|
||||||
|
key={status}
|
||||||
|
style={[styles.filterChip, statusFilter === status ? styles.filterChipActive : null]}
|
||||||
|
onPress={() => setStatusFilter(status)}>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
styles.filterChipText,
|
||||||
|
statusFilter === status ? styles.filterChipTextActive : null,
|
||||||
|
]}>
|
||||||
|
{status}
|
||||||
|
</Text>
|
||||||
|
</Pressable>
|
||||||
|
))}
|
||||||
|
<Pressable
|
||||||
|
style={[styles.filterChip, showCompleted ? styles.filterChipActive : null]}
|
||||||
|
onPress={() => setShowCompleted((prev) => !prev)}>
|
||||||
|
<Text style={[styles.filterChipText, showCompleted ? styles.filterChipTextActive : null]}>
|
||||||
|
Abgeschlossene anzeigen
|
||||||
|
</Text>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{error ? <Text style={styles.error}>{error}</Text> : null}
|
||||||
|
|
||||||
|
{loading ? (
|
||||||
|
<View style={styles.loadingBox}>
|
||||||
|
<ActivityIndicator />
|
||||||
|
<Text style={styles.loadingText}>Aufgaben werden geladen...</Text>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{!loading && filteredTasks.length === 0 ? (
|
||||||
|
<Text style={styles.empty}>Keine Aufgaben gefunden.</Text>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{!loading &&
|
||||||
|
filteredTasks.map((task) => {
|
||||||
|
const status = normalizeStatus(task.categorie);
|
||||||
|
const isUpdating = updatingTaskId === Number(task.id);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View key={String(task.id)} style={styles.taskCard}>
|
||||||
|
<View style={styles.taskHeader}>
|
||||||
|
<Text style={styles.taskTitle} numberOfLines={2}>
|
||||||
|
{task.name}
|
||||||
|
</Text>
|
||||||
|
<Text style={styles.statusBadge}>{status}</Text>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{task.description ? (
|
||||||
|
<Text style={styles.taskDescription} numberOfLines={3}>
|
||||||
|
{task.description}
|
||||||
|
</Text>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<Text style={styles.taskMeta}>Zuweisung: {getAssigneeLabel(task)}</Text>
|
||||||
|
|
||||||
|
<View style={styles.actionRow}>
|
||||||
|
{STATUSES.map((nextStatus) => (
|
||||||
|
<Pressable
|
||||||
|
key={nextStatus}
|
||||||
|
style={[
|
||||||
|
styles.actionButton,
|
||||||
|
nextStatus === status ? styles.actionButtonActive : null,
|
||||||
|
isUpdating ? styles.buttonDisabled : null,
|
||||||
|
]}
|
||||||
|
onPress={() => setTaskStatus(task, nextStatus)}
|
||||||
|
disabled={isUpdating || nextStatus === status}>
|
||||||
|
<Text style={styles.actionButtonText}>{nextStatus}</Text>
|
||||||
|
</Pressable>
|
||||||
|
))}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
<Pressable style={styles.fab} onPress={() => setCreateModalOpen(true)}>
|
||||||
|
<Text style={styles.fabText}>+</Text>
|
||||||
|
</Pressable>
|
||||||
|
|
||||||
|
<Modal visible={createModalOpen} transparent animationType="fade" onRequestClose={closeCreateModal}>
|
||||||
|
<View style={styles.modalOverlay}>
|
||||||
|
<KeyboardAvoidingView
|
||||||
|
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
|
||||||
|
style={styles.modalKeyboardWrap}>
|
||||||
|
<View style={styles.modalCard}>
|
||||||
|
<Text style={styles.modalTitle}>Neue Aufgabe</Text>
|
||||||
|
|
||||||
|
<TextInput
|
||||||
|
placeholder="Titel"
|
||||||
|
placeholderTextColor="#9ca3af"
|
||||||
|
style={styles.input}
|
||||||
|
value={newTaskName}
|
||||||
|
onChangeText={setNewTaskName}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
placeholder="Beschreibung (optional)"
|
||||||
|
placeholderTextColor="#9ca3af"
|
||||||
|
style={[styles.input, styles.inputMultiline]}
|
||||||
|
multiline
|
||||||
|
value={newTaskDescription}
|
||||||
|
onChangeText={setNewTaskDescription}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{createError ? <Text style={styles.error}>{createError}</Text> : null}
|
||||||
|
|
||||||
|
<View style={styles.modalActions}>
|
||||||
|
<Pressable style={styles.secondaryButton} onPress={closeCreateModal} disabled={saving}>
|
||||||
|
<Text style={styles.secondaryButtonText}>Abbrechen</Text>
|
||||||
|
</Pressable>
|
||||||
|
<Pressable
|
||||||
|
style={[styles.primaryButton, saving ? styles.buttonDisabled : null]}
|
||||||
|
onPress={onCreateTask}
|
||||||
|
disabled={saving}>
|
||||||
|
<Text style={styles.primaryButtonText}>{saving ? 'Speichere...' : 'Anlegen'}</Text>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</KeyboardAvoidingView>
|
||||||
|
</View>
|
||||||
|
</Modal>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
screen: {
|
||||||
|
flex: 1,
|
||||||
|
backgroundColor: '#f9fafb',
|
||||||
|
},
|
||||||
|
container: {
|
||||||
|
padding: 16,
|
||||||
|
gap: 12,
|
||||||
|
paddingBottom: 96,
|
||||||
|
},
|
||||||
|
topActions: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
gap: 8,
|
||||||
|
},
|
||||||
|
topActionButton: {
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: '#d1d5db',
|
||||||
|
borderRadius: 10,
|
||||||
|
paddingHorizontal: 12,
|
||||||
|
paddingVertical: 8,
|
||||||
|
backgroundColor: '#ffffff',
|
||||||
|
},
|
||||||
|
topActionButtonActive: {
|
||||||
|
borderColor: PRIMARY,
|
||||||
|
backgroundColor: '#eff9ea',
|
||||||
|
},
|
||||||
|
topActionText: {
|
||||||
|
color: '#374151',
|
||||||
|
fontWeight: '600',
|
||||||
|
},
|
||||||
|
topActionTextActive: {
|
||||||
|
color: '#3d7a30',
|
||||||
|
},
|
||||||
|
panel: {
|
||||||
|
backgroundColor: '#ffffff',
|
||||||
|
borderRadius: 12,
|
||||||
|
padding: 12,
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: '#e5e7eb',
|
||||||
|
},
|
||||||
|
input: {
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: '#d1d5db',
|
||||||
|
borderRadius: 10,
|
||||||
|
paddingHorizontal: 12,
|
||||||
|
paddingVertical: 10,
|
||||||
|
fontSize: 15,
|
||||||
|
color: '#111827',
|
||||||
|
backgroundColor: '#ffffff',
|
||||||
|
},
|
||||||
|
inputMultiline: {
|
||||||
|
minHeight: 72,
|
||||||
|
textAlignVertical: 'top',
|
||||||
|
},
|
||||||
|
filterRow: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
gap: 8,
|
||||||
|
},
|
||||||
|
filterChip: {
|
||||||
|
borderRadius: 999,
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: '#d1d5db',
|
||||||
|
paddingHorizontal: 10,
|
||||||
|
paddingVertical: 6,
|
||||||
|
backgroundColor: '#ffffff',
|
||||||
|
},
|
||||||
|
filterChipActive: {
|
||||||
|
borderColor: PRIMARY,
|
||||||
|
backgroundColor: '#eff9ea',
|
||||||
|
},
|
||||||
|
filterChipText: {
|
||||||
|
color: '#374151',
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: '500',
|
||||||
|
},
|
||||||
|
filterChipTextActive: {
|
||||||
|
color: '#3d7a30',
|
||||||
|
},
|
||||||
|
error: {
|
||||||
|
color: '#dc2626',
|
||||||
|
fontSize: 13,
|
||||||
|
},
|
||||||
|
loadingBox: {
|
||||||
|
padding: 16,
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: 8,
|
||||||
|
},
|
||||||
|
loadingText: {
|
||||||
|
color: '#6b7280',
|
||||||
|
},
|
||||||
|
empty: {
|
||||||
|
color: '#6b7280',
|
||||||
|
textAlign: 'center',
|
||||||
|
paddingVertical: 16,
|
||||||
|
},
|
||||||
|
taskCard: {
|
||||||
|
backgroundColor: '#ffffff',
|
||||||
|
borderRadius: 12,
|
||||||
|
padding: 12,
|
||||||
|
gap: 8,
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: '#e5e7eb',
|
||||||
|
},
|
||||||
|
taskHeader: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
alignItems: 'flex-start',
|
||||||
|
gap: 8,
|
||||||
|
},
|
||||||
|
taskTitle: {
|
||||||
|
flex: 1,
|
||||||
|
color: '#111827',
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: '600',
|
||||||
|
},
|
||||||
|
statusBadge: {
|
||||||
|
color: '#3d7a30',
|
||||||
|
backgroundColor: '#eff9ea',
|
||||||
|
borderRadius: 999,
|
||||||
|
paddingHorizontal: 8,
|
||||||
|
paddingVertical: 4,
|
||||||
|
fontSize: 12,
|
||||||
|
overflow: 'hidden',
|
||||||
|
},
|
||||||
|
taskDescription: {
|
||||||
|
color: '#374151',
|
||||||
|
fontSize: 14,
|
||||||
|
},
|
||||||
|
taskMeta: {
|
||||||
|
color: '#6b7280',
|
||||||
|
fontSize: 12,
|
||||||
|
},
|
||||||
|
actionRow: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
gap: 8,
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
},
|
||||||
|
actionButton: {
|
||||||
|
borderRadius: 8,
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: '#d1d5db',
|
||||||
|
backgroundColor: '#ffffff',
|
||||||
|
paddingHorizontal: 10,
|
||||||
|
paddingVertical: 7,
|
||||||
|
},
|
||||||
|
actionButtonActive: {
|
||||||
|
borderColor: PRIMARY,
|
||||||
|
backgroundColor: '#eff9ea',
|
||||||
|
},
|
||||||
|
actionButtonText: {
|
||||||
|
color: '#1f2937',
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: '500',
|
||||||
|
},
|
||||||
|
fab: {
|
||||||
|
position: 'absolute',
|
||||||
|
right: 18,
|
||||||
|
bottom: 24,
|
||||||
|
width: 56,
|
||||||
|
height: 56,
|
||||||
|
borderRadius: 28,
|
||||||
|
backgroundColor: PRIMARY,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
elevation: 4,
|
||||||
|
shadowColor: '#111827',
|
||||||
|
shadowOpacity: 0.18,
|
||||||
|
shadowRadius: 10,
|
||||||
|
shadowOffset: { width: 0, height: 4 },
|
||||||
|
},
|
||||||
|
fabText: {
|
||||||
|
color: '#ffffff',
|
||||||
|
fontSize: 30,
|
||||||
|
lineHeight: 30,
|
||||||
|
fontWeight: '500',
|
||||||
|
marginTop: -1,
|
||||||
|
},
|
||||||
|
modalOverlay: {
|
||||||
|
flex: 1,
|
||||||
|
backgroundColor: 'rgba(0,0,0,0.35)',
|
||||||
|
justifyContent: 'center',
|
||||||
|
padding: 16,
|
||||||
|
},
|
||||||
|
modalKeyboardWrap: {
|
||||||
|
width: '100%',
|
||||||
|
},
|
||||||
|
modalCard: {
|
||||||
|
backgroundColor: '#ffffff',
|
||||||
|
borderRadius: 14,
|
||||||
|
padding: 14,
|
||||||
|
gap: 10,
|
||||||
|
},
|
||||||
|
modalTitle: {
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: '700',
|
||||||
|
color: '#111827',
|
||||||
|
},
|
||||||
|
modalActions: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
justifyContent: 'flex-end',
|
||||||
|
gap: 8,
|
||||||
|
marginTop: 2,
|
||||||
|
},
|
||||||
|
secondaryButton: {
|
||||||
|
minHeight: 42,
|
||||||
|
borderRadius: 10,
|
||||||
|
paddingHorizontal: 14,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
backgroundColor: '#e5e7eb',
|
||||||
|
},
|
||||||
|
secondaryButtonText: {
|
||||||
|
color: '#111827',
|
||||||
|
fontWeight: '600',
|
||||||
|
},
|
||||||
|
primaryButton: {
|
||||||
|
minHeight: 42,
|
||||||
|
borderRadius: 10,
|
||||||
|
paddingHorizontal: 14,
|
||||||
|
backgroundColor: PRIMARY,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
},
|
||||||
|
primaryButtonText: {
|
||||||
|
color: '#ffffff',
|
||||||
|
fontWeight: '600',
|
||||||
|
},
|
||||||
|
buttonDisabled: {
|
||||||
|
opacity: 0.6,
|
||||||
|
},
|
||||||
|
});
|
||||||
19
mobile/app/_layout.tsx
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import { Stack } from 'expo-router';
|
||||||
|
import { StatusBar } from 'expo-status-bar';
|
||||||
|
import 'react-native-reanimated';
|
||||||
|
|
||||||
|
import { AuthProvider } from '@/src/providers/auth-provider';
|
||||||
|
|
||||||
|
export default function RootLayout() {
|
||||||
|
return (
|
||||||
|
<AuthProvider>
|
||||||
|
<Stack>
|
||||||
|
<Stack.Screen name="index" options={{ headerShown: false }} />
|
||||||
|
<Stack.Screen name="login" options={{ title: 'Login', headerBackVisible: false }} />
|
||||||
|
<Stack.Screen name="tenant-select" options={{ title: 'Tenant auswaehlen', headerBackVisible: false }} />
|
||||||
|
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
||||||
|
</Stack>
|
||||||
|
<StatusBar style="dark" />
|
||||||
|
</AuthProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
41
mobile/app/index.tsx
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { Redirect } from 'expo-router';
|
||||||
|
import { ActivityIndicator, StyleSheet, Text, View } from 'react-native';
|
||||||
|
|
||||||
|
import { useAuth } from '@/src/providers/auth-provider';
|
||||||
|
|
||||||
|
export default function IndexScreen() {
|
||||||
|
const { isBootstrapping, token, requiresTenantSelection } = useAuth();
|
||||||
|
|
||||||
|
if (isBootstrapping) {
|
||||||
|
return (
|
||||||
|
<View style={styles.centered}>
|
||||||
|
<ActivityIndicator size="large" />
|
||||||
|
<Text style={styles.copy}>Initialisiere mobile Session...</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!token) {
|
||||||
|
return <Redirect href="/login" />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requiresTenantSelection) {
|
||||||
|
return <Redirect href="/tenant-select" />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return <Redirect href="/(tabs)" />;
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
centered: {
|
||||||
|
flex: 1,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
gap: 12,
|
||||||
|
padding: 24,
|
||||||
|
},
|
||||||
|
copy: {
|
||||||
|
fontSize: 14,
|
||||||
|
color: '#4b5563',
|
||||||
|
},
|
||||||
|
});
|
||||||
164
mobile/app/login.tsx
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
import { Redirect, router } from 'expo-router';
|
||||||
|
import {
|
||||||
|
ActivityIndicator,
|
||||||
|
KeyboardAvoidingView,
|
||||||
|
Platform,
|
||||||
|
Pressable,
|
||||||
|
StyleSheet,
|
||||||
|
Text,
|
||||||
|
TextInput,
|
||||||
|
View,
|
||||||
|
} from 'react-native';
|
||||||
|
|
||||||
|
import { API_BASE_URL } from '@/src/config/env';
|
||||||
|
import { useAuth, useTokenStorageInfo } from '@/src/providers/auth-provider';
|
||||||
|
|
||||||
|
export default function LoginScreen() {
|
||||||
|
const { token, requiresTenantSelection, login } = useAuth();
|
||||||
|
const storageInfo = useTokenStorageInfo();
|
||||||
|
|
||||||
|
const [email, setEmail] = useState('');
|
||||||
|
const [password, setPassword] = useState('');
|
||||||
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
if (token) {
|
||||||
|
return <Redirect href={requiresTenantSelection ? '/tenant-select' : '/(tabs)'} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onSubmit() {
|
||||||
|
setIsSubmitting(true);
|
||||||
|
setError(null);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await login(email.trim(), password);
|
||||||
|
router.replace('/');
|
||||||
|
} catch (err) {
|
||||||
|
setError(err instanceof Error ? err.message : 'Login fehlgeschlagen.');
|
||||||
|
} finally {
|
||||||
|
setIsSubmitting(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<KeyboardAvoidingView
|
||||||
|
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
|
||||||
|
style={styles.container}>
|
||||||
|
<View style={styles.card}>
|
||||||
|
<Text style={styles.title}>FEDEO Mobile</Text>
|
||||||
|
<Text style={styles.subtitle}>Login mit anschliessender Tenant-Auswahl</Text>
|
||||||
|
|
||||||
|
<Text style={styles.label}>E-Mail</Text>
|
||||||
|
<TextInput
|
||||||
|
autoCapitalize="none"
|
||||||
|
autoCorrect={false}
|
||||||
|
keyboardType="email-address"
|
||||||
|
placeholder="name@firma.de"
|
||||||
|
placeholderTextColor="#9ca3af"
|
||||||
|
style={styles.input}
|
||||||
|
value={email}
|
||||||
|
onChangeText={setEmail}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Text style={styles.label}>Passwort</Text>
|
||||||
|
<TextInput
|
||||||
|
secureTextEntry
|
||||||
|
placeholder="••••••••"
|
||||||
|
placeholderTextColor="#9ca3af"
|
||||||
|
style={styles.input}
|
||||||
|
value={password}
|
||||||
|
onChangeText={setPassword}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{error ? <Text style={styles.error}>{error}</Text> : null}
|
||||||
|
|
||||||
|
<Pressable
|
||||||
|
style={[styles.button, isSubmitting ? styles.buttonDisabled : null]}
|
||||||
|
onPress={onSubmit}
|
||||||
|
disabled={isSubmitting || !email || !password}>
|
||||||
|
{isSubmitting ? <ActivityIndicator color="#ffffff" /> : <Text style={styles.buttonText}>Anmelden</Text>}
|
||||||
|
</Pressable>
|
||||||
|
|
||||||
|
<View style={styles.metaBox}>
|
||||||
|
<Text style={styles.metaText}>API: {API_BASE_URL}</Text>
|
||||||
|
<Text style={styles.metaText}>Token Storage: {storageInfo.mode}</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</KeyboardAvoidingView>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
flex: 1,
|
||||||
|
justifyContent: 'center',
|
||||||
|
padding: 20,
|
||||||
|
backgroundColor: '#f3f4f6',
|
||||||
|
},
|
||||||
|
card: {
|
||||||
|
backgroundColor: '#ffffff',
|
||||||
|
borderRadius: 16,
|
||||||
|
padding: 20,
|
||||||
|
gap: 10,
|
||||||
|
shadowColor: '#111827',
|
||||||
|
shadowOpacity: 0.08,
|
||||||
|
shadowRadius: 16,
|
||||||
|
shadowOffset: { width: 0, height: 8 },
|
||||||
|
elevation: 3,
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
fontSize: 24,
|
||||||
|
fontWeight: '700',
|
||||||
|
color: '#111827',
|
||||||
|
},
|
||||||
|
subtitle: {
|
||||||
|
color: '#6b7280',
|
||||||
|
marginBottom: 8,
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
fontSize: 14,
|
||||||
|
color: '#374151',
|
||||||
|
fontWeight: '500',
|
||||||
|
},
|
||||||
|
input: {
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: '#d1d5db',
|
||||||
|
borderRadius: 10,
|
||||||
|
paddingHorizontal: 12,
|
||||||
|
paddingVertical: 10,
|
||||||
|
fontSize: 16,
|
||||||
|
color: '#111827',
|
||||||
|
},
|
||||||
|
button: {
|
||||||
|
marginTop: 6,
|
||||||
|
backgroundColor: '#16a34a',
|
||||||
|
borderRadius: 10,
|
||||||
|
minHeight: 44,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
},
|
||||||
|
buttonDisabled: {
|
||||||
|
backgroundColor: '#86efac',
|
||||||
|
},
|
||||||
|
buttonText: {
|
||||||
|
color: '#ffffff',
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: '600',
|
||||||
|
},
|
||||||
|
error: {
|
||||||
|
color: '#dc2626',
|
||||||
|
fontSize: 13,
|
||||||
|
},
|
||||||
|
metaBox: {
|
||||||
|
marginTop: 8,
|
||||||
|
paddingTop: 8,
|
||||||
|
borderTopWidth: 1,
|
||||||
|
borderTopColor: '#e5e7eb',
|
||||||
|
gap: 4,
|
||||||
|
},
|
||||||
|
metaText: {
|
||||||
|
fontSize: 12,
|
||||||
|
color: '#6b7280',
|
||||||
|
},
|
||||||
|
});
|
||||||
29
mobile/app/modal.tsx
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import { Link } from 'expo-router';
|
||||||
|
import { StyleSheet } from 'react-native';
|
||||||
|
|
||||||
|
import { ThemedText } from '@/components/themed-text';
|
||||||
|
import { ThemedView } from '@/components/themed-view';
|
||||||
|
|
||||||
|
export default function ModalScreen() {
|
||||||
|
return (
|
||||||
|
<ThemedView style={styles.container}>
|
||||||
|
<ThemedText type="title">This is a modal</ThemedText>
|
||||||
|
<Link href="/" dismissTo style={styles.link}>
|
||||||
|
<ThemedText type="link">Go to home screen</ThemedText>
|
||||||
|
</Link>
|
||||||
|
</ThemedView>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
flex: 1,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
padding: 20,
|
||||||
|
},
|
||||||
|
link: {
|
||||||
|
marginTop: 15,
|
||||||
|
paddingVertical: 15,
|
||||||
|
},
|
||||||
|
});
|
||||||
110
mobile/app/tenant-select.tsx
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
import { Redirect, router } from 'expo-router';
|
||||||
|
import { ActivityIndicator, Pressable, ScrollView, StyleSheet, Text, View } from 'react-native';
|
||||||
|
|
||||||
|
import { useAuth } from '@/src/providers/auth-provider';
|
||||||
|
|
||||||
|
export default function TenantSelectScreen() {
|
||||||
|
const { token, tenants, activeTenantId, requiresTenantSelection, switchTenant } = useAuth();
|
||||||
|
|
||||||
|
const [switchingTenantId, setSwitchingTenantId] = useState<number | null>(null);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
if (!token) {
|
||||||
|
return <Redirect href="/login" />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!requiresTenantSelection && activeTenantId) {
|
||||||
|
return <Redirect href="/(tabs)" />;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onSelectTenant(tenantId: number) {
|
||||||
|
setSwitchingTenantId(tenantId);
|
||||||
|
setError(null);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await switchTenant(tenantId);
|
||||||
|
router.replace('/(tabs)');
|
||||||
|
} catch (err) {
|
||||||
|
setError(err instanceof Error ? err.message : 'Tenant konnte nicht gewechselt werden.');
|
||||||
|
} finally {
|
||||||
|
setSwitchingTenantId(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ScrollView contentContainerStyle={styles.container}>
|
||||||
|
<Text style={styles.title}>Tenant auswaehlen</Text>
|
||||||
|
<Text style={styles.subtitle}>Bitte waehle den Tenant fuer deine Session.</Text>
|
||||||
|
|
||||||
|
{error ? <Text style={styles.error}>{error}</Text> : null}
|
||||||
|
|
||||||
|
{tenants.map((tenant) => {
|
||||||
|
const tenantId = Number(tenant.id);
|
||||||
|
const isBusy = switchingTenantId === tenantId;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Pressable
|
||||||
|
key={String(tenant.id)}
|
||||||
|
style={[styles.tenantButton, isBusy ? styles.tenantButtonDisabled : null]}
|
||||||
|
onPress={() => onSelectTenant(tenantId)}
|
||||||
|
disabled={switchingTenantId !== null}>
|
||||||
|
<View>
|
||||||
|
<Text style={styles.tenantName}>{tenant.name}</Text>
|
||||||
|
<Text style={styles.tenantMeta}>ID: {tenantId}</Text>
|
||||||
|
</View>
|
||||||
|
{isBusy ? <ActivityIndicator /> : <Text style={styles.tenantAction}>Auswaehlen</Text>}
|
||||||
|
</Pressable>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</ScrollView>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
flexGrow: 1,
|
||||||
|
padding: 16,
|
||||||
|
gap: 10,
|
||||||
|
backgroundColor: '#f9fafb',
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
fontSize: 24,
|
||||||
|
fontWeight: '700',
|
||||||
|
color: '#111827',
|
||||||
|
},
|
||||||
|
subtitle: {
|
||||||
|
color: '#6b7280',
|
||||||
|
marginBottom: 8,
|
||||||
|
},
|
||||||
|
error: {
|
||||||
|
color: '#dc2626',
|
||||||
|
marginBottom: 8,
|
||||||
|
},
|
||||||
|
tenantButton: {
|
||||||
|
borderRadius: 12,
|
||||||
|
padding: 14,
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: '#d1d5db',
|
||||||
|
backgroundColor: '#ffffff',
|
||||||
|
flexDirection: 'row',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
alignItems: 'center',
|
||||||
|
},
|
||||||
|
tenantButtonDisabled: {
|
||||||
|
opacity: 0.6,
|
||||||
|
},
|
||||||
|
tenantName: {
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: '600',
|
||||||
|
color: '#111827',
|
||||||
|
},
|
||||||
|
tenantMeta: {
|
||||||
|
color: '#6b7280',
|
||||||
|
marginTop: 4,
|
||||||
|
},
|
||||||
|
tenantAction: {
|
||||||
|
color: '#2563eb',
|
||||||
|
fontWeight: '600',
|
||||||
|
},
|
||||||
|
});
|
||||||
BIN
mobile/assets/images/android-icon-background.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
mobile/assets/images/android-icon-foreground.png
Normal file
|
After Width: | Height: | Size: 77 KiB |
BIN
mobile/assets/images/android-icon-monochrome.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
mobile/assets/images/favicon.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
mobile/assets/images/icon.png
Normal file
|
After Width: | Height: | Size: 384 KiB |
BIN
mobile/assets/images/partial-react-logo.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
mobile/assets/images/react-logo.png
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
mobile/assets/images/react-logo@2x.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
mobile/assets/images/react-logo@3x.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
mobile/assets/images/splash-icon.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
25
mobile/components/external-link.tsx
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { Href, Link } from 'expo-router';
|
||||||
|
import { openBrowserAsync, WebBrowserPresentationStyle } from 'expo-web-browser';
|
||||||
|
import { type ComponentProps } from 'react';
|
||||||
|
|
||||||
|
type Props = Omit<ComponentProps<typeof Link>, 'href'> & { href: Href & string };
|
||||||
|
|
||||||
|
export function ExternalLink({ href, ...rest }: Props) {
|
||||||
|
return (
|
||||||
|
<Link
|
||||||
|
target="_blank"
|
||||||
|
{...rest}
|
||||||
|
href={href}
|
||||||
|
onPress={async (event) => {
|
||||||
|
if (process.env.EXPO_OS !== 'web') {
|
||||||
|
// Prevent the default behavior of linking to the default browser on native.
|
||||||
|
event.preventDefault();
|
||||||
|
// Open the link in an in-app browser.
|
||||||
|
await openBrowserAsync(href, {
|
||||||
|
presentationStyle: WebBrowserPresentationStyle.AUTOMATIC,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
18
mobile/components/haptic-tab.tsx
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { BottomTabBarButtonProps } from '@react-navigation/bottom-tabs';
|
||||||
|
import { PlatformPressable } from '@react-navigation/elements';
|
||||||
|
import * as Haptics from 'expo-haptics';
|
||||||
|
|
||||||
|
export function HapticTab(props: BottomTabBarButtonProps) {
|
||||||
|
return (
|
||||||
|
<PlatformPressable
|
||||||
|
{...props}
|
||||||
|
onPressIn={(ev) => {
|
||||||
|
if (process.env.EXPO_OS === 'ios') {
|
||||||
|
// Add a soft haptic feedback when pressing down on the tabs.
|
||||||
|
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
|
||||||
|
}
|
||||||
|
props.onPressIn?.(ev);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
19
mobile/components/hello-wave.tsx
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import Animated from 'react-native-reanimated';
|
||||||
|
|
||||||
|
export function HelloWave() {
|
||||||
|
return (
|
||||||
|
<Animated.Text
|
||||||
|
style={{
|
||||||
|
fontSize: 28,
|
||||||
|
lineHeight: 32,
|
||||||
|
marginTop: -6,
|
||||||
|
animationName: {
|
||||||
|
'50%': { transform: [{ rotate: '25deg' }] },
|
||||||
|
},
|
||||||
|
animationIterationCount: 4,
|
||||||
|
animationDuration: '300ms',
|
||||||
|
}}>
|
||||||
|
👋
|
||||||
|
</Animated.Text>
|
||||||
|
);
|
||||||
|
}
|
||||||
79
mobile/components/parallax-scroll-view.tsx
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
import type { PropsWithChildren, ReactElement } from 'react';
|
||||||
|
import { StyleSheet } from 'react-native';
|
||||||
|
import Animated, {
|
||||||
|
interpolate,
|
||||||
|
useAnimatedRef,
|
||||||
|
useAnimatedStyle,
|
||||||
|
useScrollOffset,
|
||||||
|
} from 'react-native-reanimated';
|
||||||
|
|
||||||
|
import { ThemedView } from '@/components/themed-view';
|
||||||
|
import { useColorScheme } from '@/hooks/use-color-scheme';
|
||||||
|
import { useThemeColor } from '@/hooks/use-theme-color';
|
||||||
|
|
||||||
|
const HEADER_HEIGHT = 250;
|
||||||
|
|
||||||
|
type Props = PropsWithChildren<{
|
||||||
|
headerImage: ReactElement;
|
||||||
|
headerBackgroundColor: { dark: string; light: string };
|
||||||
|
}>;
|
||||||
|
|
||||||
|
export default function ParallaxScrollView({
|
||||||
|
children,
|
||||||
|
headerImage,
|
||||||
|
headerBackgroundColor,
|
||||||
|
}: Props) {
|
||||||
|
const backgroundColor = useThemeColor({}, 'background');
|
||||||
|
const colorScheme = useColorScheme() ?? 'light';
|
||||||
|
const scrollRef = useAnimatedRef<Animated.ScrollView>();
|
||||||
|
const scrollOffset = useScrollOffset(scrollRef);
|
||||||
|
const headerAnimatedStyle = useAnimatedStyle(() => {
|
||||||
|
return {
|
||||||
|
transform: [
|
||||||
|
{
|
||||||
|
translateY: interpolate(
|
||||||
|
scrollOffset.value,
|
||||||
|
[-HEADER_HEIGHT, 0, HEADER_HEIGHT],
|
||||||
|
[-HEADER_HEIGHT / 2, 0, HEADER_HEIGHT * 0.75]
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
scale: interpolate(scrollOffset.value, [-HEADER_HEIGHT, 0, HEADER_HEIGHT], [2, 1, 1]),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Animated.ScrollView
|
||||||
|
ref={scrollRef}
|
||||||
|
style={{ backgroundColor, flex: 1 }}
|
||||||
|
scrollEventThrottle={16}>
|
||||||
|
<Animated.View
|
||||||
|
style={[
|
||||||
|
styles.header,
|
||||||
|
{ backgroundColor: headerBackgroundColor[colorScheme] },
|
||||||
|
headerAnimatedStyle,
|
||||||
|
]}>
|
||||||
|
{headerImage}
|
||||||
|
</Animated.View>
|
||||||
|
<ThemedView style={styles.content}>{children}</ThemedView>
|
||||||
|
</Animated.ScrollView>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
flex: 1,
|
||||||
|
},
|
||||||
|
header: {
|
||||||
|
height: HEADER_HEIGHT,
|
||||||
|
overflow: 'hidden',
|
||||||
|
},
|
||||||
|
content: {
|
||||||
|
flex: 1,
|
||||||
|
padding: 32,
|
||||||
|
gap: 16,
|
||||||
|
overflow: 'hidden',
|
||||||
|
},
|
||||||
|
});
|
||||||
60
mobile/components/themed-text.tsx
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import { StyleSheet, Text, type TextProps } from 'react-native';
|
||||||
|
|
||||||
|
import { useThemeColor } from '@/hooks/use-theme-color';
|
||||||
|
|
||||||
|
export type ThemedTextProps = TextProps & {
|
||||||
|
lightColor?: string;
|
||||||
|
darkColor?: string;
|
||||||
|
type?: 'default' | 'title' | 'defaultSemiBold' | 'subtitle' | 'link';
|
||||||
|
};
|
||||||
|
|
||||||
|
export function ThemedText({
|
||||||
|
style,
|
||||||
|
lightColor,
|
||||||
|
darkColor,
|
||||||
|
type = 'default',
|
||||||
|
...rest
|
||||||
|
}: ThemedTextProps) {
|
||||||
|
const color = useThemeColor({ light: lightColor, dark: darkColor }, 'text');
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
{ color },
|
||||||
|
type === 'default' ? styles.default : undefined,
|
||||||
|
type === 'title' ? styles.title : undefined,
|
||||||
|
type === 'defaultSemiBold' ? styles.defaultSemiBold : undefined,
|
||||||
|
type === 'subtitle' ? styles.subtitle : undefined,
|
||||||
|
type === 'link' ? styles.link : undefined,
|
||||||
|
style,
|
||||||
|
]}
|
||||||
|
{...rest}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
default: {
|
||||||
|
fontSize: 16,
|
||||||
|
lineHeight: 24,
|
||||||
|
},
|
||||||
|
defaultSemiBold: {
|
||||||
|
fontSize: 16,
|
||||||
|
lineHeight: 24,
|
||||||
|
fontWeight: '600',
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
fontSize: 32,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
lineHeight: 32,
|
||||||
|
},
|
||||||
|
subtitle: {
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
},
|
||||||
|
link: {
|
||||||
|
lineHeight: 30,
|
||||||
|
fontSize: 16,
|
||||||
|
color: '#0a7ea4',
|
||||||
|
},
|
||||||
|
});
|
||||||
14
mobile/components/themed-view.tsx
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import { View, type ViewProps } from 'react-native';
|
||||||
|
|
||||||
|
import { useThemeColor } from '@/hooks/use-theme-color';
|
||||||
|
|
||||||
|
export type ThemedViewProps = ViewProps & {
|
||||||
|
lightColor?: string;
|
||||||
|
darkColor?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function ThemedView({ style, lightColor, darkColor, ...otherProps }: ThemedViewProps) {
|
||||||
|
const backgroundColor = useThemeColor({ light: lightColor, dark: darkColor }, 'background');
|
||||||
|
|
||||||
|
return <View style={[{ backgroundColor }, style]} {...otherProps} />;
|
||||||
|
}
|
||||||
45
mobile/components/ui/collapsible.tsx
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import { PropsWithChildren, useState } from 'react';
|
||||||
|
import { StyleSheet, TouchableOpacity } from 'react-native';
|
||||||
|
|
||||||
|
import { ThemedText } from '@/components/themed-text';
|
||||||
|
import { ThemedView } from '@/components/themed-view';
|
||||||
|
import { IconSymbol } from '@/components/ui/icon-symbol';
|
||||||
|
import { Colors } from '@/constants/theme';
|
||||||
|
import { useColorScheme } from '@/hooks/use-color-scheme';
|
||||||
|
|
||||||
|
export function Collapsible({ children, title }: PropsWithChildren & { title: string }) {
|
||||||
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
|
const theme = useColorScheme() ?? 'light';
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ThemedView>
|
||||||
|
<TouchableOpacity
|
||||||
|
style={styles.heading}
|
||||||
|
onPress={() => setIsOpen((value) => !value)}
|
||||||
|
activeOpacity={0.8}>
|
||||||
|
<IconSymbol
|
||||||
|
name="chevron.right"
|
||||||
|
size={18}
|
||||||
|
weight="medium"
|
||||||
|
color={theme === 'light' ? Colors.light.icon : Colors.dark.icon}
|
||||||
|
style={{ transform: [{ rotate: isOpen ? '90deg' : '0deg' }] }}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ThemedText type="defaultSemiBold">{title}</ThemedText>
|
||||||
|
</TouchableOpacity>
|
||||||
|
{isOpen && <ThemedView style={styles.content}>{children}</ThemedView>}
|
||||||
|
</ThemedView>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
heading: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: 6,
|
||||||
|
},
|
||||||
|
content: {
|
||||||
|
marginTop: 6,
|
||||||
|
marginLeft: 24,
|
||||||
|
},
|
||||||
|
});
|
||||||
32
mobile/components/ui/icon-symbol.ios.tsx
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import { SymbolView, SymbolViewProps, SymbolWeight } from 'expo-symbols';
|
||||||
|
import { StyleProp, ViewStyle } from 'react-native';
|
||||||
|
|
||||||
|
export function IconSymbol({
|
||||||
|
name,
|
||||||
|
size = 24,
|
||||||
|
color,
|
||||||
|
style,
|
||||||
|
weight = 'regular',
|
||||||
|
}: {
|
||||||
|
name: SymbolViewProps['name'];
|
||||||
|
size?: number;
|
||||||
|
color: string;
|
||||||
|
style?: StyleProp<ViewStyle>;
|
||||||
|
weight?: SymbolWeight;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<SymbolView
|
||||||
|
weight={weight}
|
||||||
|
tintColor={color}
|
||||||
|
resizeMode="scaleAspectFit"
|
||||||
|
name={name}
|
||||||
|
style={[
|
||||||
|
{
|
||||||
|
width: size,
|
||||||
|
height: size,
|
||||||
|
},
|
||||||
|
style,
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
41
mobile/components/ui/icon-symbol.tsx
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
// Fallback for using MaterialIcons on Android and web.
|
||||||
|
|
||||||
|
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
|
||||||
|
import { SymbolWeight, SymbolViewProps } from 'expo-symbols';
|
||||||
|
import { ComponentProps } from 'react';
|
||||||
|
import { OpaqueColorValue, type StyleProp, type TextStyle } from 'react-native';
|
||||||
|
|
||||||
|
type IconMapping = Record<SymbolViewProps['name'], ComponentProps<typeof MaterialIcons>['name']>;
|
||||||
|
type IconSymbolName = keyof typeof MAPPING;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add your SF Symbols to Material Icons mappings here.
|
||||||
|
* - see Material Icons in the [Icons Directory](https://icons.expo.fyi).
|
||||||
|
* - see SF Symbols in the [SF Symbols](https://developer.apple.com/sf-symbols/) app.
|
||||||
|
*/
|
||||||
|
const MAPPING = {
|
||||||
|
'house.fill': 'home',
|
||||||
|
'paperplane.fill': 'send',
|
||||||
|
'chevron.left.forwardslash.chevron.right': 'code',
|
||||||
|
'chevron.right': 'chevron-right',
|
||||||
|
} as IconMapping;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An icon component that uses native SF Symbols on iOS, and Material Icons on Android and web.
|
||||||
|
* This ensures a consistent look across platforms, and optimal resource usage.
|
||||||
|
* Icon `name`s are based on SF Symbols and require manual mapping to Material Icons.
|
||||||
|
*/
|
||||||
|
export function IconSymbol({
|
||||||
|
name,
|
||||||
|
size = 24,
|
||||||
|
color,
|
||||||
|
style,
|
||||||
|
}: {
|
||||||
|
name: IconSymbolName;
|
||||||
|
size?: number;
|
||||||
|
color: string | OpaqueColorValue;
|
||||||
|
style?: StyleProp<TextStyle>;
|
||||||
|
weight?: SymbolWeight;
|
||||||
|
}) {
|
||||||
|
return <MaterialIcons color={color} size={size} name={MAPPING[name]} style={style} />;
|
||||||
|
}
|
||||||
53
mobile/constants/theme.ts
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
* Below are the colors that are used in the app. The colors are defined in the light and dark mode.
|
||||||
|
* There are many other ways to style your app. For example, [Nativewind](https://www.nativewind.dev/), [Tamagui](https://tamagui.dev/), [unistyles](https://reactnativeunistyles.vercel.app), etc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Platform } from 'react-native';
|
||||||
|
|
||||||
|
const tintColorLight = '#69c350';
|
||||||
|
const tintColorDark = '#69c350';
|
||||||
|
|
||||||
|
export const Colors = {
|
||||||
|
light: {
|
||||||
|
text: '#11181C',
|
||||||
|
background: '#fff',
|
||||||
|
tint: tintColorLight,
|
||||||
|
icon: '#687076',
|
||||||
|
tabIconDefault: '#687076',
|
||||||
|
tabIconSelected: tintColorLight,
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
text: '#ECEDEE',
|
||||||
|
background: '#151718',
|
||||||
|
tint: tintColorDark,
|
||||||
|
icon: '#9BA1A6',
|
||||||
|
tabIconDefault: '#9BA1A6',
|
||||||
|
tabIconSelected: tintColorDark,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Fonts = Platform.select({
|
||||||
|
ios: {
|
||||||
|
/** iOS `UIFontDescriptorSystemDesignDefault` */
|
||||||
|
sans: 'system-ui',
|
||||||
|
/** iOS `UIFontDescriptorSystemDesignSerif` */
|
||||||
|
serif: 'ui-serif',
|
||||||
|
/** iOS `UIFontDescriptorSystemDesignRounded` */
|
||||||
|
rounded: 'ui-rounded',
|
||||||
|
/** iOS `UIFontDescriptorSystemDesignMonospaced` */
|
||||||
|
mono: 'ui-monospace',
|
||||||
|
},
|
||||||
|
default: {
|
||||||
|
sans: 'normal',
|
||||||
|
serif: 'serif',
|
||||||
|
rounded: 'normal',
|
||||||
|
mono: 'monospace',
|
||||||
|
},
|
||||||
|
web: {
|
||||||
|
sans: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",
|
||||||
|
serif: "Georgia, 'Times New Roman', serif",
|
||||||
|
rounded: "'SF Pro Rounded', 'Hiragino Maru Gothic ProN', Meiryo, 'MS PGothic', sans-serif",
|
||||||
|
mono: "SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace",
|
||||||
|
},
|
||||||
|
});
|
||||||
10
mobile/eslint.config.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
// https://docs.expo.dev/guides/using-eslint/
|
||||||
|
const { defineConfig } = require('eslint/config');
|
||||||
|
const expoConfig = require('eslint-config-expo/flat');
|
||||||
|
|
||||||
|
module.exports = defineConfig([
|
||||||
|
expoConfig,
|
||||||
|
{
|
||||||
|
ignores: ['dist/*'],
|
||||||
|
},
|
||||||
|
]);
|
||||||
1
mobile/hooks/use-color-scheme.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { useColorScheme } from 'react-native';
|
||||||
21
mobile/hooks/use-color-scheme.web.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { useColorScheme as useRNColorScheme } from 'react-native';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To support static rendering, this value needs to be re-calculated on the client side for web
|
||||||
|
*/
|
||||||
|
export function useColorScheme() {
|
||||||
|
const [hasHydrated, setHasHydrated] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setHasHydrated(true);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const colorScheme = useRNColorScheme();
|
||||||
|
|
||||||
|
if (hasHydrated) {
|
||||||
|
return colorScheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'light';
|
||||||
|
}
|
||||||
21
mobile/hooks/use-theme-color.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/**
|
||||||
|
* Learn more about light and dark modes:
|
||||||
|
* https://docs.expo.dev/guides/color-schemes/
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Colors } from '@/constants/theme';
|
||||||
|
import { useColorScheme } from '@/hooks/use-color-scheme';
|
||||||
|
|
||||||
|
export function useThemeColor(
|
||||||
|
props: { light?: string; dark?: string },
|
||||||
|
colorName: keyof typeof Colors.light & keyof typeof Colors.dark
|
||||||
|
) {
|
||||||
|
const theme = useColorScheme() ?? 'light';
|
||||||
|
const colorFromProps = props[theme];
|
||||||
|
|
||||||
|
if (colorFromProps) {
|
||||||
|
return colorFromProps;
|
||||||
|
} else {
|
||||||
|
return Colors[theme][colorName];
|
||||||
|
}
|
||||||
|
}
|
||||||
12879
mobile/package-lock.json
generated
Normal file
48
mobile/package.json
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
"name": "mobile",
|
||||||
|
"main": "expo-router/entry",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"scripts": {
|
||||||
|
"start": "expo start",
|
||||||
|
"reset-project": "node ./scripts/reset-project.js",
|
||||||
|
"android": "expo start --android",
|
||||||
|
"ios": "expo start --ios",
|
||||||
|
"web": "expo start --web",
|
||||||
|
"lint": "expo lint"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@expo/vector-icons": "^15.0.3",
|
||||||
|
"@react-navigation/bottom-tabs": "^7.4.0",
|
||||||
|
"@react-navigation/elements": "^2.6.3",
|
||||||
|
"@react-navigation/native": "^7.1.8",
|
||||||
|
"expo": "~54.0.33",
|
||||||
|
"expo-constants": "~18.0.13",
|
||||||
|
"expo-font": "~14.0.11",
|
||||||
|
"expo-haptics": "~15.0.8",
|
||||||
|
"expo-image": "~3.0.11",
|
||||||
|
"expo-linking": "~8.0.11",
|
||||||
|
"expo-router": "~6.0.23",
|
||||||
|
"expo-secure-store": "^15.0.8",
|
||||||
|
"expo-splash-screen": "~31.0.13",
|
||||||
|
"expo-status-bar": "~3.0.9",
|
||||||
|
"expo-symbols": "~1.0.8",
|
||||||
|
"expo-system-ui": "~6.0.9",
|
||||||
|
"expo-web-browser": "~15.0.10",
|
||||||
|
"react": "19.1.0",
|
||||||
|
"react-dom": "19.1.0",
|
||||||
|
"react-native": "0.81.5",
|
||||||
|
"react-native-gesture-handler": "~2.28.0",
|
||||||
|
"react-native-reanimated": "~4.1.1",
|
||||||
|
"react-native-safe-area-context": "~5.6.0",
|
||||||
|
"react-native-screens": "~4.16.0",
|
||||||
|
"react-native-web": "~0.21.0",
|
||||||
|
"react-native-worklets": "0.5.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/react": "~19.1.0",
|
||||||
|
"eslint": "^9.25.0",
|
||||||
|
"eslint-config-expo": "~10.0.0",
|
||||||
|
"typescript": "~5.9.2"
|
||||||
|
},
|
||||||
|
"private": true
|
||||||
|
}
|
||||||
112
mobile/scripts/reset-project.js
Executable file
@@ -0,0 +1,112 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This script is used to reset the project to a blank state.
|
||||||
|
* It deletes or moves the /app, /components, /hooks, /scripts, and /constants directories to /app-example based on user input and creates a new /app directory with an index.tsx and _layout.tsx file.
|
||||||
|
* You can remove the `reset-project` script from package.json and safely delete this file after running it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
const readline = require("readline");
|
||||||
|
|
||||||
|
const root = process.cwd();
|
||||||
|
const oldDirs = ["app", "components", "hooks", "constants", "scripts"];
|
||||||
|
const exampleDir = "app-example";
|
||||||
|
const newAppDir = "app";
|
||||||
|
const exampleDirPath = path.join(root, exampleDir);
|
||||||
|
|
||||||
|
const indexContent = `import { Text, View } from "react-native";
|
||||||
|
|
||||||
|
export default function Index() {
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
flex: 1,
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text>Edit app/index.tsx to edit this screen.</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const layoutContent = `import { Stack } from "expo-router";
|
||||||
|
|
||||||
|
export default function RootLayout() {
|
||||||
|
return <Stack />;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const rl = readline.createInterface({
|
||||||
|
input: process.stdin,
|
||||||
|
output: process.stdout,
|
||||||
|
});
|
||||||
|
|
||||||
|
const moveDirectories = async (userInput) => {
|
||||||
|
try {
|
||||||
|
if (userInput === "y") {
|
||||||
|
// Create the app-example directory
|
||||||
|
await fs.promises.mkdir(exampleDirPath, { recursive: true });
|
||||||
|
console.log(`📁 /${exampleDir} directory created.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move old directories to new app-example directory or delete them
|
||||||
|
for (const dir of oldDirs) {
|
||||||
|
const oldDirPath = path.join(root, dir);
|
||||||
|
if (fs.existsSync(oldDirPath)) {
|
||||||
|
if (userInput === "y") {
|
||||||
|
const newDirPath = path.join(root, exampleDir, dir);
|
||||||
|
await fs.promises.rename(oldDirPath, newDirPath);
|
||||||
|
console.log(`➡️ /${dir} moved to /${exampleDir}/${dir}.`);
|
||||||
|
} else {
|
||||||
|
await fs.promises.rm(oldDirPath, { recursive: true, force: true });
|
||||||
|
console.log(`❌ /${dir} deleted.`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log(`➡️ /${dir} does not exist, skipping.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create new /app directory
|
||||||
|
const newAppDirPath = path.join(root, newAppDir);
|
||||||
|
await fs.promises.mkdir(newAppDirPath, { recursive: true });
|
||||||
|
console.log("\n📁 New /app directory created.");
|
||||||
|
|
||||||
|
// Create index.tsx
|
||||||
|
const indexPath = path.join(newAppDirPath, "index.tsx");
|
||||||
|
await fs.promises.writeFile(indexPath, indexContent);
|
||||||
|
console.log("📄 app/index.tsx created.");
|
||||||
|
|
||||||
|
// Create _layout.tsx
|
||||||
|
const layoutPath = path.join(newAppDirPath, "_layout.tsx");
|
||||||
|
await fs.promises.writeFile(layoutPath, layoutContent);
|
||||||
|
console.log("📄 app/_layout.tsx created.");
|
||||||
|
|
||||||
|
console.log("\n✅ Project reset complete. Next steps:");
|
||||||
|
console.log(
|
||||||
|
`1. Run \`npx expo start\` to start a development server.\n2. Edit app/index.tsx to edit the main screen.${
|
||||||
|
userInput === "y"
|
||||||
|
? `\n3. Delete the /${exampleDir} directory when you're done referencing it.`
|
||||||
|
: ""
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`❌ Error during script execution: ${error.message}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
rl.question(
|
||||||
|
"Do you want to move existing files to /app-example instead of deleting them? (Y/n): ",
|
||||||
|
(answer) => {
|
||||||
|
const userInput = answer.trim().toLowerCase() || "y";
|
||||||
|
if (userInput === "y" || userInput === "n") {
|
||||||
|
moveDirectories(userInput).finally(() => rl.close());
|
||||||
|
} else {
|
||||||
|
console.log("❌ Invalid input. Please enter 'Y' or 'N'.");
|
||||||
|
rl.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
2
mobile/src/config/env.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export const API_BASE_URL =
|
||||||
|
process.env.EXPO_PUBLIC_API_BASE?.replace(/\/$/, '') || 'http://localhost:3100';
|
||||||
260
mobile/src/lib/api.ts
Normal file
@@ -0,0 +1,260 @@
|
|||||||
|
import { API_BASE_URL } from '@/src/config/env';
|
||||||
|
|
||||||
|
export type Tenant = {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
short?: string | null;
|
||||||
|
[key: string]: unknown;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TaskStatus = 'Offen' | 'In Bearbeitung' | 'Abgeschlossen';
|
||||||
|
|
||||||
|
export type Task = {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
description?: string | null;
|
||||||
|
categorie?: string | null;
|
||||||
|
userId?: string | null;
|
||||||
|
user_id?: string | null;
|
||||||
|
profile?: string | null;
|
||||||
|
archived?: boolean;
|
||||||
|
[key: string]: unknown;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TenantProfile = {
|
||||||
|
id?: number | string;
|
||||||
|
user_id?: string;
|
||||||
|
full_name?: string;
|
||||||
|
fullName?: string;
|
||||||
|
email?: string;
|
||||||
|
[key: string]: unknown;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type StaffTimeSpan = {
|
||||||
|
id: string | null;
|
||||||
|
eventIds: string[];
|
||||||
|
state: string;
|
||||||
|
started_at: string;
|
||||||
|
stopped_at: string | null;
|
||||||
|
duration_minutes: number;
|
||||||
|
user_id: string | null;
|
||||||
|
type: string;
|
||||||
|
description: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type MeResponse = {
|
||||||
|
user: {
|
||||||
|
id: string;
|
||||||
|
email: string;
|
||||||
|
must_change_password?: boolean;
|
||||||
|
[key: string]: unknown;
|
||||||
|
};
|
||||||
|
tenants: Tenant[];
|
||||||
|
activeTenant: number | string | null;
|
||||||
|
profile: Record<string, unknown> | null;
|
||||||
|
permissions: string[];
|
||||||
|
};
|
||||||
|
|
||||||
|
type RequestOptions = {
|
||||||
|
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
||||||
|
token?: string | null;
|
||||||
|
body?: unknown;
|
||||||
|
};
|
||||||
|
|
||||||
|
function buildUrl(path: string): string {
|
||||||
|
if (path.startsWith('http://') || path.startsWith('https://')) {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
const normalizedPath = path.startsWith('/') ? path : `/${path}`;
|
||||||
|
return `${API_BASE_URL}${normalizedPath}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function parseJson(response: Response): Promise<unknown> {
|
||||||
|
const text = await response.text();
|
||||||
|
if (!text) return null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
return JSON.parse(text);
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiRequest<T>(path: string, options: RequestOptions = {}): Promise<T> {
|
||||||
|
const response = await fetch(buildUrl(path), {
|
||||||
|
method: options.method || 'GET',
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/json',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
...(options.token ? { Authorization: `Bearer ${options.token}` } : {}),
|
||||||
|
},
|
||||||
|
body: options.body ? JSON.stringify(options.body) : undefined,
|
||||||
|
});
|
||||||
|
|
||||||
|
const payload = await parseJson(response);
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const message =
|
||||||
|
(payload as { message?: string; error?: string } | null)?.message ||
|
||||||
|
(payload as { message?: string; error?: string } | null)?.error ||
|
||||||
|
`Request failed (${response.status}) for ${path}`;
|
||||||
|
throw new Error(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return payload as T;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function checkBackendHealth(): Promise<{ status: string; [key: string]: unknown }> {
|
||||||
|
return apiRequest<{ status: string; [key: string]: unknown }>('/health');
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function loginWithEmailPassword(email: string, password: string): Promise<string> {
|
||||||
|
const payload = await apiRequest<{ token?: string }>('/auth/login', {
|
||||||
|
method: 'POST',
|
||||||
|
body: { email, password },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!payload?.token) {
|
||||||
|
throw new Error('Login did not return a token.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return payload.token;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchMe(token: string): Promise<MeResponse> {
|
||||||
|
return apiRequest<MeResponse>('/api/me', {
|
||||||
|
token,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function switchTenantRequest(tenantId: number, token: string): Promise<string> {
|
||||||
|
const payload = await apiRequest<{ token?: string }>('/api/tenant/switch', {
|
||||||
|
method: 'POST',
|
||||||
|
token,
|
||||||
|
body: { tenant_id: String(tenantId) },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!payload?.token) {
|
||||||
|
throw new Error('Tenant switch did not return a token.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return payload.token;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchTasks(token: string): Promise<Task[]> {
|
||||||
|
const tasks = await apiRequest<Task[]>('/api/resource/tasks', { token });
|
||||||
|
return (tasks || []).filter((task) => !task.archived);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createTask(
|
||||||
|
token: string,
|
||||||
|
payload: {
|
||||||
|
name: string;
|
||||||
|
description?: string | null;
|
||||||
|
categorie?: TaskStatus;
|
||||||
|
userId?: string | null;
|
||||||
|
}
|
||||||
|
): Promise<Task> {
|
||||||
|
return apiRequest<Task>('/api/resource/tasks', {
|
||||||
|
method: 'POST',
|
||||||
|
token,
|
||||||
|
body: payload,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateTask(token: string, taskId: number, payload: Partial<Task>): Promise<Task> {
|
||||||
|
return apiRequest<Task>(`/api/resource/tasks/${taskId}`, {
|
||||||
|
method: 'PUT',
|
||||||
|
token,
|
||||||
|
body: payload,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchTenantProfiles(token: string): Promise<TenantProfile[]> {
|
||||||
|
const response = await apiRequest<{ data?: TenantProfile[] }>('/api/tenant/profiles', { token });
|
||||||
|
return response?.data || [];
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchStaffTimeSpans(
|
||||||
|
token: string,
|
||||||
|
targetUserId?: string
|
||||||
|
): Promise<StaffTimeSpan[]> {
|
||||||
|
const query = targetUserId ? `?targetUserId=${encodeURIComponent(targetUserId)}` : '';
|
||||||
|
const spans = await apiRequest<any[]>(`/api/staff/time/spans${query}`, { token });
|
||||||
|
|
||||||
|
return (spans || [])
|
||||||
|
.map((span) => {
|
||||||
|
const started = span.startedAt ? new Date(span.startedAt) : null;
|
||||||
|
const ended = span.endedAt ? new Date(span.endedAt) : new Date();
|
||||||
|
const durationMinutes =
|
||||||
|
started && ended ? Math.max(0, Math.floor((ended.getTime() - started.getTime()) / 60000)) : 0;
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: span.sourceEventIds?.[0] ?? null,
|
||||||
|
eventIds: span.sourceEventIds || [],
|
||||||
|
state: span.status || 'draft',
|
||||||
|
started_at: span.startedAt,
|
||||||
|
stopped_at: span.endedAt || null,
|
||||||
|
duration_minutes: durationMinutes,
|
||||||
|
user_id: targetUserId || null,
|
||||||
|
type: span.type || 'work',
|
||||||
|
description: span.payload?.description || '',
|
||||||
|
} as StaffTimeSpan;
|
||||||
|
})
|
||||||
|
.sort((a, b) => new Date(b.started_at).getTime() - new Date(a.started_at).getTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createStaffTimeEvent(
|
||||||
|
token: string,
|
||||||
|
payload: {
|
||||||
|
eventtype: string;
|
||||||
|
eventtime: string;
|
||||||
|
user_id: string;
|
||||||
|
description?: string;
|
||||||
|
}
|
||||||
|
): Promise<void> {
|
||||||
|
await apiRequest('/api/staff/time/event', {
|
||||||
|
method: 'POST',
|
||||||
|
token,
|
||||||
|
body: {
|
||||||
|
eventtype: payload.eventtype,
|
||||||
|
eventtime: payload.eventtime,
|
||||||
|
user_id: payload.user_id,
|
||||||
|
payload: payload.description ? { description: payload.description } : undefined,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function submitStaffTime(token: string, eventIds: string[]): Promise<void> {
|
||||||
|
await apiRequest('/api/staff/time/submit', {
|
||||||
|
method: 'POST',
|
||||||
|
token,
|
||||||
|
body: { eventIds },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function approveStaffTime(
|
||||||
|
token: string,
|
||||||
|
eventIds: string[],
|
||||||
|
employeeUserId: string
|
||||||
|
): Promise<void> {
|
||||||
|
await apiRequest('/api/staff/time/approve', {
|
||||||
|
method: 'POST',
|
||||||
|
token,
|
||||||
|
body: { eventIds, employeeUserId },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function rejectStaffTime(
|
||||||
|
token: string,
|
||||||
|
eventIds: string[],
|
||||||
|
employeeUserId: string,
|
||||||
|
reason: string
|
||||||
|
): Promise<void> {
|
||||||
|
await apiRequest('/api/staff/time/reject', {
|
||||||
|
method: 'POST',
|
||||||
|
token,
|
||||||
|
body: { eventIds, employeeUserId, reason },
|
||||||
|
});
|
||||||
|
}
|
||||||
44
mobile/src/lib/token-storage.ts
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import * as SecureStore from 'expo-secure-store';
|
||||||
|
|
||||||
|
const TOKEN_KEY = 'fedeo.mobile.auth.token';
|
||||||
|
|
||||||
|
let memoryToken: string | null = null;
|
||||||
|
|
||||||
|
async function hasSecureStore(): Promise<boolean> {
|
||||||
|
try {
|
||||||
|
return await SecureStore.isAvailableAsync();
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getStoredToken(): Promise<string | null> {
|
||||||
|
if (await hasSecureStore()) {
|
||||||
|
const token = await SecureStore.getItemAsync(TOKEN_KEY);
|
||||||
|
memoryToken = token;
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
return memoryToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function setStoredToken(token: string): Promise<void> {
|
||||||
|
memoryToken = token;
|
||||||
|
|
||||||
|
if (await hasSecureStore()) {
|
||||||
|
await SecureStore.setItemAsync(TOKEN_KEY, token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function clearStoredToken(): Promise<void> {
|
||||||
|
memoryToken = null;
|
||||||
|
|
||||||
|
if (await hasSecureStore()) {
|
||||||
|
await SecureStore.deleteItemAsync(TOKEN_KEY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const tokenStorageInfo = {
|
||||||
|
mode: 'secure-store',
|
||||||
|
key: TOKEN_KEY,
|
||||||
|
} as const;
|
||||||
186
mobile/src/providers/auth-provider.tsx
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
||||||
|
|
||||||
|
import { fetchMe, loginWithEmailPassword, MeResponse, switchTenantRequest, Tenant } from '@/src/lib/api';
|
||||||
|
import { clearStoredToken, getStoredToken, setStoredToken, tokenStorageInfo } from '@/src/lib/token-storage';
|
||||||
|
|
||||||
|
export type AuthUser = MeResponse['user'];
|
||||||
|
|
||||||
|
type AuthContextValue = {
|
||||||
|
isBootstrapping: boolean;
|
||||||
|
token: string | null;
|
||||||
|
user: AuthUser | null;
|
||||||
|
tenants: Tenant[];
|
||||||
|
activeTenantId: number | null;
|
||||||
|
activeTenant: Tenant | null;
|
||||||
|
profile: Record<string, unknown> | null;
|
||||||
|
permissions: string[];
|
||||||
|
requiresTenantSelection: boolean;
|
||||||
|
login: (email: string, password: string) => Promise<void>;
|
||||||
|
logout: () => Promise<void>;
|
||||||
|
refreshUser: () => Promise<void>;
|
||||||
|
switchTenant: (tenantId: number) => Promise<void>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const AuthContext = createContext<AuthContextValue | undefined>(undefined);
|
||||||
|
|
||||||
|
function normalizeTenantId(value: number | string | null | undefined): number | null {
|
||||||
|
if (value === null || value === undefined || value === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const parsed = Number(value);
|
||||||
|
return Number.isNaN(parsed) ? null : parsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||||
|
const [isBootstrapping, setIsBootstrapping] = useState(true);
|
||||||
|
const [token, setToken] = useState<string | null>(null);
|
||||||
|
const [user, setUser] = useState<AuthUser | null>(null);
|
||||||
|
const [tenants, setTenants] = useState<Tenant[]>([]);
|
||||||
|
const [activeTenantId, setActiveTenantId] = useState<number | null>(null);
|
||||||
|
const [profile, setProfile] = useState<Record<string, unknown> | null>(null);
|
||||||
|
const [permissions, setPermissions] = useState<string[]>([]);
|
||||||
|
|
||||||
|
const resetSession = useCallback(() => {
|
||||||
|
setUser(null);
|
||||||
|
setTenants([]);
|
||||||
|
setActiveTenantId(null);
|
||||||
|
setProfile(null);
|
||||||
|
setPermissions([]);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const hydrateSession = useCallback(
|
||||||
|
async (tokenToUse: string) => {
|
||||||
|
const me = await fetchMe(tokenToUse);
|
||||||
|
setUser(me.user);
|
||||||
|
setTenants(me.tenants || []);
|
||||||
|
setActiveTenantId(normalizeTenantId(me.activeTenant));
|
||||||
|
setProfile(me.profile || null);
|
||||||
|
setPermissions(me.permissions || []);
|
||||||
|
},
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
const logout = useCallback(async () => {
|
||||||
|
await clearStoredToken();
|
||||||
|
setToken(null);
|
||||||
|
resetSession();
|
||||||
|
}, [resetSession]);
|
||||||
|
|
||||||
|
const refreshUser = useCallback(async () => {
|
||||||
|
if (!token) {
|
||||||
|
resetSession();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await hydrateSession(token);
|
||||||
|
} catch {
|
||||||
|
await logout();
|
||||||
|
}
|
||||||
|
}, [hydrateSession, logout, resetSession, token]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
async function bootstrap() {
|
||||||
|
const storedToken = await getStoredToken();
|
||||||
|
|
||||||
|
if (!storedToken) {
|
||||||
|
setIsBootstrapping(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await hydrateSession(storedToken);
|
||||||
|
setToken(storedToken);
|
||||||
|
} catch {
|
||||||
|
await clearStoredToken();
|
||||||
|
setToken(null);
|
||||||
|
resetSession();
|
||||||
|
} finally {
|
||||||
|
setIsBootstrapping(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void bootstrap();
|
||||||
|
}, [hydrateSession, resetSession]);
|
||||||
|
|
||||||
|
const login = useCallback(
|
||||||
|
async (email: string, password: string) => {
|
||||||
|
const nextToken = await loginWithEmailPassword(email, password);
|
||||||
|
await setStoredToken(nextToken);
|
||||||
|
await hydrateSession(nextToken);
|
||||||
|
setToken(nextToken);
|
||||||
|
},
|
||||||
|
[hydrateSession]
|
||||||
|
);
|
||||||
|
|
||||||
|
const switchTenant = useCallback(
|
||||||
|
async (tenantId: number) => {
|
||||||
|
if (!token) {
|
||||||
|
throw new Error('No active session found.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const nextToken = await switchTenantRequest(tenantId, token);
|
||||||
|
await setStoredToken(nextToken);
|
||||||
|
await hydrateSession(nextToken);
|
||||||
|
setToken(nextToken);
|
||||||
|
},
|
||||||
|
[token, hydrateSession]
|
||||||
|
);
|
||||||
|
|
||||||
|
const activeTenant = useMemo(
|
||||||
|
() => tenants.find((tenant) => Number(tenant.id) === activeTenantId) || null,
|
||||||
|
[activeTenantId, tenants]
|
||||||
|
);
|
||||||
|
|
||||||
|
const requiresTenantSelection = Boolean(token) && tenants.length > 0 && !activeTenantId;
|
||||||
|
|
||||||
|
const value = useMemo(
|
||||||
|
() => ({
|
||||||
|
isBootstrapping,
|
||||||
|
token,
|
||||||
|
user,
|
||||||
|
tenants,
|
||||||
|
activeTenantId,
|
||||||
|
activeTenant,
|
||||||
|
profile,
|
||||||
|
permissions,
|
||||||
|
requiresTenantSelection,
|
||||||
|
login,
|
||||||
|
logout,
|
||||||
|
refreshUser,
|
||||||
|
switchTenant,
|
||||||
|
}),
|
||||||
|
[
|
||||||
|
activeTenant,
|
||||||
|
activeTenantId,
|
||||||
|
isBootstrapping,
|
||||||
|
login,
|
||||||
|
logout,
|
||||||
|
permissions,
|
||||||
|
profile,
|
||||||
|
refreshUser,
|
||||||
|
requiresTenantSelection,
|
||||||
|
switchTenant,
|
||||||
|
tenants,
|
||||||
|
token,
|
||||||
|
user,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useAuth(): AuthContextValue {
|
||||||
|
const context = useContext(AuthContext);
|
||||||
|
|
||||||
|
if (!context) {
|
||||||
|
throw new Error('useAuth must be used inside AuthProvider');
|
||||||
|
}
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useTokenStorageInfo() {
|
||||||
|
return tokenStorageInfo;
|
||||||
|
}
|
||||||
17
mobile/tsconfig.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"extends": "expo/tsconfig.base",
|
||||||
|
"compilerOptions": {
|
||||||
|
"strict": true,
|
||||||
|
"paths": {
|
||||||
|
"@/*": [
|
||||||
|
"./*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"**/*.ts",
|
||||||
|
"**/*.tsx",
|
||||||
|
".expo/types/**/*.ts",
|
||||||
|
"expo-env.d.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||