From 90ada963bfb52fd6d7c9554db969aba06548515a Mon Sep 17 00:00:00 2001 From: Kuba Date: Tue, 10 Jun 2025 21:38:10 +0200 Subject: [PATCH 1/2] Added new atributes to view in notice id Also added SafeAreView to userid --- ArtisanConnect/app/notice/[id].jsx | 10 ++++++++++ ArtisanConnect/app/user/[userId].jsx | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ArtisanConnect/app/notice/[id].jsx b/ArtisanConnect/app/notice/[id].jsx index f5f0477..052ecc1 100644 --- a/ArtisanConnect/app/notice/[id].jsx +++ b/ArtisanConnect/app/notice/[id].jsx @@ -392,6 +392,16 @@ export default function NoticeDetails() { {notice.category} + {notice.attributes && notice.attributes.length > 0 && ( + + {notice.attributes.map((attribute, index) => ( + + {attribute.name}:{" "} + {attribute.value} + + ))} + + )} Opis ogloszenia diff --git a/ArtisanConnect/app/user/[userId].jsx b/ArtisanConnect/app/user/[userId].jsx index 28dea9c..dc23465 100644 --- a/ArtisanConnect/app/user/[userId].jsx +++ b/ArtisanConnect/app/user/[userId].jsx @@ -1,6 +1,6 @@ import { useLocalSearchParams, Stack } from "expo-router"; import { useState, useEffect } from "react"; -import { FlatList, ActivityIndicator, Text } from "react-native"; +import {FlatList, ActivityIndicator, Text, SafeAreaView} from "react-native"; import { Box } from "@/components/ui/box"; import { Image } from "@/components/ui/image"; import { VStack } from "@/components/ui/vstack"; @@ -44,6 +44,7 @@ export default function UserProfile() { ); return ( + Ten użytkownik nie ma żadnych ogłoszeń. )} + ); } From 121d9d1e5350606663470a4e383f92c7e85d8113 Mon Sep 17 00:00:00 2001 From: Andrii Solianyk Date: Tue, 10 Jun 2025 21:39:52 +0200 Subject: [PATCH 2/2] ekran autoryzacji przerobiony --- ArtisanConnect/app/(auth)/login.jsx | 127 ++++++++++++++++++---------- ArtisanConnect/app/registration.jsx | 123 ++++++++++++++++++--------- 2 files changed, 164 insertions(+), 86 deletions(-) diff --git a/ArtisanConnect/app/(auth)/login.jsx b/ArtisanConnect/app/(auth)/login.jsx index ed5cf42..309e76e 100644 --- a/ArtisanConnect/app/(auth)/login.jsx +++ b/ArtisanConnect/app/(auth)/login.jsx @@ -1,5 +1,5 @@ import React, {useEffect, useState} from 'react'; -import {StyleSheet, ActivityIndicator, SafeAreaView, View, Platform} from 'react-native'; +import {StyleSheet, ActivityIndicator, SafeAreaView, View, Platform, KeyboardAvoidingView} from 'react-native'; import {useAuthStore} from '@/store/authStore'; import {useRouter} from 'expo-router'; @@ -7,11 +7,11 @@ import {Box} from "@/components/ui/box" import {Button, ButtonText, ButtonIcon} from "@/components/ui/button" import {Center} from "@/components/ui/center" import {Heading} from "@/components/ui/heading" -import {Input, InputField} from "@/components/ui/input" +import {Input, InputField, InputIcon, InputSlot} from "@/components/ui/input" import {Text} from "@/components/ui/text" import {VStack} from "@/components/ui/vstack" import {HStack} from "@/components/ui/hstack" -import {ArrowRightIcon} from "@/components/ui/icon" +import {ArrowRightIcon, EyeIcon, EyeOffIcon} from "@/components/ui/icon" import {Divider} from '@/components/ui/divider'; import {Ionicons} from "@expo/vector-icons"; @@ -30,6 +30,8 @@ WebBrowser.maybeCompleteAuthSession(); export default function Login() { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); + const [emailError, setEmailError] = useState(''); + const [showPassword, setShowPassword] = useState(false) const {signIn, isLoading, signInWithGoogle} = useAuthStore(); const router = useRouter(); @@ -52,6 +54,11 @@ export default function Login() { return; } + if (!validateEmail(email)) { + setEmailError('Nieprawidłowy format adresu email'); + return; + } + try { await signIn(email, password); alert(`Zalogowano jako ${email}`); @@ -69,7 +76,7 @@ export default function Login() { // const user = await AsyncStorage.getItem("@user"); let user = null; if (!user) { - if(response.type === "success") { + if (response.type === "success") { user = await getUserInfo(response.authentication.accessToken) await signInWithGoogle(response.authentication.accessToken); alert(`Zalogowano jako ${user.email}`); @@ -83,7 +90,7 @@ export default function Login() { }; const getUserInfo = async (token) => { - if(!token) { + if (!token) { return } try { @@ -103,6 +110,17 @@ export default function Login() { } } + const validateEmail = (email) => { + const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + return emailRegex.test(email); + }; + + const handleShowPassword = () => { + setShowPassword((showState) => { + return !showState + }) + } + if (isLoading) { return ( @@ -112,49 +130,70 @@ export default function Login() { } return ( - -
- - - Logowanie - - {/* */} - - {/* */} - - - - - - - - - - - - - + {/* */} + + + + {emailError ? {emailError} : null} + + { + setEmail(text); + if (text && !validateEmail(text)) { + setEmailError('Nieprawidłowy format adresu email'); + } else { + setEmailError(''); + } + }} + /> + + + + + + + + + + + - - - - lub - - - - - -
-
+ + + + lub + + + + +
+ + + ); } @@ -173,7 +212,7 @@ const styles = StyleSheet.create({ }, errorText: { color: 'red', - marginBottom: 10, + fontSize: 12, }, signupbutton: { fontWeight: '300', diff --git a/ArtisanConnect/app/registration.jsx b/ArtisanConnect/app/registration.jsx index 4011ca7..ab76aca 100644 --- a/ArtisanConnect/app/registration.jsx +++ b/ArtisanConnect/app/registration.jsx @@ -1,22 +1,24 @@ import React, {useState} from 'react'; -import {StyleSheet, ActivityIndicator, SafeAreaView, View} from 'react-native'; +import {StyleSheet, ActivityIndicator, SafeAreaView, View, Platform, KeyboardAvoidingView} from 'react-native'; import {useAuthStore} from '@/store/authStore'; import {useRouter} from 'expo-router'; import {Box} from "@/components/ui/box" -import {Button, ButtonText,ButtonIcon} from "@/components/ui/button" -import {ArrowRightIcon} from "@/components/ui/icon" +import {Button, ButtonText, ButtonIcon} from "@/components/ui/button" +import {ArrowRightIcon, EyeIcon, EyeOffIcon} from "@/components/ui/icon" import {Center} from "@/components/ui/center" import {Heading} from "@/components/ui/heading" -import {Input, InputField} from "@/components/ui/input" +import {Input, InputField, InputIcon, InputSlot} from "@/components/ui/input" import {VStack} from "@/components/ui/vstack" -import {Link} from "expo-router" +import {Text} from "@/components/ui/text"; export default function Registration() { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [firstName, setFirstName] = useState(''); const [lastName, setLastName] = useState(''); + const [emailError, setEmailError] = useState(''); + const [showPassword, setShowPassword] = useState(false) const {signUp, isLoading} = useAuthStore(); const router = useRouter(); @@ -26,6 +28,11 @@ export default function Registration() { return; } + if (!validateEmail(email)) { + setEmailError('Nieprawidłowy format adresu email'); + return; + } + try { await signUp({email, password, firstName, lastName}); alert(`Zalogowano jako ${email}`); @@ -35,6 +42,17 @@ export default function Registration() { } } + const validateEmail = (email) => { + const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + return emailRegex.test(email); + }; + + const handleShowPassword = () => { + setShowPassword((showState) => { + return !showState + }) + } + if (isLoading) { return ( @@ -44,45 +62,66 @@ export default function Registration() { } return ( - -
- - - - Rejestracja - - {/* */} - - {/* */} - - - - - - - - - - - - - - - - - - - - - -
-
+ {/* */} + + + + {emailError ? {emailError} : null} + + { + setEmail(text); + if (text && !validateEmail(text)) { + setEmailError('Nieprawidłowy format adresu email'); + } else { + setEmailError(''); + } + }} + /> + + + + + + + + + + + + + + + + + + + + + + ); } @@ -105,7 +144,7 @@ const styles = StyleSheet.create({ color: 'red', marginBottom: 10, }, - signupbutton: { + signupbutton: { fontWeight: '300', textAlign: 'left', },