Compare commits
8 Commits
c2d4f5fb79
...
a04ef906cd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a04ef906cd | ||
|
|
a51345fd93 | ||
| 7ec883100f | |||
| c25495ba3f | |||
| be51f1e9cc | |||
| 14bd178f84 | |||
| 7fc1312ddc | |||
| 1d3cbeef3a |
@@ -13,6 +13,6 @@ export async function listCategories() {
|
|||||||
});
|
});
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Nie udało się pobrać listy kategorii.", err.response.status);
|
// console.error("Nie udało się pobrać listy kategorii.", err.response.status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,9 @@ export async function getUserById(userId) {
|
|||||||
const { token } = useAuthStore.getState();
|
const { token } = useAuthStore.getState();
|
||||||
const headers = token ? { Authorization: `Bearer ${token}` } : {};
|
const headers = token ? { Authorization: `Bearer ${token}` } : {};
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(
|
const response = await axios.get(`${API_URL}/clients/get/${userId}`, {
|
||||||
`${API_URL}/clients/get/${userId}`,
|
headers: headers,
|
||||||
headers
|
});
|
||||||
);
|
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(
|
console.error(
|
||||||
|
|||||||
30
ArtisanConnect/api/email.jsx
Normal file
30
ArtisanConnect/api/email.jsx
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import { useAuthStore } from "@/store/authStore";
|
||||||
|
|
||||||
|
const API_URL = "https://hopp.zikor.pl/api/v1";
|
||||||
|
|
||||||
|
export const sendEmail = async (emailData) => {
|
||||||
|
const token = useAuthStore.getState().token;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(`${API_URL}/email/send`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
...(token && { Authorization: `Bearer ${token}` }),
|
||||||
|
},
|
||||||
|
body: JSON.stringify(emailData),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorMessage = `HTTP error! Status: ${response.status}`;
|
||||||
|
console.error("Error przy wysyłaniu maila", errorMessage);
|
||||||
|
return { success: false, error: errorMessage };
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await response.text();
|
||||||
|
return { success: true, result };
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error przy wysyłaniu maila:", error.message);
|
||||||
|
return { success: false, error: error.message };
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
"scheme": "com.hamx.artisanconnect",
|
"scheme": "com.hamx.artisanconnect",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"orientation": "portrait",
|
"orientation": "portrait",
|
||||||
"icon": "./assets/icon.png",
|
"icon": "./assets/AppIco.png",
|
||||||
"userInterfaceStyle": "light",
|
"userInterfaceStyle": "light",
|
||||||
"newArchEnabled": true,
|
"newArchEnabled": true,
|
||||||
"splash": {
|
"splash": {
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export default function UserNotices() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
loadNotices();
|
loadNotices();
|
||||||
}, []);
|
}, [fetchNotices]);
|
||||||
|
|
||||||
const showNewToast = (title) => {
|
const showNewToast = (title) => {
|
||||||
const newId = Math.random();
|
const newId = Math.random();
|
||||||
|
|||||||
@@ -15,15 +15,15 @@ export default function Home() {
|
|||||||
const [isReady, setIsReady] = useState(false);
|
const [isReady, setIsReady] = useState(false);
|
||||||
const fetchNotices = useNoticesStore((state) => state.fetchNotices);
|
const fetchNotices = useNoticesStore((state) => state.fetchNotices);
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
setIsReady(true);
|
// setIsReady(true);
|
||||||
}, []);
|
// }, []);
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
if (isReady && !token) {
|
// if (isReady && !token) {
|
||||||
router.replace("/login");
|
// router.replace("/login");
|
||||||
}
|
// }
|
||||||
}, [isReady, token, router]);
|
// }, [isReady, token, router]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (token) {
|
if (token) {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ return (
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
||||||
|
<Stack.Screen name="user" options={{ headerShown: false }} />
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="(auth)/login"
|
name="(auth)/login"
|
||||||
options={{ headerShown: false }}/>
|
options={{ headerShown: false }}/>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import {Link, Stack, useLocalSearchParams} from "expo-router";
|
import { Link, Stack, useLocalSearchParams } from "expo-router";
|
||||||
import {Box} from "@/components/ui/box";
|
import { Box } from "@/components/ui/box";
|
||||||
import {Card} from "@/components/ui/card";
|
import { Card } from "@/components/ui/card";
|
||||||
import {Heading} from "@/components/ui/heading";
|
import { Heading } from "@/components/ui/heading";
|
||||||
import {Image} from "@/components/ui/image";
|
import { Image } from "@/components/ui/image";
|
||||||
import {Text} from "@/components/ui/text";
|
import { Text } from "@/components/ui/text";
|
||||||
import {VStack} from "@/components/ui/vstack";
|
import { VStack } from "@/components/ui/vstack";
|
||||||
import {Ionicons} from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
import {
|
import {
|
||||||
ActivityIndicator,
|
ActivityIndicator,
|
||||||
Dimensions,
|
Dimensions,
|
||||||
@@ -13,16 +13,16 @@ import {
|
|||||||
View,
|
View,
|
||||||
TextInput,
|
TextInput,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
import {useEffect, useState, useRef} from "react";
|
import { useEffect, useState, useRef } from "react";
|
||||||
import {useNoticesStore} from "@/store/noticesStore";
|
import { useNoticesStore } from "@/store/noticesStore";
|
||||||
import {useWishlist} from "@/store/wishlistStore";
|
import { useWishlist } from "@/store/wishlistStore";
|
||||||
import {Pressable, ScrollView} from "react-native";
|
import { Pressable, ScrollView } from "react-native";
|
||||||
import {getUserById} from "@/api/client";
|
import { getUserById } from "@/api/client";
|
||||||
|
|
||||||
const {width} = Dimensions.get("window");
|
const { width } = Dimensions.get("window");
|
||||||
|
|
||||||
export default function NoticeDetails() {
|
export default function NoticeDetails() {
|
||||||
const {id} = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
const [images, setImages] = useState([]);
|
const [images, setImages] = useState([]);
|
||||||
const [isImageLoading, setIsImageLoading] = useState(true);
|
const [isImageLoading, setIsImageLoading] = useState(true);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
@@ -55,7 +55,7 @@ export default function NoticeDetails() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const {getNoticeById, getAllImagesByNoticeId} = useNoticesStore();
|
const { getNoticeById, getAllImagesByNoticeId } = useNoticesStore();
|
||||||
const toggleNoticeInWishlist = useWishlist(
|
const toggleNoticeInWishlist = useWishlist(
|
||||||
(state) => state.toggleNoticeInWishlist
|
(state) => state.toggleNoticeInWishlist
|
||||||
);
|
);
|
||||||
@@ -63,7 +63,7 @@ export default function NoticeDetails() {
|
|||||||
const isInWishlist = useWishlist((state) =>
|
const isInWishlist = useWishlist((state) =>
|
||||||
id ? state.wishlistNotices.some((item) => item.noticeId === id) : false
|
id ? state.wishlistNotices.some((item) => item.noticeId === id) : false
|
||||||
);
|
);
|
||||||
const onViewableItemsChanged = useRef(({viewableItems}) => {
|
const onViewableItemsChanged = useRef(({ viewableItems }) => {
|
||||||
if (viewableItems.length > 0) {
|
if (viewableItems.length > 0) {
|
||||||
setCurrentIndex(viewableItems[0].index);
|
setCurrentIndex(viewableItems[0].index);
|
||||||
}
|
}
|
||||||
@@ -103,11 +103,11 @@ export default function NoticeDetails() {
|
|||||||
setImages(
|
setImages(
|
||||||
fetchedImages && fetchedImages.length > 0
|
fetchedImages && fetchedImages.length > 0
|
||||||
? fetchedImages
|
? fetchedImages
|
||||||
: {uri: "https://http.cat/404.jpg"}
|
: { uri: "https://http.cat/404.jpg" }
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Error while loading images:", err);
|
console.error("Error while loading images:", err);
|
||||||
setImage({uri: "https://http.cat/404.jpg"});
|
setImage({ uri: "https://http.cat/404.jpg" });
|
||||||
} finally {
|
} finally {
|
||||||
setIsImageLoading(false);
|
setIsImageLoading(false);
|
||||||
}
|
}
|
||||||
@@ -138,7 +138,7 @@ export default function NoticeDetails() {
|
|||||||
}, [notice]);
|
}, [notice]);
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return <ActivityIndicator/>;
|
return <ActivityIndicator />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
@@ -158,7 +158,7 @@ export default function NoticeDetails() {
|
|||||||
/>
|
/>
|
||||||
{isImageLoading ? (
|
{isImageLoading ? (
|
||||||
<Box className="h-auto w-full rounded-md aspect-[1/1] bg-gray-100 items-center justify-center">
|
<Box className="h-auto w-full rounded-md aspect-[1/1] bg-gray-100 items-center justify-center">
|
||||||
<ActivityIndicator size="large" color="#3b82f6"/>
|
<ActivityIndicator size="large" color="#3b82f6" />
|
||||||
</Box>
|
</Box>
|
||||||
) : (
|
) : (
|
||||||
<Box className="sticky top-0 z-10 bg-white">
|
<Box className="sticky top-0 z-10 bg-white">
|
||||||
@@ -173,8 +173,8 @@ export default function NoticeDetails() {
|
|||||||
pagingEnabled
|
pagingEnabled
|
||||||
onViewableItemsChanged={onViewableItemsChanged}
|
onViewableItemsChanged={onViewableItemsChanged}
|
||||||
viewabilityConfig={viewabilityConfig}
|
viewabilityConfig={viewabilityConfig}
|
||||||
renderItem={({item, index}) => (
|
renderItem={({ item, index }) => (
|
||||||
<View style={{width: width}} className="p-1">
|
<View style={{ width: width }} className="p-1">
|
||||||
<Image
|
<Image
|
||||||
source={item}
|
source={item}
|
||||||
className="h-auto w-auto rounded-md aspect-[1/1]"
|
className="h-auto w-auto rounded-md aspect-[1/1]"
|
||||||
@@ -244,7 +244,7 @@ export default function NoticeDetails() {
|
|||||||
<Box className="mt-4 bg-gray-50 p-3 rounded-lg shadow-sm">
|
<Box className="mt-4 bg-gray-50 p-3 rounded-lg shadow-sm">
|
||||||
<Text className="text-sm text-typography-500">Uzytkownik:</Text>
|
<Text className="text-sm text-typography-500">Uzytkownik:</Text>
|
||||||
{isUserLoading ? (
|
{isUserLoading ? (
|
||||||
<ActivityIndicator/>
|
<ActivityIndicator />
|
||||||
) : user ? (
|
) : user ? (
|
||||||
<>
|
<>
|
||||||
<Box className="mr-4">
|
<Box className="mr-4">
|
||||||
|
|||||||
11
ArtisanConnect/app/user/_layout.jsx
Normal file
11
ArtisanConnect/app/user/_layout.jsx
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { Stack } from 'expo-router';
|
||||||
|
|
||||||
|
export default function UserLayout() {
|
||||||
|
return (
|
||||||
|
<Stack
|
||||||
|
screenOptions={{
|
||||||
|
headerTitle: 'Ogłoszenia użytkownika',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
BIN
ArtisanConnect/assets/AppIco.png
Normal file
BIN
ArtisanConnect/assets/AppIco.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 304 KiB |
@@ -1,6 +1,5 @@
|
|||||||
import { View, FlatList } from "react-native";
|
import { View, FlatList } from "react-native";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useAuthStore } from "@/store/authStore";
|
|
||||||
import { Heading } from "@/components/ui/heading";
|
import { Heading } from "@/components/ui/heading";
|
||||||
import { Text } from "@/components/ui/text";
|
import { Text } from "@/components/ui/text";
|
||||||
import { Link } from "expo-router";
|
import { Link } from "expo-router";
|
||||||
@@ -17,7 +16,6 @@ export function CategorySection({ notices, title }) {
|
|||||||
setCategoryMap(data);
|
setCategoryMap(data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fetchCategories();
|
fetchCategories();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
11
ArtisanConnect/package-lock.json
generated
11
ArtisanConnect/package-lock.json
generated
@@ -43,6 +43,7 @@
|
|||||||
"expo-image-picker": "~16.1.4",
|
"expo-image-picker": "~16.1.4",
|
||||||
"expo-linking": "~7.1.4",
|
"expo-linking": "~7.1.4",
|
||||||
"expo-router": "~5.0.5",
|
"expo-router": "~5.0.5",
|
||||||
|
"expo-screen-orientation": "~8.1.7",
|
||||||
"expo-status-bar": "~2.2.3",
|
"expo-status-bar": "~2.2.3",
|
||||||
"expo-web-browser": "~14.1.6",
|
"expo-web-browser": "~14.1.6",
|
||||||
"form-data": "^4.0.2",
|
"form-data": "^4.0.2",
|
||||||
@@ -7012,6 +7013,16 @@
|
|||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/expo-screen-orientation": {
|
||||||
|
"version": "8.1.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/expo-screen-orientation/-/expo-screen-orientation-8.1.7.tgz",
|
||||||
|
"integrity": "sha512-nYwadYtdU6mMDk0MCHMPPPQtBoeFYJ2FspLRW+J35CMLqzE4nbpwGeiImfXzkvD94fpOCfI4KgLj5vGauC3pfA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peerDependencies": {
|
||||||
|
"expo": "*",
|
||||||
|
"react-native": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/expo-status-bar": {
|
"node_modules/expo-status-bar": {
|
||||||
"version": "2.2.3",
|
"version": "2.2.3",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -62,7 +62,8 @@
|
|||||||
"react-native-svg": "15.11.2",
|
"react-native-svg": "15.11.2",
|
||||||
"react-native-web": "~0.20.0",
|
"react-native-web": "~0.20.0",
|
||||||
"tailwindcss": "^3.4.17",
|
"tailwindcss": "^3.4.17",
|
||||||
"zustand": "^5.0.3"
|
"zustand": "^5.0.3",
|
||||||
|
"expo-screen-orientation": "~8.1.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.20.0",
|
"@babel/core": "^7.20.0",
|
||||||
|
|||||||
@@ -11,22 +11,23 @@ let interceptorInitialized = false;
|
|||||||
export const useAuthStore = create(
|
export const useAuthStore = create(
|
||||||
persist(
|
persist(
|
||||||
(set, get) => {
|
(set, get) => {
|
||||||
// if (!interceptorInitialized.current) {
|
if (!interceptorInitialized.current) {
|
||||||
// axios.interceptors.response.use(
|
axios.interceptors.response.use(
|
||||||
// (response) => response,
|
(response) => response,
|
||||||
// (error) => {
|
(error) => {
|
||||||
// if (
|
if (
|
||||||
// (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_id: null, token: null, isLoading: false });
|
||||||
// delete axios.defaults.headers.common["Authorization"];
|
delete axios.defaults.headers.common["Authorization"];
|
||||||
// }
|
router.replace("/login");
|
||||||
// return Promise.reject(error);
|
}
|
||||||
// }
|
return Promise.reject(error);
|
||||||
// );
|
}
|
||||||
// interceptorInitialized = true;
|
);
|
||||||
// }
|
interceptorInitialized = true;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
user_id: null,
|
user_id: null,
|
||||||
token: null,
|
token: null,
|
||||||
|
|||||||
Reference in New Issue
Block a user