Skip to content

Commit

Permalink
Added Donation list tab in navigation bar that lets you view items in…
Browse files Browse the repository at this point in the history
… donation cart with chnage quantity and remove item functionalities
  • Loading branch information
Neha Rao authored and Neha Rao committed Oct 19, 2021
1 parent ef7bff9 commit 1630c7e
Show file tree
Hide file tree
Showing 8 changed files with 469 additions and 23,599 deletions.
Binary file added Archive.zip
Binary file not shown.
24 changes: 24 additions & 0 deletions navigation/DonorStack/DonationList/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { createStackNavigator } from '@react-navigation/stack';
import * as React from 'react';
import DonationListScreen from '../../../screens/DonationList';
// import DonationScreen from '../../../screens/DonationScreen';

import {
DonationScreenParamList,
} from '../DonationList/types';

const DonationListScreenStack = createStackNavigator();

function DonationListScreenNavigator() {
return (
<DonationListScreenStack.Navigator>
<DonationListScreenStack.Screen
name="DonationScreen"
component={DonationListScreen}
options={{ headerTitle: 'Donation List Screen' }}
/>
</DonationListScreenStack.Navigator>
);
}

export default DonationListScreenNavigator;
3 changes: 3 additions & 0 deletions navigation/DonorStack/DonationList/types.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type DonationScreenParamList = {
DonationScreen: undefined;
};
8 changes: 8 additions & 0 deletions navigation/MainNavBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import MapScreenNavigator from '../AdminStack/Map';
import DonationScreenNavigator from '../DonorStack/DonationForm';
import DonationsListNavigator from '../AdminStack/DonationList';
import ProfileNavigator from '../SharedStack/UserProfile';
import DonationListScreenNavigator from '../DonorStack/DonationList';

import {
BottomTabParamList,
Expand Down Expand Up @@ -46,6 +47,13 @@ function DonorTabs() {
tabBarIcon: ({ color }) => <MaterialCommunityIcons name="hand-heart" size={30} color={color} style={{ marginBottom: -3 }} />,
}}
/>
<BottomTab.Screen
name="Donation List"
component={DonationListScreenNavigator}
options={{
tabBarIcon: ({ color }) => <MaterialCommunityIcons name="cart" size={30} color={color} style={{ marginBottom: -3 }} />,
}}
/>
<BottomTab.Screen
name="Me"
component={ProfileNavigator}
Expand Down
23,626 changes: 29 additions & 23,597 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"react-native-geolocation-service": "^5.2.0",
"react-native-gesture-handler": "~1.8.0",
"react-native-maps": "0.27.1",
"react-native-paper": "^4.9.2",
"react-native-safe-area-context": "3.1.9",
"react-native-screens": "~2.15.0",
"react-native-svg": "12.1.0",
Expand Down
25 changes: 23 additions & 2 deletions redux/reducers/donationCartReducer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const initialState = {
ongoing: false,
status: '',
imageLink: '',
dishes: [],
dishes: [{ dishID: 'asd', quantity: 2, _id: `${Math.random()}` }],
pickupAddress: {
streetAddress: '',
buildingNumber: 0,
Expand All @@ -31,9 +31,30 @@ const donationCartReducer = createSlice({
reducers: {
addToCart(state, action: PayloadAction<DonationDishes>) {
state.dishes.push(action.payload);
},
setDonationList(state, action) {
state.dishes = [].concat(action.payload);
},
getDonationList(state) {
return state;
},
deleteDonationList(state: any, action) {
const list = state.dishes.filter((f: any) => f._id !== action.payload._id);
state.dishes = list;
},
updateQty(state: any, action) {
const item = state.dishes.filter((f: any) => f._id === action.payload.item._id)[0];
const list = state.dishes;
for (let index = 0; index < list.length; index += 1) {
if (list[index]._id === item._id) {
list[index].quantity = action.payload.quantity;
}
}
state.dishes = list;
console.log(item);
}
},
});

export const { addToCart } = donationCartReducer.actions;
export const { addToCart, setDonationList, getDonationList, deleteDonationList, updateQty } = donationCartReducer.actions;
export default donationCartReducer.reducer;
Loading

0 comments on commit 1630c7e

Please sign in to comment.