diff --git a/donutshop/app/components/HomeCardItem.tsx b/donutshop/app/components/HomeCardItem.tsx
new file mode 100644
index 0000000..395c52d
--- /dev/null
+++ b/donutshop/app/components/HomeCardItem.tsx
@@ -0,0 +1,59 @@
+import { StyleSheet, Text, View, Pressable, Image} from 'react-native'
+import React from 'react'
+import { useNavigation } from '@react-navigation/native';
+
+
+
+const HomeCardItem = () => {
+ const navigation = useNavigation();
+
+ return (
+
+
+
+
+
+
+ Pokémon Donuts(Coming soon)
+ The limited-edition Pokémon Donuts is coming soon!
+
+
+
+
+
+
+ navigation.navigate('menu')}>
+
+
+
+ Mothers Day Box for your mama
+ Lets show our appreciation for our moms by treating them with the special Mothers Day Box!
+ navigation.navigate('menu')} style={{marginTop: 10, padding: 10, backgroundColor: '#DA7297', width: 100, borderRadius: 5, alignItems: 'center'}}>
+ Order Now
+
+
+
+
+
+
+
+ navigation.navigate('menu')}>
+
+
+
+ Colorful Smoothies are here
+ The colors are not due to artificial colorings, but rather from natural fruits and vegetables
+ navigation.navigate('menu')} style={{marginTop: 10, padding: 10, backgroundColor: '#DA7297', width: 100, borderRadius: 5, alignItems: 'center'}}>
+ Order Now
+
+
+
+
+
+
+ )
+}
+
+export default HomeCardItem
+
+const styles = StyleSheet.create({})
\ No newline at end of file
diff --git a/donutshop/app/components/OrderReceiptCard.tsx b/donutshop/app/components/OrderReceiptCard.tsx
index b75354f..30c9b59 100644
--- a/donutshop/app/components/OrderReceiptCard.tsx
+++ b/donutshop/app/components/OrderReceiptCard.tsx
@@ -18,16 +18,9 @@ const OrderReceiptCard: React.FC = ({
}) => {
return (
-
-
-
- Order Time
- {OrderDate}
-
-
- Total Amount
- $ {CartListPrice}
-
+
+
+ {OrderDate}
@@ -51,6 +44,11 @@ const OrderReceiptCard: React.FC = ({
))}
+
+
+ Total Amount
+ $ {CartListPrice}
+
)
}
diff --git a/donutshop/app/components/OrderReceiptItem.tsx b/donutshop/app/components/OrderReceiptItem.tsx
index 78553b1..e66450b 100644
--- a/donutshop/app/components/OrderReceiptItem.tsx
+++ b/donutshop/app/components/OrderReceiptItem.tsx
@@ -27,7 +27,7 @@ const OrderReceiptItem: React.FC = ({
{prices.map((item: any, index: any) => (
- {name || donutname} {item.size}
+ {name || donutname} {item.size}
))}
diff --git a/donutshop/app/screen/Detail.tsx b/donutshop/app/screen/Detail.tsx
index d29543c..d439062 100644
--- a/donutshop/app/screen/Detail.tsx
+++ b/donutshop/app/screen/Detail.tsx
@@ -10,7 +10,7 @@ import { TouchableWithoutFeedback } from 'react-native-gesture-handler';
const Detail = ({navigation, route}: any) => {
const ItemOfIndex = useStore((state: any) =>
- route.params.type == 'Donut' ? state.AllDonutList2 : state.AllDrinkList2,
+ route.params.type == 'Donut' ? state.AllDonutMenu : state.AllDrinkMenu,
)[route.params.index];
const addToFavoriteList = useStore((state: any) => state.addToFavoriteList);
diff --git a/donutshop/app/screen/DetailDrink.tsx b/donutshop/app/screen/DetailDrink.tsx
index b15aace..a9a3c40 100644
--- a/donutshop/app/screen/DetailDrink.tsx
+++ b/donutshop/app/screen/DetailDrink.tsx
@@ -9,7 +9,7 @@ import PaymentFooter from "../components/PaymentFooter";
const DetailDrink = ({navigation, route}: any) => {
const ItemOfIndex = useStore((state: any) =>
- route.params.type == 'Donut' ? state.AllDonutList2 : state.AllDrinkList2,
+ route.params.type == 'Donut' ? state.AllDonutMenu : state.AllDrinkMenu,
)[route.params.index];
const addToFavoriteList = useStore((state: any) => state.addToFavoriteList);
diff --git a/donutshop/app/screen/Home.tsx b/donutshop/app/screen/Home.tsx
index b6390e5..fdc8d6c 100644
--- a/donutshop/app/screen/Home.tsx
+++ b/donutshop/app/screen/Home.tsx
@@ -1,6 +1,7 @@
-import { View, Text, ScrollView, StyleSheet } from 'react-native'
+import { View, Text, ScrollView, StyleSheet, Image, Pressable } from 'react-native'
import React from 'react'
import HomeHeader from '../components/HomeHeader'
+import HomeCardItem from '../components/HomeCardItem'
import { StatusBar } from 'expo-status-bar';
const Home = () => {
@@ -10,6 +11,7 @@ const Home = () => {
+
)
diff --git a/donutshop/app/screen/Menu.tsx b/donutshop/app/screen/Menu.tsx
index be9e0b3..d902063 100644
--- a/donutshop/app/screen/Menu.tsx
+++ b/donutshop/app/screen/Menu.tsx
@@ -1,4 +1,4 @@
-import { View, Text, ScrollView, StyleSheet, Pressable, Dimensions, ToastAndroid} from 'react-native'
+import { View, Text, ScrollView, StyleSheet, Pressable, Dimensions} from 'react-native'
import React, { useState } from 'react'
import { useStore } from '../store/store';
import { useBottomTabBarHeight } from '@react-navigation/bottom-tabs';
@@ -32,8 +32,8 @@ const getDonutList = (category: string, data: any) => {
const Menu = ({navigation}: any) => {
- const DonutList = useStore((state: any) => state.AllDonutList2);
- const DrinkList = useStore((state: any) => state.AllDrinkList2);
+ const DonutList = useStore((state: any) => state.AllDonutMenu);
+ const DrinkList = useStore((state: any) => state.AllDrinkMenu);
const [categories, setCategories] = useState(getCategoriesFromData(DonutList));
const [searchMenu, setSearchMenu] = useState('');
diff --git a/donutshop/app/store/store.ts b/donutshop/app/store/store.ts
index e5c91e1..9a04af2 100644
--- a/donutshop/app/store/store.ts
+++ b/donutshop/app/store/store.ts
@@ -8,8 +8,8 @@ import DrinkData from "../data/DrinkData";
export const useStore = create(
persist(
(set, get) => ({
- AllDonutList1: DonutData,
- AllDrinkList: DrinkData,
+ AllDonutMenu: DonutData,
+ AllDrinkMenu: DrinkData,
CartPrice: 0,
FavoriteList: [],
CartList: [],
@@ -68,25 +68,25 @@ export const useStore = create(
set(
produce(state => {
if(type == 'Donut'){
- for(let i = 0; i < state.AllDonutList1.length; i++){
- if(state.AllDonutList1[i].id == id){
- if(state.AllDonutList1[i].favourite == false){
- state.AllDonutList1[i].favourite = true;
- state.FavoriteList.unshift(state.AllDonutList1[i]);
+ for(let i = 0; i < state.AllDonutMenu.length; i++){
+ if(state.AllDonutMenu[i].id == id){
+ if(state.AllDonutMenu[i].favourite == false){
+ state.AllDonutMenu[i].favourite = true;
+ state.FavoriteList.unshift(state.AllDonutMenu[i]);
} else{
- state.AllDonutList1[i].favourite = false;
+ state.AllDonutMenu[i].favourite = false;
}
break;
}
}
} else if(type == 'Drink'){
- for(let i = 0; i< state.AllDrinkList.length; i++){
- if(state.AllDrinkList[i].id == id){
- if(state.AllDrinkList[i].favourite == false){
- state.AllDrinkList[i].favourite = true;
- state.FavoriteList.unshift(state.AllDrinkList[i]);
+ for(let i = 0; i < state.AllDrinkMenu.length; i++){
+ if(state.AllDrinkMenu[i].id == id){
+ if(state.AllDrinkMenu[i].favourite == false){
+ state.AllDrinkMenu[i].favourite = true;
+ state.FavoriteList.unshift(state.AllDrinkMenu[i]);
} else{
- state.AllDrinkList[i].favourite = false;
+ state.AllDrinkMenu[i].favourite = false;
}
break;
}
@@ -98,23 +98,23 @@ export const useStore = create(
set(
produce(state => {
if(type = 'Donut'){
- for(let i = 0; i < state.AllDonutList1.length; i++){
- if(state.AllDonutList1[i].id == id){
- if(state.AllDonutList1[i].favourite == true){
- state.AllDonutList1[i].favourite = false;
+ for(let i = 0; i < state.AllDonutMenu.length; i++){
+ if(state.AllDonutMenu[i].id == id){
+ if(state.AllDonutMenu[i].favourite == true){
+ state.AllDonutMenu[i].favourite = false;
} else{
- state.AllDonutList1[i].favourite = true;
+ state.AllDonutMenu[i].favourite = true;
}
break;
}
}
} else if(type = 'Drink'){
- for(let i = 0; i < state.AllDrinkList.length; i++){
- if(state.AllDrinkList[i].id == id){
- if(state.AllDrinkList[i].favourite == true){
- state.AllDrinkList[i].favourite = false;
+ for(let i = 0; i < state.AllDrinkMenu.length; i++){
+ if(state.AllDrinkMenu[i].id == id){
+ if(state.AllDrinkMenu[i].favourite == true){
+ state.AllDrinkMenu[i].favourite = false;
} else{
- state.AllDrinkList[i].favourite = true;
+ state.AllDrinkMenu[i].favourite = true;
}
break;
}
@@ -130,6 +130,72 @@ export const useStore = create(
state.FavoriteList.splice(spliceIndex, 1);
}),
),
+ addCartItemQuantity:(id: string, size: string) =>
+ set(
+ produce(state => {
+ for(let i = 0; i < state.CartList.length; i++){
+ if(state.CartList[i].id == id){
+ for (let j = 0; j < state.CartList[i].prices.length; j++) {
+ if (state.CartList[i].prices[j].size == size) {
+ state.CartList[i].prices[j].quantity++;
+ break;
+ }
+ }
+ }
+ }
+ }),
+ ),
+ removeCartItemQuantity:(id: string, size: string) =>
+ set(
+ produce(state => {
+ for (let i = 0; i < state.CartList.length; i++) {
+ if(state.CartList[i].id == id){
+ for (let j = 0; j < state.CartList[i].prices.length; j++) {
+ if (state.CartList[i].prices[j].size == size) {
+ if(state.CartList[i].prices.length > 1){
+ if (state.CartList[i].prices[j].quantity > 1) {
+ state.CartList[i].prices[j].quantity--;
+ } else{
+ state.CartList[i].prices.splice(j, 1);
+ }
+ } else{
+ if (state.CartList[i].prices[j].quantity > 1) {
+ state.CartList[i].prices[j].quantity--;
+ } else {
+ state.CartList.splice(i, 1);
+ }
+ }
+ break
+ }
+ }
+ }
+ }
+ }),
+ ),
+ addToReceiptList:() =>
+ set(
+ produce(state => {
+ let temp = state.CartList.reduce(
+ (accumulator: number, currentValue: any) =>
+ accumulator + parseFloat(currentValue.ItemPrice),
+ 0,
+ );
+ if(state.ReceiptList.length > 0){
+ state.ReceiptList.unshift({
+ OrderDate: new Date().toDateString() + ' ' + new Date().toLocaleTimeString(),
+ CartList: state.CartList,
+ CartListPrice: temp.toFixed(2).toString(),
+ })
+ } else{
+ state.ReceiptList.push({
+ OrderDate: new Date().toDateString() + ' ' + new Date().toLocaleTimeString(),
+ CartList: state.CartList,
+ CartListPrice: temp.toFixed(2).toString(),
+ });
+ }
+ state.CartList = [];
+ }),
+ ),
}),
{
name: 'donutshop',