Update frontend
This commit is contained in:
@@ -20,12 +20,12 @@ export default function LoginPage() {
|
||||
e.preventDefault();
|
||||
setError("");
|
||||
|
||||
const res = await fetchData("https://internal-api.inboxi.ng/api/auth/login", {
|
||||
const res = await fetchData("http://localhost:3001/api/auth/login", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ username, password }),
|
||||
});
|
||||
|
||||
|
||||
if (res.token) {
|
||||
document.cookie = `Authorization=${res.token}; path=/; Secure; SameSite=Strict; max-age=604800`;
|
||||
router.push("/dashboard");
|
||||
|
||||
@@ -141,7 +141,6 @@ export default function ProductsPage() {
|
||||
await saveProductImage(`${process.env.NEXT_PUBLIC_API_URL}/products/${savedProduct._id}/image`, file, authToken);
|
||||
}
|
||||
|
||||
// Update state with the saved product
|
||||
setProducts((prevProducts) => {
|
||||
if (editing) {
|
||||
return prevProducts.map((product) =>
|
||||
|
||||
@@ -40,7 +40,7 @@ export const saveProductImage = async(url: string, file:File, authToken: string)
|
||||
formData.append("file", file);
|
||||
|
||||
return await fetchData(url, {
|
||||
method: "POST",
|
||||
method: "PUT",
|
||||
headers: {
|
||||
Authorization: `Bearer ${authToken}`,
|
||||
//"Content-Type": "multipart/form-data",
|
||||
|
||||
Reference in New Issue
Block a user