fix integration

This commit is contained in:
2025-06-05 21:40:30 +02:00
parent 3bd3b9b70d
commit 48cf5cd6c4
9 changed files with 92 additions and 33 deletions

View File

@@ -4,16 +4,21 @@ import { Heading } from '@/components/ui/heading';
import { FlatList } from 'react-native';
import axios from 'axios';
import UserBlock from '@/components/UserBlock';
import {useAuthStore} from "@/store/authStore";
export function UserSection({notices, title}) {
const token = useAuthStore((state) => state.token);
const headers = token ? { 'Authorization': `Bearer ${token}` } : {};
const [users, setUsers] = useState([]);
useEffect(() => {
axios.get('https://testowe.zikor.pl/api/v1/clients/get/all')
if (token){
axios.get('https://testowe.zikor.pl/api/v1/clients/get/all', { headers })
.then(res => setUsers(res.data))
.catch(() => setUsers([]));
}, []);
}
}, [token]);
const usersWithNoticeCount = users.map(user => {
const count = notices.filter(n => n.clientId === user.id).length;