nice
This commit is contained in:
parent
9df9847c8a
commit
fd6d4e2ae2
@ -3,7 +3,6 @@ import { BrowserQRCodeReader } from '@zxing/browser';
|
|||||||
import { timeApi } from '../api/time';
|
import { timeApi } from '../api/time';
|
||||||
import { useAuth } from '../context/useAuth';
|
import { useAuth } from '../context/useAuth';
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||||
import { Input } from '@/components/ui/input';
|
|
||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Alert, AlertDescription } from '@/components/ui/alert';
|
import { Alert, AlertDescription } from '@/components/ui/alert';
|
||||||
@ -241,37 +240,26 @@ const TimeClockPage = () => {
|
|||||||
if (!user) return '';
|
if (!user) return '';
|
||||||
|
|
||||||
return String(
|
return String(
|
||||||
user.id ??
|
user.id
|
||||||
user.pk ??
|
|
||||||
user.user_id ??
|
|
||||||
user.user?.id ??
|
|
||||||
''
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getUserLabel = (user) => {
|
const getUserLabel = (user) => {
|
||||||
if (!user) return 'Utilisateur';
|
if (!user) return 'Utilisateur';
|
||||||
|
|
||||||
const firstName = user.first_name || user.firstName || '';
|
const firstName = user.first_name || '';
|
||||||
const lastName = user.last_name || user.lastName || '';
|
const lastName = user.last_name || '';
|
||||||
const fullName = `${firstName} ${lastName}`.trim();
|
const fullName = `${firstName} ${lastName}`.trim();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
fullName ||
|
fullName ||
|
||||||
user.username ||
|
`Utilisateur #${user.id}`
|
||||||
user.name ||
|
|
||||||
user.email ||
|
|
||||||
`Utilisateur #${getUserId(user)}`
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getEntryUserId = (entry) => {
|
const getEntryUserId = (entry) => {
|
||||||
return String(
|
return String(
|
||||||
entry.user_id ??
|
entry.user.id
|
||||||
entry.userId ??
|
|
||||||
entry.user?.id ??
|
|
||||||
entry.user?.pk ??
|
|
||||||
''
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -312,16 +300,7 @@ const TimeClockPage = () => {
|
|||||||
|
|
||||||
if (!id || usersById.has(id)) return;
|
if (!id || usersById.has(id)) return;
|
||||||
|
|
||||||
const entryUser =
|
usersById.set(id, entry.user);
|
||||||
typeof entry.user === 'object' && entry.user
|
|
||||||
? entry.user
|
|
||||||
: {
|
|
||||||
id,
|
|
||||||
username: entry.username,
|
|
||||||
name: entry.user,
|
|
||||||
};
|
|
||||||
|
|
||||||
usersById.set(id, entryUser);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
availableUsers = [...usersById.values()];
|
availableUsers = [...usersById.values()];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user