refactor: app routes handling
This commit is contained in:
parent
ce3b5e7b58
commit
305ad640fa
@ -1,7 +0,0 @@
|
||||
import { Slot } from "expo-router"
|
||||
|
||||
const Layout: React.FC = () => {
|
||||
return <Slot />
|
||||
}
|
||||
|
||||
export default Layout
|
@ -43,9 +43,7 @@ const StackLayout: React.FC = () => {
|
||||
screenOptions={{
|
||||
headerShown: false,
|
||||
}}
|
||||
>
|
||||
<Stack.Screen name="(pages)" />
|
||||
</Stack>
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ const TabLayout: React.FC = () => {
|
||||
const { user } = useAuthentication()
|
||||
|
||||
if (user == null) {
|
||||
return <Redirect href="/(pages)/authentication/login" />
|
||||
return <Redirect href="/authentication/login" />
|
||||
}
|
||||
|
||||
return (
|
@ -8,7 +8,7 @@ const TabLayout: React.FC = () => {
|
||||
const { user } = useAuthentication()
|
||||
|
||||
if (user != null) {
|
||||
return <Redirect href="/(pages)/application/habits" />
|
||||
return <Redirect href="/application/habits/" />
|
||||
}
|
||||
|
||||
return (
|
@ -6,10 +6,10 @@ const HomePage: React.FC = () => {
|
||||
const { user } = useAuthentication()
|
||||
|
||||
if (user == null) {
|
||||
return <Redirect href="/(pages)/authentication/login" />
|
||||
return <Redirect href="/authentication/login" />
|
||||
}
|
||||
|
||||
return <Redirect href="/(pages)/application/habits" />
|
||||
return <Redirect href="/application/habits/" />
|
||||
}
|
||||
|
||||
export default HomePage
|
@ -14,6 +14,9 @@ npm run lint:typescript
|
||||
|
||||
# Test
|
||||
npm run test
|
||||
|
||||
# Test Snapshots Update
|
||||
npm run test -- --u
|
||||
```
|
||||
|
||||
Une pipeline CI ([`.gitlab-ci.yml`](../.gitlab-ci.yml)) est en place pour vérifier que le code respecte ces bonnes pratiques et que les tests passent.
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { AuthenticationUseCase } from "@/domain/use-cases/Authentication"
|
||||
import { RetrieveHabitsTrackerUseCase } from "../domain/use-cases/RetrieveHabitsTracker"
|
||||
import { HabitsTrackerPresenter } from "../presentation/presenters/HabitsTracker"
|
||||
import { AuthenticationSupabaseRepository } from "./repositories/supabase/lib/AuthenticationRepository"
|
||||
import { GetHabitProgressHistorySupabaseRepository } from "./repositories/supabase/lib/GetHabitProgressHistory"
|
||||
import { GetHabitsByUserIdSupabaseRepository } from "./repositories/supabase/lib/GetHabitsByUserId"
|
||||
import { supabaseClient } from "./repositories/supabase/supabase"
|
||||
import { AuthenticationSupabaseRepository } from "./supabase/repositories/Authentication"
|
||||
import { GetHabitProgressHistorySupabaseRepository } from "./supabase/repositories/GetHabitProgressHistory"
|
||||
import { GetHabitsByUserIdSupabaseRepository } from "./supabase/repositories/GetHabitsByUserId"
|
||||
import { supabaseClient } from "./supabase/supabase"
|
||||
import { AuthenticationPresenter } from "@/presentation/presenters/Authentication"
|
||||
|
||||
/**
|
@ -15,7 +15,7 @@
|
||||
"lint:typescript": "tsc --noEmit",
|
||||
"lint:staged": "lint-staged",
|
||||
"test": "jest --reporters=default --reporters=jest-junit",
|
||||
"supabase": "supabase --workdir \"./infrastructure/repositories\"",
|
||||
"supabase": "supabase --workdir \"./infrastructure\"",
|
||||
"postinstall": "husky"
|
||||
},
|
||||
"dependencies": {
|
||||
|
@ -1,34 +0,0 @@
|
||||
import type { StyleProp, ViewStyle } from "react-native"
|
||||
import { Pressable, StyleSheet, Text } from "react-native"
|
||||
|
||||
export interface ButtonCustomProps
|
||||
extends React.ComponentProps<typeof Pressable> {
|
||||
children: React.ReactNode
|
||||
style?: StyleProp<ViewStyle>
|
||||
}
|
||||
|
||||
export const ButtonCustom: React.FC<ButtonCustomProps> = (props) => {
|
||||
const { children, style, ...rest } = props
|
||||
|
||||
return (
|
||||
<Pressable style={[styles.button, style]} {...rest}>
|
||||
<Text style={styles.text}>{children}</Text>
|
||||
</Pressable>
|
||||
)
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
button: {
|
||||
padding: 10,
|
||||
borderWidth: 1,
|
||||
borderColor: "black",
|
||||
borderRadius: 10,
|
||||
marginTop: 10,
|
||||
backgroundColor: "#152B5D",
|
||||
},
|
||||
text: {
|
||||
color: "white",
|
||||
textAlign: "center",
|
||||
fontSize: 15,
|
||||
},
|
||||
})
|
@ -1,13 +0,0 @@
|
||||
import { StyleSheet, Text } from "react-native"
|
||||
|
||||
export const MonoText: React.FC<Text["props"]> = (props) => {
|
||||
const { style, ...rest } = props
|
||||
|
||||
return <Text style={[style, styles.text]} {...rest} />
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
text: {
|
||||
fontFamily: "SpaceMono",
|
||||
},
|
||||
})
|
@ -1,12 +0,0 @@
|
||||
import renderer from "react-test-renderer"
|
||||
|
||||
import { ButtonCustom } from "@/presentation/react/components/ButtonCustom"
|
||||
|
||||
describe("<ButtonCustom />", () => {
|
||||
it("renders correctly", () => {
|
||||
const tree = renderer
|
||||
.create(<ButtonCustom>Awesome Button!</ButtonCustom>)
|
||||
.toJSON()
|
||||
expect(tree).toMatchSnapshot()
|
||||
})
|
||||
})
|
@ -1,10 +0,0 @@
|
||||
import renderer from "react-test-renderer"
|
||||
|
||||
import { MonoText } from "@/presentation/react/components/MonoText"
|
||||
|
||||
describe("<MonoText />", () => {
|
||||
it("renders correctly", () => {
|
||||
const tree = renderer.create(<MonoText>Awesome text!</MonoText>).toJSON()
|
||||
expect(tree).toMatchSnapshot()
|
||||
})
|
||||
})
|
12
presentation/react/components/__tests__/TabBarIcon.test.tsx
Normal file
12
presentation/react/components/__tests__/TabBarIcon.test.tsx
Normal file
@ -0,0 +1,12 @@
|
||||
import renderer from "react-test-renderer"
|
||||
|
||||
import { TabBarIcon } from "@/presentation/react/components/TabBarIcon"
|
||||
|
||||
describe("<TabBarIcon />", () => {
|
||||
it("renders correctly", () => {
|
||||
const tree = renderer
|
||||
.create(<TabBarIcon name="info" color="black" />)
|
||||
.toJSON()
|
||||
expect(tree).toMatchSnapshot()
|
||||
})
|
||||
})
|
@ -1,60 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<ButtonCustom /> renders correctly 1`] = `
|
||||
<View
|
||||
accessibilityState={
|
||||
{
|
||||
"busy": undefined,
|
||||
"checked": undefined,
|
||||
"disabled": undefined,
|
||||
"expanded": undefined,
|
||||
"selected": undefined,
|
||||
}
|
||||
}
|
||||
accessibilityValue={
|
||||
{
|
||||
"max": undefined,
|
||||
"min": undefined,
|
||||
"now": undefined,
|
||||
"text": undefined,
|
||||
}
|
||||
}
|
||||
accessible={true}
|
||||
collapsable={false}
|
||||
focusable={true}
|
||||
onBlur={[Function]}
|
||||
onClick={[Function]}
|
||||
onFocus={[Function]}
|
||||
onResponderGrant={[Function]}
|
||||
onResponderMove={[Function]}
|
||||
onResponderRelease={[Function]}
|
||||
onResponderTerminate={[Function]}
|
||||
onResponderTerminationRequest={[Function]}
|
||||
onStartShouldSetResponder={[Function]}
|
||||
style={
|
||||
[
|
||||
{
|
||||
"backgroundColor": "#152B5D",
|
||||
"borderColor": "black",
|
||||
"borderRadius": 10,
|
||||
"borderWidth": 1,
|
||||
"marginTop": 10,
|
||||
"padding": 10,
|
||||
},
|
||||
undefined,
|
||||
]
|
||||
}
|
||||
>
|
||||
<Text
|
||||
style={
|
||||
{
|
||||
"color": "white",
|
||||
"fontSize": 15,
|
||||
"textAlign": "center",
|
||||
}
|
||||
}
|
||||
>
|
||||
Awesome Button!
|
||||
</Text>
|
||||
</View>
|
||||
`;
|
@ -1,16 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<MonoText /> renders correctly 1`] = `
|
||||
<Text
|
||||
style={
|
||||
[
|
||||
undefined,
|
||||
{
|
||||
"fontFamily": "SpaceMono",
|
||||
},
|
||||
]
|
||||
}
|
||||
>
|
||||
Awesome text!
|
||||
</Text>
|
||||
`;
|
@ -0,0 +1,3 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<TabBarIcon /> renders correctly 1`] = `<Text />`;
|
@ -5,7 +5,7 @@ import type {
|
||||
AuthenticationPresenter,
|
||||
AuthenticationPresenterState,
|
||||
} from "@/presentation/presenters/Authentication"
|
||||
import { authenticationPresenter } from "@/infrastructure"
|
||||
import { authenticationPresenter } from "@/infrastructure/instances"
|
||||
|
||||
export interface AuthenticationContextValue
|
||||
extends AuthenticationPresenterState {
|
||||
|
@ -5,7 +5,7 @@ import type {
|
||||
HabitsTrackerPresenterState,
|
||||
} from "@/presentation/presenters/HabitsTracker"
|
||||
import { usePresenterState } from "@/presentation/react/hooks/usePresenterState"
|
||||
import { habitsTrackerPresenter } from "@/infrastructure"
|
||||
import { habitsTrackerPresenter } from "@/infrastructure/instances"
|
||||
import { useAuthentication } from "./Authentication"
|
||||
|
||||
export interface HabitsTrackerContextValue extends HabitsTrackerPresenterState {
|
||||
|
Reference in New Issue
Block a user