From 36d5b1825e1dd30d4b72d7a047a2fa94ab67b7ac Mon Sep 17 00:00:00 2001 From: sverben <59171289+sverben@users.noreply.github.com> Date: Tue, 11 Jun 2024 15:33:53 +0200 Subject: [PATCH] feat: order list + search rework --- src/screens/feed/search.tsx | 153 ++++++++++++++++++++++++++---------- src/screens/settings.tsx | 15 ++++ 2 files changed, 125 insertions(+), 43 deletions(-) diff --git a/src/screens/feed/search.tsx b/src/screens/feed/search.tsx index df1c3f3..8d5ca72 100644 --- a/src/screens/feed/search.tsx +++ b/src/screens/feed/search.tsx @@ -1,10 +1,19 @@ -import { Card, Searchbar, useTheme } from "react-native-paper"; +import { + ActivityIndicator, + Button, + Card, + Icon, + Searchbar, + Text, + useTheme, +} from "react-native-paper"; import { useState } from "react"; import { SafeAreaView, ScrollView, StyleSheet, View } from "react-native"; import { useNavigation } from "@react-navigation/native"; import { ActionType, FeedItem } from "../../stores/feed"; import Item from "../../components/feed/item"; import { parse } from "fast-html-parser"; +import * as WebBrowser from "expo-web-browser"; export interface Item { id: number; @@ -78,62 +87,106 @@ export default function SearchScreen() { const [search, setSearch] = useState(""); const navigation = useNavigation(); - const [itemResults, setItemsResults] = useState([]); - const [articleResults, setArticleResults] = useState([]); + const [itemResults, setItemsResults] = useState(null); + const [articleResults, setArticleResults] = useState(null); + const [searched, setSearched] = useState(false); async function updateResults() { + setSearched(!!search); if (!search) return; + + setItemsResults(null); + setArticleResults(null); + getItems(search).then(setItemsResults); getArticles(search).then(setArticleResults); } + async function orderList() { + await WebBrowser.openBrowserAsync( + "https://docs.google.com/document/d/1cyrfqq37l9QdhByT1zExyk_W7TDEhyO6/edit", + ); + } + return ( - - - - - + <> + - {itemResults.length > 0 && ( - - - - {itemResults.map((result, index) => ( - - ))} - - - )} - {articleResults.length > 0 && ( - - - - {articleResults.map((result, index) => ( - - ))} - - - )} + + + + + {searched && ( + <> + + + + {itemResults ? ( + itemResults.length > 0 ? ( + itemResults.map((result, index) => ( + + )) + ) : ( + + Geen producten gevonden + + + ) + ) : ( + + )} + + + + + + {articleResults ? ( + articleResults.length > 0 ? ( + articleResults.map((result, index) => ( + + )) + ) : ( + + Geen artikelen gevonden + + ) + ) : ( + + )} + + + + )} + + + + + {!searched && ( + + + Zoek naar artikelen en items in de inventaris - - + )} + ); } @@ -153,4 +206,18 @@ const styles = StyleSheet.create({ content: { gap: 10, }, + center: { + alignItems: "center", + }, + start: { + position: "absolute", + left: 0, + top: 0, + width: "100%", + height: "100%", + zIndex: -1, + justifyContent: "center", + alignItems: "center", + gap: 10, + }, }); diff --git a/src/screens/settings.tsx b/src/screens/settings.tsx index 4715752..88df935 100644 --- a/src/screens/settings.tsx +++ b/src/screens/settings.tsx @@ -2,11 +2,18 @@ import { useContext } from "react"; import AuthContext, { Authed } from "../auth"; import { ScrollView, StyleSheet, View } from "react-native"; import { Appbar, Button, Card, Text } from "react-native-paper"; +import * as WebBrowser from "expo-web-browser"; import auth from "../auth"; export default function SettingsScreen() { const authState = useContext(AuthContext); + async function orderList() { + await WebBrowser.openBrowserAsync( + "https://docs.google.com/document/d/1cyrfqq37l9QdhByT1zExyk_W7TDEhyO6/edit", + ); + } + return ( <> @@ -14,6 +21,14 @@ export default function SettingsScreen() { + + + + + + {authState.authenticated === Authed.AUTHENTICATED && (