-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3470dfb
commit f22197c
Showing
9 changed files
with
8,450 additions
and
37 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"name": "rockethelp-thorvi", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "expo start --dev-client", | ||
"android": "expo run:android", | ||
"ios": "expo run:ios", | ||
"web": "expo start --web" | ||
}, | ||
"dependencies": { | ||
"@expo-google-fonts/roboto": "^0.2.2", | ||
"@react-native-firebase/app": "^15.1.1", | ||
"@react-native-firebase/auth": "^15.1.1", | ||
"@react-native-firebase/firestore": "^15.1.1", | ||
"@react-navigation/native": "^6.0.11", | ||
"@react-navigation/native-stack": "^6.7.0", | ||
"expo": "~45.0.0", | ||
"expo-font": "~10.1.0", | ||
"expo-splash-screen": "~0.15.1", | ||
"expo-status-bar": "~1.3.0", | ||
"native-base": "^3.4.9", | ||
"phosphor-react-native": "^1.1.2", | ||
"react": "17.0.2", | ||
"react-dom": "17.0.2", | ||
"react-native": "0.68.2", | ||
"react-native-safe-area-context": "4.2.4", | ||
"react-native-screens": "~3.11.1", | ||
"react-native-svg": "12.3.0", | ||
"react-native-svg-transformer": "^1.0.0", | ||
"react-native-web": "0.17.7" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.12.9", | ||
"@types/react": "~17.0.21", | ||
"@types/react-native": "~0.67.6", | ||
"typescript": "~4.3.5" | ||
}, | ||
"private": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// DTO = data transfer object | ||
import {FirebaseFirestoreTypes} from "@react-native-firebase/firestore"; | ||
|
||
export type OrderFirestoreDTO = { | ||
patrimony: string; | ||
description: string; | ||
status: 'open' | 'closed', | ||
created_at: FirebaseFirestoreTypes.Timestamp; | ||
solution?: string; | ||
closed_at?: FirebaseFirestoreTypes.Timestamp; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {VStack} from "native-base"; | ||
|
||
export function CardDetails() { | ||
return( | ||
<VStack></VStack> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,66 @@ | ||
import {useState} from "react"; | ||
import {VStack} from "native-base"; | ||
import {Header} from "../components/Header"; | ||
import {Input} from "../components/Input"; | ||
import {Button} from "../components/Button"; | ||
|
||
import {Alert} from "react-native"; | ||
import firestore from '@react-native-firebase/firestore' | ||
import {useNavigation} from "@react-navigation/native"; | ||
|
||
export function Register() { | ||
const [isLoading, setIsLoading] = useState(false); | ||
const [patrimony, setPatrimony] = useState(''); | ||
const [description, setDescription] = useState(''); | ||
const navigation = useNavigation(); | ||
|
||
function handleNewOrderRegister() { | ||
if (!patrimony || !description) { | ||
return Alert.alert('Registrar', 'Preencha todos os campos antes de continuar.') | ||
} | ||
|
||
setIsLoading(true); | ||
|
||
firestore() | ||
.collection('orders') | ||
.add({ | ||
patrimony, | ||
description, | ||
status: 'open', | ||
created_at: firestore.FieldValue.serverTimestamp() | ||
}) | ||
.then(() => { | ||
Alert.alert('Solicitação', 'Solicitação registrada com sucesso.'); | ||
navigation.goBack(); | ||
}) | ||
.catch((error => { | ||
console.log(error); | ||
setIsLoading(false); | ||
return Alert.alert('Solicitação', 'Não foi possível registrar o pedido.'); | ||
})); | ||
} | ||
|
||
return ( | ||
<VStack flex={1} p={6} bg='gray.600'> | ||
<Header title="Nova solicitação" /> | ||
<Header title="Nova solicitação"/> | ||
<Input | ||
placeholder="Número de patrimônio" | ||
mt={4} | ||
placeholder="Número de patrimônio" | ||
mt={4} | ||
onChangeText={setPatrimony} | ||
/> | ||
<Input | ||
placeholder="Descrição do problema" | ||
mt={5} | ||
flex={1} | ||
multiline | ||
textAlignVertical="top" | ||
placeholder="Descrição do problema" | ||
mt={5} | ||
flex={1} | ||
multiline | ||
textAlignVertical="top" | ||
onChangeText={setDescription} | ||
/> | ||
<Button | ||
title="Cadastrar" | ||
mt={5} | ||
isLoading={isLoading} | ||
onPress={handleNewOrderRegister} | ||
/> | ||
<Button title="Cadastrar" mt={5} /> | ||
</VStack> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {FirebaseFirestoreTypes} from "@react-native-firebase/firestore"; | ||
|
||
export function dateFormat(timestamp: FirebaseFirestoreTypes.Timestamp) { | ||
if(timestamp) { | ||
const date = new Date(timestamp.toDate()); | ||
|
||
const day = date.toLocaleDateString('pt-BR'); | ||
const hour = date.toLocaleTimeString('pt-BR'); | ||
|
||
return `${day} às ${hour}`; | ||
} | ||
} |
Oops, something went wrong.