JWT refresh

This commit is contained in:
2020-11-29 20:23:20 +01:00
parent e48d300ca9
commit 6d02533d69
18 changed files with 69 additions and 22 deletions

View File

@@ -33,6 +33,7 @@ export default function Dish(props) {
})
.catch((err) => {
console.log(err);
throw err;
});
}, [id]);

View File

@@ -316,7 +316,7 @@ export default function EditDish() {
.then((response) => {
dispatch(hideBackdrop());
dispatch(notification("Danie zmienione.", "success"));
dispatch(refreshUserData(token));
dispatch(refreshUserData());
history.push(`/dish/${dish._id}`);
})
.catch((error) => {
@@ -324,6 +324,7 @@ export default function EditDish() {
dispatch(
notification("Wystąpił nieoczekiwany błąd, przepraszamy.", "error")
);
throw error;
});
};

View File

@@ -318,7 +318,7 @@ export default function NewRestaurant() {
.then((response) => {
dispatch(hideBackdrop());
dispatch(notification("Danie dodane pomyślnie.", "success"));
dispatch(refreshUserData(token));
dispatch(refreshUserData());
history.push(`/editRestaurant/${restaurantID}`);
})
.catch((error) => {
@@ -329,6 +329,7 @@ export default function NewRestaurant() {
"error"
)
);
throw error;
});
};

View File

@@ -202,7 +202,7 @@ export default function NewRestaurant() {
"success"
)
);
dispatch(refreshUserData(token));
dispatch(refreshUserData());
history.push("/");
})
.catch((error) => {
@@ -215,6 +215,7 @@ export default function NewRestaurant() {
)
);
history.push("/");
throw error;
});
};

View File

@@ -173,7 +173,7 @@ export default function EditRestaurantInfo(props) {
},
})
.then((response) => {
dispatch(refreshUserData(jwt));
dispatch(refreshUserData());
setState({ ...state, hidden: !state.hidden });
dispatch(hideBackdrop());
dispatch(notification("Widoczność zmieniona poprawnie", "success"));
@@ -182,6 +182,7 @@ export default function EditRestaurantInfo(props) {
console.log(err);
dispatch(hideBackdrop());
dispatch(notification("Wystąpił błąd :(", "error"));
throw err;
});
}
@@ -200,7 +201,7 @@ export default function EditRestaurantInfo(props) {
},
})
.then((response) => {
dispatch(refreshUserData(jwt));
dispatch(refreshUserData());
dispatch(hideBackdrop());
dispatch(notification("Restauracja została usunięta", "success"));
history.push("/");
@@ -209,6 +210,7 @@ export default function EditRestaurantInfo(props) {
console.log(err);
dispatch(hideBackdrop());
dispatch(notification("Wystąpił nieoczekiwany błąd :(", "error"));
throw err;
});
};
@@ -257,6 +259,7 @@ export default function EditRestaurantInfo(props) {
console.log(err);
dispatch(hideBackdrop());
dispatch(notification("Wystąpił nieoczekiwany błąd :(", "error"));
throw err;
});
}
};

View File

@@ -67,6 +67,7 @@ export default function EditRestaurantLocation(props) {
.catch((e) => {
dispatch(hideBackdrop());
dispatch(notification("Nie udało się zmienić lokalizacji :(", "error"));
throw e;
});
};

View File

@@ -69,11 +69,12 @@ export default function EditRestaurantMenu(props) {
.then((res) => {
dispatch(hideBackdrop());
dispatch(notification("Dodano kategorię.", "success"));
dispatch(refreshUserData(token));
dispatch(refreshUserData());
})
.catch((e) => {
dispatch(hideBackdrop());
dispatch(notification("Nie udało się dodać kategorii :(", "error"));
throw e;
});
}
};
@@ -96,11 +97,12 @@ export default function EditRestaurantMenu(props) {
.then((res) => {
dispatch(hideBackdrop());
dispatch(notification("Usunięto kategorię.", "success"));
dispatch(refreshUserData(token));
dispatch(refreshUserData());
})
.catch((e) => {
dispatch(hideBackdrop());
dispatch(notification("Nie udało się usunąć kategorii :(", "error"));
throw e;
});
};

View File

@@ -60,11 +60,12 @@ export default function EditRestaurantPhoto(props) {
.then((res) => {
dispatch(hideBackdrop());
dispatch(notification("Zmieniono zdjęcie.", "success"));
dispatch(refreshUserData(token));
dispatch(refreshUserData());
})
.catch((e) => {
dispatch(hideBackdrop());
dispatch(notification("Nie udało się zmienić zdjęcia :(", "error"));
throw e;
});
};
return (

View File

@@ -55,6 +55,7 @@ export default function EditRestaurantSubscription(props) {
.catch((error) => {
dispatch(hideBackdrop());
dispatch(notification("Wystąpił błąd, spróbuj ponownie.", "error"));
throw error;
});
};
@@ -63,7 +64,7 @@ export default function EditRestaurantSubscription(props) {
};
const onAccept = () => {
dispatch(refreshUserData(token));
dispatch(refreshUserData());
openInNewTab("https://secure.przelewy24.pl/trnRequest/0");
};

View File

@@ -159,11 +159,12 @@ export default function EditCategoriesList(props) {
.then((response) => {
dispatch(hideBackdrop());
dispatch(notification("Zmieniono zestaw.", "success"));
dispatch(refreshUserData(token));
dispatch(refreshUserData());
})
.catch((error) => {
dispatch(hideBackdrop());
dispatch(notification("Wystąpił błąd.", "error"));
throw error;
});
} else {
dispatch(notification("Popraw dane.", "error"));

View File

@@ -30,6 +30,7 @@ export default function ImageUpload(props) {
.catch((error) => {
console.log("Wystąpił błąd podczas wgrywania pliku.");
setLoading(false);
throw error;
});
};

View File

@@ -30,6 +30,7 @@ export default function ImageUpload(props) {
.catch((error) => {
console.log("Wystąpił błąd podczas wgrywania pliku.");
setLoading(false);
throw error;
});
};

View File

@@ -110,7 +110,7 @@ export default function EditDishList(props) {
.then((response) => {
dispatch(hideBackdrop());
dispatch(notification("Dodano do zestawu.", "success"));
dispatch(refreshUserData(token));
dispatch(refreshUserData());
})
.catch((error) => {
dispatch(hideBackdrop());

View File

@@ -59,7 +59,7 @@ export default function EditDishList(props) {
.then((response) => {
dispatch(hideBackdrop());
dispatch(notification("Zmodyfikowano zestaw.", "success"));
dispatch(refreshUserData(token));
dispatch(refreshUserData());
})
.catch((error) => {
dispatch(hideBackdrop());