Skip to content

Commit

Permalink
Merge pull request #11 from ThatNinjaGuy/develop
Browse files Browse the repository at this point in the history
All existing screens updated to have both a better layout for UX and DB structure
  • Loading branch information
ThatNinjaGuy committed Aug 19, 2024
2 parents 7cec93d + ee8334a commit f39ef9d
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 47 deletions.
2 changes: 1 addition & 1 deletion components/InventoryItem/InventoryItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const InventoryItem = ({ item, onEdit }) => (
<View style={styles.infoContainer}>
<ThemedText style={styles.name}>{item.name}</ThemedText>
<ThemedText style={styles.price}>
{item.price + " /" + item.unit}
{item.price + "/ " + item.unit}
</ThemedText>
<ThemedText style={styles.cuisine}>
{item.quantity + " " + item.unit}
Expand Down
4 changes: 3 additions & 1 deletion components/OrderTaking/OrderManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const OrderManagement = ({ items, onClose, updateOrder }) => {
useEffect(() => {
const fetchMenuItems = async () => {
try {
const querySnapshot = await getDocs(collection(db, "menu-items/"));
const querySnapshot = await getDocs(
collection(db, "hotel-details/menu/menu-items")
);
const items = querySnapshot.docs.map((doc) => ({
id: doc.id,
...doc.data(),
Expand Down
12 changes: 8 additions & 4 deletions screens/InventoryScreen/InventoryScreenContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const InventoryScreenContainer = () => {
useEffect(() => {
const fetchInventoryItems = async () => {
try {
const querySnapshot = await getDocs(collection(db, "inventory-items"));
const querySnapshot = await getDocs(
collection(db, "hotel-details/inventory/inventory-items")
);
const items = querySnapshot.docs.map((doc) => ({
id: doc.id,
...doc.data(),
Expand All @@ -37,7 +39,9 @@ const InventoryScreenContainer = () => {

items.forEach((item) => {
item.searchableKey = generateUniqueKey(inventoryItems, item);
const docRef = doc(collection(db, "inventory-items"));
const docRef = doc(
collection(db, "hotel-details/inventory/inventory-items")
);
batch.set(docRef, item);
newItems.push({ ...item, id: docRef.id });
});
Expand All @@ -57,7 +61,7 @@ const InventoryScreenContainer = () => {

const deleteInventoryItem = async (id) => {
try {
await deleteDoc(doc(db, "inventory-items", id));
await deleteDoc(doc(db, "hotel-details/inventory/inventory-items", id));
setInventoryItems(inventoryItems.filter((item) => item.id !== id));
console.log("Document successfully deleted!");
} catch (error) {
Expand All @@ -67,7 +71,7 @@ const InventoryScreenContainer = () => {

const updateInventoryItem = async (id, updatedItem) => {
try {
const itemRef = doc(db, "inventory-items", id);
const itemRef = doc(db, "hotel-details/inventory/inventory-items", id);
await updateDoc(itemRef, updatedItem);
setInventoryItems(
inventoryItems.map((item) =>
Expand Down
8 changes: 7 additions & 1 deletion screens/InventoryScreen/InventoryScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ const formSchema = [
inputMode: "numeric",
type: "text",
},
{ name: "unit", placeholder: "Unit", inputMode: "default", type: "text" },
{
name: "unit",
placeholder: "Unit",
inputMode: "default",
type: "dropdown",
options: ["Kg", "l", "pc", "dozen", "quintal"],
},
{
name: "image",
placeholder: "Image URL",
Expand Down
69 changes: 42 additions & 27 deletions screens/MenuScreen/CategoryManagementPopup.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import FloatingCloseButton from "@/components/FloatingCloseButton/FloatingCloseButton";
import ThemedButton from "@/components/common/ThemedButton";
import { ThemedText } from "@/components/common/ThemedText";
import { ThemedView } from "@/components/common/ThemedView";
import React, { useState } from "react";
import {
View,
Text,
Button,
Modal,
FlatList,
TextInput,
StyleSheet,
} from "react-native";
import { Modal, FlatList, TextInput, StyleSheet } from "react-native";

const CategoryManagementPopup = ({
visible,
Expand Down Expand Up @@ -57,39 +52,52 @@ const CategoryManagementPopup = ({

return (
<Modal visible={visible} animationType="slide">
<View style={styles.container}>
<ThemedView style={styles.container}>
<FloatingCloseButton onClose={onClose} />
<Text style={styles.title}>Manage Categories</Text>
<ThemedText type="title" style={styles.title}>
Manage Categories
</ThemedText>
<TextInput
style={styles.input}
placeholder="Category Name"
value={newCategory}
onChangeText={setNewCategory}
/>
<View style={styles.buttons}>
<Button
title={editingCategory ? "Update Category" : "Add Category"}
<ThemedView style={styles.buttons}>
<ThemedButton
type="primary"
onPress={editingCategory ? handleUpdateCategory : handleAddCategory}
/>
{/* <Button title="Cancel" onPress={onClose} /> */}
</View>
>
<ThemedText>
{editingCategory ? "Update Category" : "Add Category"}
</ThemedText>
</ThemedButton>
</ThemedView>
<FlatList
data={categories}
renderItem={({ item }) => (
<View style={styles.categoryItem}>
<Text>{item}</Text>
<View style={styles.categoryActions}>
<Button title="Edit" onPress={() => handleEditCategory(item)} />
<Button
title="Delete"
<ThemedView style={styles.categoryItem}>
<ThemedText type="defaultSemiBold">{item}</ThemedText>
<ThemedView style={styles.categoryActions}>
<ThemedButton
onPress={() => handleDeleteCategory(item)}
/>
</View>
</View>
style={[styles.button, styles.deleteButton]}
>
<ThemedText>Delete</ThemedText>
</ThemedButton>
<ThemedButton
type="primary"
onPress={() => handleEditCategory(item)}
style={styles.button}
>
<ThemedText>Edit</ThemedText>
</ThemedButton>
</ThemedView>
</ThemedView>
)}
keyExtractor={(item) => item}
/>
</View>
</ThemedView>
</Modal>
);
};
Expand All @@ -106,6 +114,13 @@ const styles = StyleSheet.create({
marginVertical: 5,
},
categoryActions: { flexDirection: "row" },
button: {
marginHorizontal: 5,
width: 75,
},
deleteButton: {
backgroundColor: "#F44336",
},
});

export default CategoryManagementPopup;
10 changes: 6 additions & 4 deletions screens/MenuScreen/MenuScreenContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const MenuScreenContainer = () => {
useEffect(() => {
const fetchMenuItems = async () => {
try {
const querySnapshot = await getDocs(collection(db, "menu-items/"));
const querySnapshot = await getDocs(
collection(db, "hotel-details/menu/menu-items")
);
const items = querySnapshot.docs.map((doc) => ({
id: doc.id,
...doc.data(),
Expand Down Expand Up @@ -99,7 +101,7 @@ const MenuScreenContainer = () => {

items.forEach((item) => {
item.searchableKey = generateUniqueKey(menuItems, item);
const docRef = doc(collection(db, "menu-items/"));
const docRef = doc(collection(db, "hotel-details/menu/menu-items"));
batch.set(docRef, item);
newItems.push({ ...item, id: docRef.id });
});
Expand All @@ -120,7 +122,7 @@ const MenuScreenContainer = () => {

const deleteMenuItem = async (id) => {
try {
await deleteDoc(doc(db, "menu-items/", id));
await deleteDoc(doc(db, "hotel-details/menu/menu-items", id));
setMenuItems(menuItems.filter((item) => item.id !== id));
console.log("Document successfully deleted!");
} catch (error) {
Expand All @@ -130,7 +132,7 @@ const MenuScreenContainer = () => {

const updateMenuItem = async (id, updatedItem) => {
try {
const itemRef = doc(db, "menu-items/", id);
const itemRef = doc(db, "hotel-details/menu/menu-items", id);
await updateDoc(itemRef, updatedItem);
setMenuItems(
menuItems.map((item) =>
Expand Down
5 changes: 2 additions & 3 deletions screens/MenuScreen/MenuScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const MenuScreenView = ({
placeholder: "Cuisine",
inputMode: "default",
type: "dropdown",
options: ["Italian", "Chinese", "Indian"],
options: ["Indian", "Chinese", "Italian"],
},
{
name: "image",
Expand Down Expand Up @@ -135,7 +135,6 @@ const MenuScreenView = ({
<ThemedView style={styles.container}>
<ThemedView style={buttonStyles.buttonContainer}>
<ThemedButton
// onPress={handleAddMenuItemCategory}
onPress={() => setPopupVisible(true)}
type="primary"
style={buttonStyles.button}
Expand Down Expand Up @@ -211,7 +210,7 @@ const buttonStyles = StyleSheet.create({
},
button: {
flex: 1,
borderRadius: 0,
borderRadius: 5,
marginBottom: 5,
marginHorizontal: 2, // Optional: to add some space between buttons
},
Expand Down
25 changes: 23 additions & 2 deletions screens/StaffsScreen/StaffScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,28 @@ const formSchema = [
},
{ name: "name", placeholder: "Name", inputMode: "default", type: "text" },
{ name: "age", placeholder: "Age", inputMode: "numeric", type: "text" },
{ name: "role", placeholder: "Role", inputMode: "default", type: "text" },
{
name: "gender",
placeholder: "Gender",
inputMode: "numeric",
type: "dropdown",
options: ["Male", "Female", "Other"],
},
{
name: "role",
placeholder: "Role",
inputMode: "default",
type: "dropdown",
options: [
"Waiter",
"Cook",
"Cleaner",
"Manager",
"Helper",
"Assistant",
"Owner",
],
},
{
name: "image",
placeholder: "Image URL",
Expand Down Expand Up @@ -88,7 +109,7 @@ const StaffScreenView = ({ staffs, addStaff, deleteStaff, updateStaff }) => {
type="primary"
style={[{ borderRadius: 0, marginBottom: 5 }]}
>
<ThemedText>Add Person</ThemedText>
<ThemedText>Add Staff</ThemedText>
</ThemedButton>
<FlatList
data={filteredItems}
Expand Down
10 changes: 6 additions & 4 deletions screens/StaffsScreen/StaffsScreenContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const StaffsScreenContainer = () => {
useEffect(() => {
const fetchStaffs = async () => {
try {
const querySnapshot = await getDocs(collection(db, "staffs/"));
const querySnapshot = await getDocs(
collection(db, "hotel-details/staff-details/staffs")
);
const items = querySnapshot.docs.map((doc) => ({
id: doc.id,
...doc.data(),
Expand All @@ -37,7 +39,7 @@ const StaffsScreenContainer = () => {

items.forEach((item) => {
item.searchableKey = generateUniqueKey(staffs, item);
const docRef = doc(collection(db, "staffs/"));
const docRef = doc(collection(db, "hotel-details/staff-details/staffs"));
batch.set(docRef, item);
newItems.push({ ...item, id: docRef.id });
});
Expand All @@ -57,7 +59,7 @@ const StaffsScreenContainer = () => {

const deleteStaff = async (id) => {
try {
await deleteDoc(doc(db, "staffs/", id));
await deleteDoc(doc(db, "hotel-details/staff-details/staffs", id));
setStaffs(staffs.filter((item) => item.id !== id));
console.log("Document successfully deleted!");
} catch (error) {
Expand All @@ -67,7 +69,7 @@ const StaffsScreenContainer = () => {

const updateStaff = async (id, updatedItem) => {
try {
const itemRef = doc(db, "staffs/", id);
const itemRef = doc(db, "hotel-details/staff-details/staffs", id);
await updateDoc(itemRef, updatedItem);
setStaffs(
staffs.map((item) =>
Expand Down

0 comments on commit f39ef9d

Please sign in to comment.