From 853aefca82243a574e3fd8d5e5c7270355ba0cdb Mon Sep 17 00:00:00 2001
From: piotrruss <mail@pruss.it>
Date: Sun, 22 May 2022 13:42:29 +0100
Subject: add sorting

---
 components/Menu.jsx | 93 ++++++++++++++++++++++++++++-------------------------
 1 file changed, 49 insertions(+), 44 deletions(-)

(limited to 'components/Menu.jsx')

diff --git a/components/Menu.jsx b/components/Menu.jsx
index 519fe94..f380c62 100644
--- a/components/Menu.jsx
+++ b/components/Menu.jsx
@@ -1,49 +1,54 @@
 import { StyleSheet, Text, View } from 'react-native';
-import { handleLogout } from '../helpers'
+import { handleLogout, SORT } from '../helpers'
 
-const Menu = ({ session, setSession, setEdit, showError, saveNote }) => (
-  <View style={styles.menu}>
-    {
-      saveNote
-        ? (
-          <>
-            <Text
-              style={styles.menuText}
-              onPress={() => setEdit(null)}
-            >
-              Back
-            </Text>
-            <Text
-              style={styles.menuText}
-              onPress={saveNote}
-            >
-              Save
-            </Text>
-          </>
-        ) : (
-          <>
-            <Text
-              style={styles.menuText}
-              onPress={() => setEdit({})}
-            >
-              New Note
-            </Text>
-            <Text
-              style={styles.menuText}
-            >
-              Sort
-            </Text>
-            <Text
-              style={styles.menuText}
-              onPress={() => handleLogout({ session, setSession, showError })}
-            >
-              {session.email}
-            </Text>
-          </>
-        )
-    }
-  </View>
-)
+const Menu = ({ session, setSession, setEdit, showError, saveNote, sort, setSort }) => {
+  const changeSort = () => sort < SORT.length-1 ? setSort(sort+1) : setSort(0)
+
+  return (
+    <View style={styles.menu}>
+      {
+        saveNote
+          ? (
+            <>
+              <Text
+                style={styles.menuText}
+                onPress={() => setEdit(null)}
+              >
+                Back
+              </Text>
+              <Text
+                style={styles.menuText}
+                onPress={saveNote}
+              >
+                Save
+              </Text>
+            </>
+          ) : (
+            <>
+              <Text
+                style={styles.menuText}
+                onPress={() => setEdit({})}
+              >
+                New Note
+              </Text>
+              <Text
+                style={styles.menuText}
+                onPress={changeSort}
+              >
+                {SORT[sort]}
+              </Text>
+              <Text
+                style={styles.menuText}
+                onPress={() => handleLogout({ session, setSession, showError })}
+              >
+                {session.email}
+              </Text>
+            </>
+          )
+      }
+    </View>
+  )
+}
 
 const styles = StyleSheet.create({
   menu: {
-- 
cgit v1.2.3

