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">
{user.firstName} {user.lastName}
</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 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="flex-1">{user.email || "brak danych"}</Text>
</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 className="bg-white mt-4 p-5">
@@ -91,15 +91,15 @@ export default function Account() {
</Pressable>
</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>▶</Text>
</Pressable>
</Pressable> */}
</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>
</Pressable>
</Pressable> */}
</VStack>
);
}

View File

@@ -7,12 +7,14 @@ import { Text } from "@/components/ui/text";
import { useEffect } from "react";
export default function Wishlist() {
const wishlistNotices = useWishlist((state) => state.wishlistNotices);
const wishlistNotices = useWishlist((state) => state.wishlistNotices);
const fetchWishlist = useWishlist((state) => state.fetchWishlist);
useEffect(() => {
fetchWishlist();
}, []);
// console.log("Wishlist notices:", wishlistNotices);
if (wishlistNotices.length === 0) {
return (
<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(
persist(
(set) => {
(set, get) => {
// Dodaj interceptor tylko raz
if (!axios.interceptors.response.handlers.length) {
axios.interceptors.response.use(
@@ -17,7 +17,7 @@ export const useAuthStore = create(
(error.response && error.response.status === 401) ||
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"];
}
return Promise.reject(error);
@@ -113,24 +113,24 @@ export const useAuthStore = create(
}
},
checkAuth: async () => {
const { token } = useAuthStore.getState();
if (!token) return null;
// checkAuth: async () => {
// const { token } = useAuthStore.getState();
// if (!token) return null;
set({ isLoading: true });
try {
axios.defaults.headers.common["Authorization"] = `Bearer ${token}`;
// set({ isLoading: true });
// try {
// 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 });
return response.data;
} catch (error) {
delete axios.defaults.headers.common["Authorization"];
set({ user_id: null, token: null, isLoading: false });
return null;
}
},
// set({ user_id: response.data, isLoading: false });
// return response.data;
// } catch (error) {
// delete axios.defaults.headers.common["Authorization"];
// set({ user_id: null, token: null, isLoading: false });
// return null;
// }
// },
};
},
{