Redirect once done adding new product

This commit is contained in:
Keannu Christian Bernasol 2023-03-06 15:38:21 +08:00
parent 325fbf87db
commit 2dedfdbe04
7 changed files with 137 additions and 59 deletions

View file

@ -6,11 +6,7 @@ import {
LoginParams,
RegistrationParams,
} from "../../Interfaces/Interfaces";
import { useDispatch } from "react-redux";
import { SetUser } from "../../Features/Redux/Slices/LoggedInUserSlice/LoggedInUserSlice";
import { toggle_login } from "../../Features/Redux/Slices/Login/LoginSlice";
// Note APIs
// Product APIs
export function GetProducts() {
const token = JSON.parse(localStorage.getItem("token") || "{}");
@ -25,7 +21,7 @@ export function GetProducts() {
});
}
export function GetNote(id: number) {
export function GetProduct(id: number) {
const token = JSON.parse(localStorage.getItem("token") || "{}");
return axios
.get("http://localhost:8000/api/v1/products/" + id + "/", {
@ -156,7 +152,8 @@ export async function CheckSavedSession() {
console.log("Previous session found");
return true;
} else {
console.log("Previous session found but expired");
console.log("Previous session found but expired. Clearing token");
localStorage.removeItem("token");
return false;
}
}