So called working
This commit is contained in:
		
							parent
							
								
									79328b6b62
								
							
						
					
					
						commit
						556bf52865
					
				
					 2 changed files with 22 additions and 4 deletions
				
			
		|  | @ -1,7 +1,7 @@ | |||
| import React from "react"; | ||||
| import { View, Text, TextInput, Button } from "react-native"; | ||||
| import { style } from "../util/style"; | ||||
| import { createPost, NewPost } from "../util/api"; | ||||
| import { createPost, NewPost, submitLogin } from "../util/api"; | ||||
| 
 | ||||
| export function NewPostContainer({ navigation }): JSX.Element { | ||||
|   const [currentInput, setCurrentInput] = React.useState<string>(""); | ||||
|  | @ -21,13 +21,20 @@ export function NewPostContainer({ navigation }): JSX.Element { | |||
|       <Button | ||||
|         title="Post" | ||||
|         onPress={() => { | ||||
|           if (currentInput.length > 0) { | ||||
|           async function submit(): Promise<void> { | ||||
|             const user = (await submitLogin("demouser", "demopw")) ?? { | ||||
|               token: "", | ||||
|             }; | ||||
|             const p: NewPost = { | ||||
|               content: currentInput, | ||||
|               token: "token", | ||||
|               token: user.token, | ||||
|             }; | ||||
|             createPost(p); | ||||
|             await createPost(p); | ||||
|             setCurrentInput(""); | ||||
|           } | ||||
|           if (currentInput.length > 0) { | ||||
|             submit(); | ||||
|             navigation.navigate("Home"); | ||||
|           } else { | ||||
|             setCurrentInputError("Post must not be empty!"); | ||||
|           } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Imbus
						Imbus