fix account

This commit is contained in:
Patryk
2025-06-08 09:37:50 +02:00
parent 717dd32543
commit c39f9c383e
3 changed files with 31 additions and 29 deletions

View File

@@ -55,13 +55,6 @@ export default function Account() {
<Text className="text-2xl font-bold text-center mb-1"> <Text className="text-2xl font-bold text-center mb-1">
{user.firstName} {user.lastName} {user.firstName} {user.lastName}
</Text> </Text>
<Pressable
className="border border-[#002f34] rounded-md py-2 px-4 self-center"
onPress={() => console.log("Edytuj dane użytkownika")}
>
<Text className="text-[#002f34] font-medium">Edytuj profil</Text>
</Pressable>
</Box> </Box>
<Box className="bg-white mt-4 p-5 border-t border-b border-gray-200"> <Box className="bg-white mt-4 p-5 border-t border-b border-gray-200">
@@ -71,6 +64,13 @@ export default function Account() {
<Text className="text-gray-600 w-24">E-mail</Text> <Text className="text-gray-600 w-24">E-mail</Text>
<Text className="flex-1">{user.email || "brak danych"}</Text> <Text className="flex-1">{user.email || "brak danych"}</Text>
</HStack> </HStack>
<Pressable
className="border border-[#002f34] rounded-md py-2 px-4 self-start"
onPress={() => console.log("Edytuj dane użytkownika")}
>
<Text className="text-[#002f34] font-medium">Edytuj profil</Text>
</Pressable>
</Box> </Box>
<Box className="bg-white mt-4 p-5"> <Box className="bg-white mt-4 p-5">
@@ -91,15 +91,15 @@ export default function Account() {
</Pressable> </Pressable>
</Link> </Link>
<Pressable className="py-3 flex-row items-center"> {/* <Pressable className="py-3 flex-row items-center">
<Text className="text-lg flex-1">Ustawienia powiadomień</Text> <Text className="text-lg flex-1">Ustawienia powiadomień</Text>
<Text>▶</Text> <Text>▶</Text>
</Pressable> </Pressable> */}
</Box> </Box>
<Pressable className="mt-8 mx-5 p-4 bg-white rounded-md items-center shadow-sm"> {/* <Pressable className="mt-8 mx-5 p-4 bg-white rounded-md items-center shadow-sm">
<Text className="text-red-500 font-medium">Wyloguj się</Text> <Text className="text-red-500 font-medium">Wyloguj się</Text>
</Pressable> </Pressable> */}
</VStack> </VStack>
); );
} }

View File

@@ -7,12 +7,14 @@ import { Text } from "@/components/ui/text";
import { useEffect } from "react"; import { useEffect } from "react";
export default function Wishlist() { export default function Wishlist() {
const wishlistNotices = useWishlist((state) => state.wishlistNotices); const wishlistNotices = useWishlist((state) => state.wishlistNotices);
const fetchWishlist = useWishlist((state) => state.fetchWishlist); const fetchWishlist = useWishlist((state) => state.fetchWishlist);
useEffect(() => { useEffect(() => {
fetchWishlist(); fetchWishlist();
}, []); }, []);
// console.log("Wishlist notices:", wishlistNotices);
if (wishlistNotices.length === 0) { if (wishlistNotices.length === 0) {
return ( return (
<Box className="flex-row flex-1 justify-center"> <Box className="flex-row flex-1 justify-center">

View File

@@ -7,7 +7,7 @@ const API_URL = "https://hopp.zikor.pl/api/v1";
export const useAuthStore = create( export const useAuthStore = create(
persist( persist(
(set) => { (set, get) => {
// Dodaj interceptor tylko raz // Dodaj interceptor tylko raz
if (!axios.interceptors.response.handlers.length) { if (!axios.interceptors.response.handlers.length) {
axios.interceptors.response.use( axios.interceptors.response.use(
@@ -17,7 +17,7 @@ export const useAuthStore = create(
(error.response && error.response.status === 401) || (error.response && error.response.status === 401) ||
error.response.status === 403 error.response.status === 403
) { ) {
set({ user_id: null, token: null, isLoading: false }); set({ user: null, token: null, isLoading: false });
delete axios.defaults.headers.common["Authorization"]; delete axios.defaults.headers.common["Authorization"];
} }
return Promise.reject(error); return Promise.reject(error);
@@ -113,24 +113,24 @@ export const useAuthStore = create(
} }
}, },
checkAuth: async () => { // checkAuth: async () => {
const { token } = useAuthStore.getState(); // const { token } = useAuthStore.getState();
if (!token) return null; // if (!token) return null;
set({ isLoading: true }); // set({ isLoading: true });
try { // try {
axios.defaults.headers.common["Authorization"] = `Bearer ${token}`; // axios.defaults.headers.common["Authorization"] = `Bearer ${token}`;
const response = await axios.get(`${API_URL}/auth/me`); // const response = await axios.get(`${API_URL}/auth/me`);
set({ user_id: response.data, isLoading: false }); // set({ user_id: response.data, isLoading: false });
return response.data; // return response.data;
} catch (error) { // } catch (error) {
delete axios.defaults.headers.common["Authorization"]; // delete axios.defaults.headers.common["Authorization"];
set({ user_id: null, token: null, isLoading: false }); // set({ user_id: null, token: null, isLoading: false });
return null; // return null;
} // }
}, // },
}; };
}, },
{ {