parent
2da9f7904d
commit
0b71078069
@ -0,0 +1,43 @@
|
||||
import React from 'react';
|
||||
import { FC } from 'react'
|
||||
import { useController } from 'react-hook-form';
|
||||
import { Datepicker, Icon, IconElement, Layout } from '@ui-kitten/components';
|
||||
|
||||
|
||||
interface Props {
|
||||
name: string,
|
||||
label: string,
|
||||
control: any
|
||||
}
|
||||
|
||||
const CalendarIcon = (props:any): IconElement => (
|
||||
<Icon
|
||||
{...props}
|
||||
name='calendar'
|
||||
/>
|
||||
);
|
||||
|
||||
export const InputDate: FC<Props> = ({ name, label, control }) => {
|
||||
|
||||
const { field } = useController({
|
||||
control,
|
||||
defaultValue: 0.0,
|
||||
name,
|
||||
})
|
||||
|
||||
return (
|
||||
<>
|
||||
<Layout className='flex flex-col' level='1'>
|
||||
<Datepicker
|
||||
label={''}
|
||||
caption='Caption'
|
||||
placeholder='Pick Date'
|
||||
date={new Date(field.value)}
|
||||
onSelect={field.onChange}
|
||||
accessoryRight={CalendarIcon}
|
||||
className='p-2 m-2 w-max border rounded-xl border-sky-500'
|
||||
/>
|
||||
</Layout>
|
||||
</>
|
||||
)
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
import React from 'react';
|
||||
import { FC } from 'react'
|
||||
import { useController } from 'react-hook-form';
|
||||
import { Text, TextInput, View } from 'react-native';
|
||||
|
||||
interface Props {
|
||||
name: string,
|
||||
label: string,
|
||||
control: any
|
||||
}
|
||||
|
||||
export const InputNumber: FC<Props> = ({ name, label, control }) => {
|
||||
|
||||
const { field } = useController({
|
||||
control,
|
||||
defaultValue: 0.0,
|
||||
name,
|
||||
})
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className='flex flex-col'>
|
||||
<TextInput
|
||||
id={name}
|
||||
value={String(field.value)}
|
||||
onChangeText={field.onChange}
|
||||
placeholder={label}
|
||||
keyboardType="numeric"
|
||||
className='p-2 m-2 w-max border rounded-xl border-sky-500'
|
||||
/>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
}
|
@ -1,8 +1,89 @@
|
||||
const CompanyFormScreen = () => {
|
||||
import { useEffect } from 'react'
|
||||
import { Text } from 'react-native'
|
||||
import { Background } from '../../components/Background'
|
||||
import { Button } from '../../components/Button';
|
||||
import { Card } from '../../components/Card';
|
||||
import { Input } from '../../components/Input';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { NativeStackScreenProps } from '@react-navigation/native-stack';
|
||||
import { RootStackParams } from './CompanyStack';
|
||||
import { useFetchWithAuth } from '../../hooks/useFetchWithAuth';
|
||||
import { saveWithAuth } from '../../hooks/saveWithAuth';
|
||||
import { ManyToOne } from '../../components/ManyToOne';
|
||||
|
||||
|
||||
|
||||
interface Props extends NativeStackScreenProps<RootStackParams, 'CompanyFormScreen'> { };
|
||||
|
||||
export const CompanyFormScreen = ({ route, navigation }: Props) => {
|
||||
|
||||
const { control, handleSubmit, setValue, formState: { errors } } = useForm({
|
||||
defaultValues: {
|
||||
id: 0,
|
||||
nombre: '',
|
||||
ruc: '',
|
||||
direccion: ''
|
||||
}
|
||||
});
|
||||
let id: string = "0";
|
||||
if (route.params?.id != undefined) {
|
||||
id = String(route.params.id);
|
||||
}
|
||||
|
||||
const getInitData = async () => {
|
||||
if (!id || id == "0")
|
||||
return;
|
||||
const { data, error } = await useFetchWithAuth("compania/" + id);
|
||||
|
||||
if (!error) {
|
||||
|
||||
if (data.id != 0) {
|
||||
setValue("id", data['id'])
|
||||
setValue("nombre", data['nombre'])
|
||||
setValue("ruc", data['ruc'])
|
||||
setValue("direccion", data['direccion'])
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
getInitData();
|
||||
}, [])
|
||||
|
||||
const onSubmit = async (entity: any) => {
|
||||
try {
|
||||
let endpoint = "compania";
|
||||
//entity['compania'] = { id: entity['compania'].id }
|
||||
const { data, error } = await saveWithAuth(endpoint, id, entity);
|
||||
if (error) {
|
||||
console.log(error);
|
||||
} else {
|
||||
navigation.navigate("CompanyListScreen")
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("Post error:");
|
||||
console.table(e);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Background >
|
||||
<Card>
|
||||
<Text className='text-xl text-center my-4'>Registro de clientes</Text>
|
||||
<Input name="ruc" label='RUC' control={control} />
|
||||
<Input name="nombre" label='Nombre' control={control} />
|
||||
<Input name="direccion" label='Dirección' control={control} />
|
||||
<Button
|
||||
title='Guardar'
|
||||
onPress={handleSubmit(onSubmit)}
|
||||
/>
|
||||
</Card>
|
||||
</Background>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default CompanyFormScreen;
|
@ -1,12 +1,63 @@
|
||||
import { Text } from "react-native";
|
||||
import { useEffect, useState } from 'react'
|
||||
import { FlatList, RefreshControl, Text, View } from 'react-native'
|
||||
import { useNavigation } from '@react-navigation/native';
|
||||
import { Card } from '../../components/Card'
|
||||
import { CardList } from '../../components/cardList/CardList'
|
||||
import { Button } from '../../components/Button'
|
||||
import { useFetchWithAuth } from '../../hooks/useFetchWithAuth'
|
||||
|
||||
const CompanyListScreen = () => {
|
||||
export const CompanyListScreen = () => {
|
||||
const navigation = useNavigation();
|
||||
const [refreshing, setRefreshing] = useState(false);
|
||||
const endpoints = "compania";
|
||||
let defaultData: [] = [];
|
||||
|
||||
const [entities, setEntities] = useState(defaultData);
|
||||
|
||||
const getInitData = async () => {
|
||||
const { data, error } = await useFetchWithAuth(endpoints);
|
||||
if (!error) {
|
||||
setEntities(data);
|
||||
} else {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getInitData();
|
||||
}, [refreshing])
|
||||
|
||||
const onRefresh = () => {
|
||||
setRefreshing(true);
|
||||
setTimeout(() => {
|
||||
setRefreshing(false);
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Text>Compañia lista</Text>
|
||||
</>
|
||||
<View className='bg-sky-100'>
|
||||
<Button
|
||||
title=' + '
|
||||
additionalStyle='z-10 absolute bottom-2 right-0'
|
||||
onPress={() => navigation.navigate("CompanyFormScreen" as never)} />
|
||||
<FlatList
|
||||
refreshControl={
|
||||
<RefreshControl
|
||||
refreshing={refreshing}
|
||||
onRefresh={onRefresh}
|
||||
/>
|
||||
}
|
||||
data={[""]}
|
||||
renderItem={({ item }) =>
|
||||
<View id={item} className='flex-1 items-center'>
|
||||
<Card>
|
||||
<Text className='text-xl text-center my-4'>Listado de compania</Text>
|
||||
<CardList screenName="CompanyFormScreen" columnDisplay="nombre" entities={entities} />
|
||||
</Card>
|
||||
</View>
|
||||
}
|
||||
keyExtractor={item => item}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
export default CompanyListScreen;
|
@ -1,13 +0,0 @@
|
||||
import { FC } from 'react'
|
||||
import { Text } from 'react-native'
|
||||
|
||||
interface Props {
|
||||
}
|
||||
|
||||
export const CompanyScreen:FC <Props> = () => {
|
||||
return (
|
||||
<>
|
||||
<Text>Compañia</Text>
|
||||
</>
|
||||
)
|
||||
}
|
@ -1,24 +1,30 @@
|
||||
import { createNativeStackNavigator } from "@react-navigation/native-stack";
|
||||
import CompanyListScreen from "./CompanyListScreen";
|
||||
import CompanyFormScreen from "./CompanyFormScreen";
|
||||
import { useContext } from 'react'
|
||||
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
||||
import { AuthContext } from '../login/AuthContext';
|
||||
import { CompanyFormScreen } from './CompanyFormScreen';
|
||||
import { CompanyListScreen } from './CompanyListScreen';
|
||||
|
||||
const Stack = createNativeStackNavigator();
|
||||
export type RootStackParams = {
|
||||
CompanyListScreen: undefined,
|
||||
CompanyFormScreen: { id: number }
|
||||
}
|
||||
const Stack = createNativeStackNavigator<RootStackParams>();
|
||||
|
||||
const CompanyStack = () => {
|
||||
export const CompanyStack = () => {
|
||||
const { isAuthenticated } = useContext(AuthContext)
|
||||
|
||||
return (
|
||||
<Stack.Navigator
|
||||
screenOptions={
|
||||
{
|
||||
headerShown:true
|
||||
}
|
||||
}
|
||||
screenOptions={{
|
||||
headerShown: true,
|
||||
}}
|
||||
>
|
||||
{isAuthenticated && (
|
||||
<>
|
||||
<Stack.Screen name="CompanyListScreen" component={CompanyListScreen} />
|
||||
<Stack.Screen name="CompanyFormScreen" component={CompanyFormScreen} />
|
||||
</>
|
||||
)}
|
||||
</Stack.Navigator>
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
export default CompanyStack;
|
@ -0,0 +1,91 @@
|
||||
import { useEffect } from 'react'
|
||||
import { Text } from 'react-native'
|
||||
import { Background } from '../../components/Background'
|
||||
import { Button } from '../../components/Button';
|
||||
import { Card } from '../../components/Card';
|
||||
import { Input } from '../../components/Input';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { NativeStackScreenProps } from '@react-navigation/native-stack';
|
||||
import { RootStackParams } from './ProductStack';
|
||||
import { useFetchWithAuth } from '../../hooks/useFetchWithAuth';
|
||||
import { saveWithAuth } from '../../hooks/saveWithAuth';
|
||||
import { InputNumber } from '../../components/InputNumber';
|
||||
import { InputDate } from '../../components/InputDate';
|
||||
|
||||
|
||||
interface Props extends NativeStackScreenProps<RootStackParams, 'ProductFormScreen'> { };
|
||||
|
||||
export const ProductFormScreen = ({ route, navigation }: Props) => {
|
||||
|
||||
const { control, handleSubmit, setValue, formState: { errors } } = useForm({
|
||||
defaultValues: {
|
||||
id: 0,
|
||||
nombre: '',
|
||||
codigo: '',
|
||||
precio: 0,
|
||||
creado: new Date()
|
||||
}
|
||||
});
|
||||
let id: string = "0";
|
||||
if (route.params?.id != undefined) {
|
||||
id = String(route.params.id);
|
||||
}
|
||||
|
||||
const getInitData = async () => {
|
||||
if (!id || id == "0")
|
||||
return;
|
||||
const { data, error } = await useFetchWithAuth("producto/" + id);
|
||||
if (!error) {
|
||||
|
||||
if (data.id != 0) {
|
||||
setValue("id", data['id'])
|
||||
setValue("nombre", data['nombre'])
|
||||
setValue("codigo", data['codigo'])
|
||||
setValue("precio", data['precio'])
|
||||
setValue("creado", data['creado'])
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
getInitData();
|
||||
}, [])
|
||||
|
||||
const onSubmit = async (entity: any) => {
|
||||
try {
|
||||
let endpoint = "producto";
|
||||
//entity['creado'] = entity['creado']
|
||||
const { data, error } = await saveWithAuth(endpoint, id, entity);
|
||||
if (error) {
|
||||
console.log(error);
|
||||
} else {
|
||||
navigation.navigate("ProductListScreen")
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("Post error:");
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Background >
|
||||
<Card>
|
||||
<Text className='text-xl text-center my-4'>Registro de Productos</Text>
|
||||
<Input name="codigo" label='Código' control={control} />
|
||||
<Input name="nombre" label='Nombre' control={control} />
|
||||
<InputNumber name="precio" label='Precio' control={control} />
|
||||
<InputDate name="creado" label='creado' control={control} />
|
||||
<Button
|
||||
title='Guardar'
|
||||
onPress={handleSubmit(onSubmit)}
|
||||
/>
|
||||
</Card>
|
||||
</Background>
|
||||
</>
|
||||
)
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { FlatList, RefreshControl, Text, View } from 'react-native'
|
||||
import { useNavigation } from '@react-navigation/native';
|
||||
import { Card } from '../../components/Card'
|
||||
import { CardList } from '../../components/cardList/CardList'
|
||||
import { Button } from '../../components/Button'
|
||||
import { useFetchWithAuth } from '../../hooks/useFetchWithAuth'
|
||||
|
||||
export const ProductListScreen = () => {
|
||||
const navigation = useNavigation();
|
||||
const [refreshing, setRefreshing] = useState(false);
|
||||
const endpoints = "producto";
|
||||
let defaultData: [] = [];
|
||||
|
||||
const [entities, setEntities] = useState(defaultData);
|
||||
|
||||
const getInitData = async () => {
|
||||
const { data, error } = await useFetchWithAuth(endpoints);
|
||||
if (!error) {
|
||||
setEntities(data);
|
||||
} else {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getInitData();
|
||||
}, [refreshing])
|
||||
|
||||
const onRefresh = () => {
|
||||
setRefreshing(true);
|
||||
setTimeout(() => {
|
||||
setRefreshing(false);
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
return (
|
||||
<View className='bg-sky-100'>
|
||||
<Button
|
||||
title=' + '
|
||||
additionalStyle='z-10 absolute bottom-2 right-0'
|
||||
onPress={() => navigation.navigate("ProductFormScreen" as never)} />
|
||||
<FlatList
|
||||
refreshControl={
|
||||
<RefreshControl
|
||||
refreshing={refreshing}
|
||||
onRefresh={onRefresh}
|
||||
/>
|
||||
}
|
||||
data={[""]}
|
||||
renderItem={({ item }) =>
|
||||
<View id={item} className='flex-1 items-center'>
|
||||
<Card>
|
||||
<Text className='text-xl text-center my-4'>Listado de Produtos</Text>
|
||||
<CardList screenName="ProductFormScreen" columnDisplay="nombre" entities={entities} />
|
||||
</Card>
|
||||
</View>
|
||||
}
|
||||
keyExtractor={item => item}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
import { FC } from 'react'
|
||||
import { Text } from 'react-native'
|
||||
|
||||
interface Props {
|
||||
}
|
||||
|
||||
export const ProductScreen:FC <Props> = () => {
|
||||
return (
|
||||
<>
|
||||
<Text>Producto</Text>
|
||||
</>
|
||||
)
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
import { useContext } from 'react'
|
||||
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
||||
import { AuthContext } from '../login/AuthContext';
|
||||
import { ProductFormScreen } from './ProductFormScreen';
|
||||
import { ProductListScreen } from './ProductListScreen';
|
||||
|
||||
export type RootStackParams = {
|
||||
ProductListScreen: undefined,
|
||||
ProductFormScreen: { id: number }
|
||||
}
|
||||
const Stack = createNativeStackNavigator<RootStackParams>();
|
||||
|
||||
export const ProductStack = () => {
|
||||
const { isAuthenticated } = useContext(AuthContext)
|
||||
|
||||
return (
|
||||
<Stack.Navigator
|
||||
screenOptions={{
|
||||
headerShown: true,
|
||||
}}
|
||||
>
|
||||
{isAuthenticated && (
|
||||
<>
|
||||
<Stack.Screen name="ProductListScreen" component={ProductListScreen} />
|
||||
<Stack.Screen name="ProductFormScreen" component={ProductFormScreen} />
|
||||
</>
|
||||
)}
|
||||
</Stack.Navigator>
|
||||
)
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
import { useEffect } from 'react'
|
||||
import { Text } from 'react-native'
|
||||
import { Background } from '../../components/Background'
|
||||
import { Button } from '../../components/Button';
|
||||
import { Card } from '../../components/Card';
|
||||
import { Input } from '../../components/Input';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { NativeStackScreenProps } from '@react-navigation/native-stack';
|
||||
import { useFetchWithAuth } from '../../hooks/useFetchWithAuth';
|
||||
import { saveWithAuth } from '../../hooks/saveWithAuth';
|
||||
import { ManyToOne } from '../../components/ManyToOne';
|
||||
import { RootStackParams } from './SalesOrderStack';
|
||||
|
||||
|
||||
interface Props extends NativeStackScreenProps<RootStackParams, 'SalesOrderFormScreen'> { };
|
||||
|
||||
export const SalesOrderFormScreen = ({ route, navigation }: Props) => {
|
||||
|
||||
const { control, handleSubmit, setValue, formState: { errors } } = useForm({
|
||||
defaultValues: {
|
||||
id: 0,
|
||||
numero: '',
|
||||
cliente: { id: 0 }
|
||||
}
|
||||
});
|
||||
let id: string = "0";
|
||||
if (route.params?.id != undefined) {
|
||||
id = String(route.params.id);
|
||||
}
|
||||
|
||||
const getInitData = async () => {
|
||||
if (!id || id == "0")
|
||||
return;
|
||||
const { data, error } = await useFetchWithAuth("pedido/" + id);
|
||||
|
||||
if (!error) {
|
||||
|
||||
if (data.id != 0) {
|
||||
setValue("id", data['id'])
|
||||
setValue("numero", data['numero'])
|
||||
setValue("cliente", data['cliente'])
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
getInitData();
|
||||
}, [])
|
||||
|
||||
const onSubmit = async (entity: any) => {
|
||||
try {
|
||||
let endpoint = "pedido";
|
||||
entity['cliente'] = { id: entity['cliente'].id }
|
||||
const { data, error } = await saveWithAuth(endpoint, id, entity);
|
||||
if (error) {
|
||||
console.log(error);
|
||||
} else {
|
||||
navigation.navigate("SalesOrderListScreen")
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("Post error:");
|
||||
console.table(e);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Background >
|
||||
<Card>
|
||||
<Text className='text-xl text-center my-4'>Registro de Pedido</Text>
|
||||
<Input name="numero" label='Número' control={control} />
|
||||
<ManyToOne entity='cliente' columname='cliente' columnvalue="nombre" control={control} />
|
||||
<Button
|
||||
title='Guardar'
|
||||
onPress={handleSubmit(onSubmit)}
|
||||
/>
|
||||
</Card>
|
||||
</Background>
|
||||
</>
|
||||
)
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { FlatList, RefreshControl, Text, View } from 'react-native'
|
||||
import { useNavigation } from '@react-navigation/native';
|
||||
import { Card } from '../../components/Card'
|
||||
import { CardList } from '../../components/cardList/CardList'
|
||||
import { Button } from '../../components/Button'
|
||||
import { useFetchWithAuth } from '../../hooks/useFetchWithAuth'
|
||||
|
||||
export const SalesOrderListScreen = () => {
|
||||
const navigation = useNavigation();
|
||||
const [refreshing, setRefreshing] = useState(false);
|
||||
const endpoints = "pedido";
|
||||
let defaultData: [] = [];
|
||||
|
||||
const [entities, setEntities] = useState(defaultData);
|
||||
|
||||
const getInitData = async () => {
|
||||
const { data, error } = await useFetchWithAuth(endpoints);
|
||||
if (!error) {
|
||||
setEntities(data);
|
||||
} else {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getInitData();
|
||||
}, [refreshing])
|
||||
|
||||
const onRefresh = () => {
|
||||
setRefreshing(true);
|
||||
setTimeout(() => {
|
||||
setRefreshing(false);
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
return (
|
||||
<View className='bg-sky-100'>
|
||||
<Button
|
||||
title=' + '
|
||||
additionalStyle='z-10 absolute bottom-2 right-0'
|
||||
onPress={() => navigation.navigate("SalesOrderFormScreen" as never)} />
|
||||
<FlatList
|
||||
refreshControl={
|
||||
<RefreshControl
|
||||
refreshing={refreshing}
|
||||
onRefresh={onRefresh}
|
||||
/>
|
||||
}
|
||||
data={[""]}
|
||||
renderItem={({ item }) =>
|
||||
<View id={item} className='flex-1 items-center'>
|
||||
<Card>
|
||||
<Text className='text-xl text-center my-4'>Listado de pedidos</Text>
|
||||
<CardList screenName="SalesOrderFormScreen" columnDisplay="numero" entities={entities} />
|
||||
</Card>
|
||||
</View>
|
||||
}
|
||||
keyExtractor={item => item}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
import { FC, useContext } from 'react'
|
||||
import { Text } from 'react-native'
|
||||
import { Button } from '../../components/Button'
|
||||
import { StackScreenProps } from '@react-navigation/stack';
|
||||
import { View } from 'react-native';
|
||||
import { AuthContext } from '../login/AuthContext';
|
||||
import { Background } from '../../components/Background';
|
||||
import { NavBar } from '../../components/navbar/NavBar';
|
||||
|
||||
interface Props extends StackScreenProps<any, any> {
|
||||
|
||||
}
|
||||
|
||||
export const SalesOrderScreen:FC <Props> = ({navigation}) => {
|
||||
const {isAuthenticated, logOut} = useContext(AuthContext);
|
||||
|
||||
const exit = () => {
|
||||
logOut();
|
||||
navigation.navigate("CustomerScreen");
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Background >
|
||||
<Text>Pedidos</Text>
|
||||
<Button title='Clientes' onClick={()=>navigation.navigate("CustomerScreen")}/>
|
||||
<Button title='LogOut' onClick={()=>exit()} />
|
||||
|
||||
</Background>
|
||||
|
||||
</>
|
||||
|
||||
)
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
import { useContext } from 'react'
|
||||
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
||||
import { AuthContext } from '../login/AuthContext';
|
||||
import { SalesOrderFormScreen } from './SalesOrderFormScreen';
|
||||
import { SalesOrderListScreen } from './SalesOrderListScreen';
|
||||
|
||||
export type RootStackParams = {
|
||||
SalesOrderListScreen: undefined,
|
||||
SalesOrderFormScreen: { id: number }
|
||||
}
|
||||
const Stack = createNativeStackNavigator<RootStackParams>();
|
||||
|
||||
export const SalesOrderStack = () => {
|
||||
const { isAuthenticated } = useContext(AuthContext)
|
||||
|
||||
return (
|
||||
<Stack.Navigator
|
||||
screenOptions={{
|
||||
headerShown: true,
|
||||
}}
|
||||
>
|
||||
{isAuthenticated && (
|
||||
<>
|
||||
<Stack.Screen name="SalesOrderListScreen" component={SalesOrderListScreen} />
|
||||
<Stack.Screen name="SalesOrderFormScreen" component={SalesOrderFormScreen} />
|
||||
</>
|
||||
)}
|
||||
</Stack.Navigator>
|
||||
)
|
||||
}
|
Loading…
Reference in new issue