diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 27f017c..8529dad 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -15,23 +15,36 @@ const Header: React.FC = () => { return (
-
- Reddit-Like-App - Kod źródłowy - +
+ Reddit-Like-App + + | + + Kod źródłowy + + | + + {isAuth ? ( + <> + Stwórz post + + | + + Profil + + | + + + + ) : ( + <> + Zaloguj się + + | + + Zarejestruj się + + )}
); diff --git a/src/lib/pocketbase.ts b/src/lib/pocketbase.ts index 33a3731..50931f1 100644 --- a/src/lib/pocketbase.ts +++ b/src/lib/pocketbase.ts @@ -1,6 +1,6 @@ import PocketBase from 'pocketbase'; -export const pb = new PocketBase('https://pb.garandplg.com').autoCancellation(false); +export const pb = new PocketBase('https://rla-pb.garandplg.com').autoCancellation(false); // Inicjacja połączenia z moją instancją pocketbase // oraz wyeksportowanie tego połączenia diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index a68e2e9..1651ec7 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -19,7 +19,6 @@ const Home: React.FC = () => { try { const records = await pb.collection('posts').getFullList({ sort: '-votes', - expand: 'user', }); setPosts(records); } catch (error) { diff --git a/src/pages/Profile.tsx b/src/pages/Profile.tsx index 757566e..39ab98a 100644 --- a/src/pages/Profile.tsx +++ b/src/pages/Profile.tsx @@ -5,6 +5,7 @@ import { updateAuthAtom } from '../atoms/authAtom'; const Profile: React.FC = () => { const [email, setEmail] = useState(''); + const [username, setUsername] = useState(''); const [newPassword, setNewPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); const [, updateAuth] = useAtom(updateAuthAtom); @@ -23,7 +24,7 @@ const Profile: React.FC = () => { } try { - const data: Record = { email }; + const data: Record = { email, username }; if (newPassword) { data.password = newPassword; data.passwordConfirm = confirmPassword; @@ -47,7 +48,7 @@ const Profile: React.FC = () => { alert('Konto poprawnie usunięte'); } catch (error) { console.error('Błąd z usuwaniem konta:', error); - alert('Nie udało się usunąc konta.'); + alert('Nie udało się usunąć konta.'); } } }; @@ -67,12 +68,24 @@ const Profile: React.FC = () => { className="w-full px-3 py-2 border rounded" /> +
+ + setUsername(e.target.value)} + required + className="w-full px-3 py-2 border rounded" + /> +
setNewPassword(e.target.value)} className="w-full px-3 py-2 border rounded" /> diff --git a/src/pages/Register.tsx b/src/pages/Register.tsx index 3533f51..b13c1f0 100644 --- a/src/pages/Register.tsx +++ b/src/pages/Register.tsx @@ -1,15 +1,12 @@ import React, { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { pb } from '../lib/pocketbase'; -import { useAtom } from 'jotai'; -import { updateAuthAtom } from '../atoms/authAtom'; const Register: React.FC = () => { const [email, setEmail] = useState(''); const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [passwordConfirm, setPasswordConfirm] = useState(''); - const [, updateAuth] = useAtom(updateAuthAtom); const navigate = useNavigate(); const handleSubmit = async (e: React.FormEvent) => {