Skip to content

Commit

Permalink
Merge branch 'main' into timetable-ux
Browse files Browse the repository at this point in the history
  • Loading branch information
builder-247 authored Jul 18, 2024
2 parents 5557400 + f8c1de5 commit e7ee481
Show file tree
Hide file tree
Showing 33 changed files with 934 additions and 112 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
EXPO_PUBLIC_ENVIRONMENT=development
EXPO_PUBLIC_API_URL=https://yusf31nx11.execute-api.eu-west-1.amazonaws.com/staging
37 changes: 37 additions & 0 deletions .github/workflows/check-code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Typecheck, lint, format and test

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
lint-typecheck:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: Install dependencies
run: npm install

- name: Typecheck
run: npm run check:types

- name: Lint
run: npm run check:lint

- name: Format
run: npm run check:format

- name: Test
run: npm run check:test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ npm-debug.*
web-build/
.env

# Test stuff
coverage/

# macOS
.DS_Store

Expand Down
8 changes: 8 additions & 0 deletions api/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export class StatusError extends Error {
constructor(
public message: string,
public statusCode: number
) {
super(message);
}
}
79 changes: 79 additions & 0 deletions api/userService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { StatusError } from './errors';

export interface ProfileData {
id: number;
email: string;
phone?: string;
created_at: string;
first_name?: string;
last_name?: string;
status: number;
verified_at?: string;
extra: unknown;
username?: string;
user_level: number;
is_banned: boolean;
profile_preferences: ProfilePreferences;
telia_linked_at?: string;
marketing_box_granted: boolean;
region: string;
opened_lootboxes_count: number;
balance: number;
social_login: boolean;
}

interface ProfilePreferences {
coins: boolean;
realName: boolean;
memberSince: boolean;
shoutTrophy: boolean;
questionTrophy: boolean;
allowShowUsername: boolean;
openedLootboxesCount: boolean;
}

const opts = (token?: string, body?: unknown) => ({
method: 'POST',
headers: token
? { Authorization: 'Bearer ' + token, 'content-type': 'application/json' }
: ({ 'content-type': 'application/json' } as any),
body: body ? JSON.stringify(body) : undefined,
});

export async function fetchProfile(token: string) {
const url = `${process.env.EXPO_PUBLIC_API_URL}/auth/jwt`;

const response = await fetch(url, opts(token));
const data = await response.json();
console.log(data);
return data as ProfileData;
}

export async function signupRequest(email: string, password: string) {
const url = `${process.env.EXPO_PUBLIC_API_URL}/person/signup`;

const response = await fetch(url, opts(undefined, { email, password, region: 'asm' }));
if (!response.ok) {
throw new StatusError('signup-failed', response.status);
}
const data = await response.json();
return {
profile: data as ProfileData,
token: response.headers.get('x-auth-token')!,
};
}

export async function loginRequest(login: string, password: string) {
const url = `${process.env.EXPO_PUBLIC_API_URL}/auth/local?region=asm`;

const response = await fetch(url, opts(undefined, { login, password }));
if (!response.ok) {
throw new StatusError('login-failed', response.status);
}
const data = await response.json();
console.log(data);
return {
profile: data as ProfileData,
token: response.headers.get('x-auth-token')!,
};
}
53 changes: 53 additions & 0 deletions app.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
export default () => {
return {
expo: {
name: 'Assembly',
slug: 'assembly-app',
version: '1.0.0',
orientation: 'portrait',
icon: './assets/images/icon.png',
scheme: 'myapp',
userInterfaceStyle: 'automatic',
splash: {
image: './assets/images/splash.png',
resizeMode: 'contain',
backgroundColor: '#191919',
},
ios: {
supportsTablet: true,
bundleIdentifier:
process.env.EXPO_PUBLIC_ENVIRONMENT === 'production'
? 'com.testausserveri.assemblyapp'
: 'com.testausserveri.assemblyapp-dev',
},
android: {
adaptiveIcon: {
foregroundImage: './assets/images/adaptive-icon.png',
backgroundColor: '#191919',
},
package:
process.env.EXPO_PUBLIC_ENVIRONMENT === 'production'
? 'com.testausserveri.assemblyapp'
: 'com.testausserveri.assemblyapp-dev',
},
web: {
bundler: 'metro',
output: 'static',
favicon: './assets/images/favicon.png',
},
plugins: ['expo-router', 'expo-build-properties'],
experiments: {
typedRoutes: true,
},
extra: {
router: {
origin: false,
},
eas: {
projectId: '469c71b6-54c5-4111-bc4a-03e2cf92a23d',
},
},
owner: 'testausserveri',
},
};
};
44 changes: 0 additions & 44 deletions app.json

This file was deleted.

22 changes: 21 additions & 1 deletion app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,27 @@ export default function TabLayout() {
}}
/>
<Tabs.Screen
name='useless'
name='about'
options={{
tabBarIcon: ({ color, focused }) => (
<TabBarIcon
name={focused ? 'information-circle' : 'information-circle-outline'}
color={color}
/>
),
unmountOnBlur: true,
}}
/>
<Tabs.Screen
name='map'
options={{
tabBarIcon: ({ color, focused }) => (
<TabBarIcon name={focused ? 'map' : 'map-outline'} color={color} />
),
}}
/>
<Tabs.Screen
name='profile'
options={{
tabBarIcon: ({ color, focused }) => (
<TabBarIcon name={focused ? 'person' : 'person-outline'} color={color} />
Expand Down
25 changes: 25 additions & 0 deletions app/(tabs)/about.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import AppBar from '@/elements/AppBar';
import AboutWebview from '@/elements/about/AboutWebview';
import { Surface } from 'react-native-paper';
import { useTheme } from 'react-native-paper';
import { useSafeAreaInsets } from 'react-native-safe-area-context';

function AboutScreen() {
const theme = useTheme();
const insets = useSafeAreaInsets();

return (
<Surface
style={{
height: '100%',
backgroundColor: theme.colors.background,
paddingTop: insets.top,
}}
>
<AppBar title='about' />
<AboutWebview />
</Surface>
);
}

export default AboutScreen;
23 changes: 23 additions & 0 deletions app/(tabs)/map.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import AppBar from '@/elements/AppBar';
import EventMap from '@/elements/map/EventMap';
import { Surface } from 'react-native-paper';
import { useTheme } from 'react-native-paper';
import { useSafeAreaInsets } from 'react-native-safe-area-context';

export default function MapScreen() {
const theme = useTheme();
const insets = useSafeAreaInsets();

return (
<Surface
style={{
height: '100%',
backgroundColor: theme.colors.background,
paddingTop: insets.top,
}}
>
<AppBar title='map' />
<EventMap />
</Surface>
);
}
53 changes: 53 additions & 0 deletions app/(tabs)/profile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import AppBar from '@/elements/AppBar';
import LanguageSelector from '@/elements/LanguageSelector';
import { Link } from 'expo-router';
import { useTranslation } from 'react-i18next';
import { View } from 'react-native';
import { Surface, Text, useTheme } from 'react-native-paper';
import { useSafeAreaInsets } from 'react-native-safe-area-context';

export default function HomeScreen() {
const { t } = useTranslation();
const theme = useTheme();

const insets = useSafeAreaInsets();

return (
<View
style={{
flex: 1,
alignItems: 'center',
gap: 8,
backgroundColor: theme.colors.background,
paddingTop: insets.top,
}}
>
<AppBar title={t('profile')} />
<View
style={{ flex: 1, width: '100%', justifyContent: 'center', alignItems: 'center' }}
>
<LanguageSelector />
<Surface
elevation={0}
style={{ padding: 16, width: '100%', justifyContent: 'center', gap: 16 }}
>
<Text style={{ textAlign: 'center' }} variant='bodyLarge'>
{t('working-on-this')}
</Text>
<Link
style={{
color: theme.colors.primary,
textDecorationLine: 'underline',
textAlign: 'center',
}}
href='/credits'
>
{t('meanwhile')}
</Link>
</Surface>
</View>

{/** <ProfileView /> */}
</View>
);
}
25 changes: 0 additions & 25 deletions app/(tabs)/useless.tsx

This file was deleted.

Loading

0 comments on commit e7ee481

Please sign in to comment.