web client v0.5

//notifications
//delete restaurant
//change picture
//redesigned data store
This commit is contained in:
2020-09-27 18:40:39 +02:00
parent 3fdc93ef28
commit d2842a1db3
24 changed files with 810 additions and 501 deletions

View File

@@ -1,18 +0,0 @@
const appModeReducer = (state = "init", action) => {
switch (action.type) {
case "APP_INIT":
return (state = "init");
case "APP_EMPTY":
return (state = "empty");
case "APP_SEARCH_RESULTS":
return (state = "search results");
case "APP_RESTAURANT":
return (state = "restaurant");
case "APP_DISH":
return (state = "dish");
default:
return state;
}
};
export default appModeReducer;

View File

@@ -1,7 +1,6 @@
const initialState = {
showDishList: false,
loggedIn: false,
jwt: "",
username: "",
userId: "",
userEmail: "",
@@ -19,16 +18,9 @@ const initialState = {
restaurants: [],
},
dialogs: {
registerCircularProgress: false,
registerForm: true,
registerResult: "",
loginResult: "",
regulamin: false,
reminderResult: "",
reminderCircularProgress: false,
resetResult: "",
resetCircularProgress: false,
},
backdrop: false,
tempData: {},
};
@@ -74,11 +66,6 @@ const data = (state = initialState, action) => {
restaurants: [],
},
});
case "DIALOG_REGISTER_CIRCLE_SHOW":
return (state = {
...state,
dialogs: { ...state.dialogs, registerCircularProgress: true },
});
case "DIALOG_REGULAMIN_SHOW":
return (state = {
...state,
@@ -89,60 +76,28 @@ const data = (state = initialState, action) => {
...state,
dialogs: { ...state.dialogs, regulamin: false },
});
case "DIALOG_REGISTER_CIRCLE_HIDE":
return (state = {
...state,
dialogs: { ...state.dialogs, registerCircularProgress: false },
});
case "DIALOG_REGISTER_FORM_HIDE":
return (state = {
...state,
dialogs: { ...state.dialogs, registerForm: false },
});
case "DIALOG_REGISTER_SET_RESULT":
return (state = {
...state,
dialogs: { ...state.dialogs, registerResult: action.payload },
});
case "DIALOG_REMINDER_SET_RESULT":
return (state = {
...state,
dialogs: { ...state.dialogs, reminderResult: action.payload },
});
case "DIALOG_REMINDER_CIRCLE_SHOW":
return (state = {
...state,
dialogs: { ...state.dialogs, reminderCircularProgress: true },
});
case "DIALOG_REMINDER_CIRCLE_HIDE":
return (state = {
...state,
dialogs: { ...state.dialogs, reminderCircularProgress: false },
});
case "DIALOG_RESET_CIRCLE_SHOW":
return (state = {
...state,
dialogs: { ...state.dialogs, resetCircularProgress: true },
});
case "DIALOG_RESET_CIRCLE_HIDE":
return (state = {
...state,
dialogs: { ...state.dialogs, resetCircularProgress: false },
});
case "DIALOG_LOGIN_SET_RESULT":
return (state = {
...state,
dialogs: { ...state.dialogs, loginResult: action.payload },
});
case "DIALOG_RESET_SET_RESULT":
return (state = {
...state,
dialogs: { ...state.dialogs, resetResult: action.payload },
});
case "SET_TEMP_DATA":
return (state = { ...state, tempData: action.payload });
case "CLEAR_TEMP_DATA":
return (state = { ...state, tempData: {} });
case "SHOW_BACKDROP":
return (state = { ...state, backdrop: true });
case "HIDE_BACKDROP":
return (state = { ...state, backdrop: false });
case "UPDATE_RESTAURANT":
return (state = {
...state,
userData: {
...state.userData,
restaurants: state.userData.restaurants.map((restaurant) => {
if (restaurant._id === action.payload._id) {
return action.payload;
} else {
return restaurant;
}
}),
},
});
default:
return state;
}

View File

@@ -2,22 +2,22 @@ import { combineReducers } from "redux";
import { connectRouter } from "connected-react-router";
import autoCompleteReducer from "./autoComplete";
import searchResults from "./searchResults";
import appMode from "./appMode";
import searchQuery from "./searchQuery";
import restaurant from "./restaurant";
import dishes from "./dishes";
import data from "./data";
import notifications from "./notifications";
const rootReducer = (history) =>
combineReducers({
router: connectRouter(history),
autocomplete: autoCompleteReducer,
appMode: appMode,
searchResults: searchResults,
searchQuery: searchQuery,
restaurant: restaurant,
dishes: dishes,
data: data,
notifications: notifications,
});
export default rootReducer;

View File

@@ -0,0 +1,12 @@
const notifications = (state = [], action) => {
switch (action.type) {
case "ENQUEUE_SNACKBAR":
return [...state, { key: action.key, ...action.notification }];
case "REMOVE_SNACKBAR":
return state.filter((notification) => notification.key !== action.key);
default:
return state;
}
};
export default notifications;