This commit is contained in:
KS Jannette
2026-03-29 07:02:20 -04:00
parent 1418e7f97c
commit 9d2a0678be

View File

@@ -1,38 +1,32 @@
import { useReducer } from "react"
const UserAuthContext = createContext();
export const initialState = {
user: null,
tier: null,
authUser: null,
AuthTier: null
};
const shopReducer = (state, action) => {
const { name, payload } = action;
const authReducer = (state, action) => {
const { type, payload = "FREE_TIER" } = action
switch (type) {
case "ADD_TO_CART":
console.log("ADD_TO_CART", payload);
case "ADD_AUTH_USER":
console.log("ADD_AUTH_USER", payload);
return {
...state,
products: payload.products
};
case "REMOVE_FROM_CART":
console.log("REMOVE_FROM_CART", payload);
return {
...state,
products: payload.products
};
case "UPDATE_PRICE":
console.log("UPDATE_PRICE", payload);
return {
...state,
total: payload.total
auth: payload
};
default:
throw new Error(`No case for type ${type} found in shopReducer.`);
throw new Error(`No case for type ${type} found.`);
}
};
switch (type) {
case "DELETE_AUTH_USER":
return {
...state,
users: state.users.filter(user => user.id !== action.userIdToDelete)
};
}
}
export default shopReducer;
export default shopReducer