v0.12.53 Restricted Login type rule changes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rosterchirp-frontend",
|
||||
"version": "0.12.52",
|
||||
"version": "0.12.53",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -19,6 +19,7 @@ export default function AddChildAliasModal({ features = {}, onClose }) {
|
||||
// ── Mixed-age state (real minor users) ────────────────────────────────────
|
||||
const [minorPlayers, setMinorPlayers] = useState([]); // available + already-mine
|
||||
const [selectedMinorId, setSelectedMinorId] = useState('');
|
||||
const [childDob, setChildDob] = useState('');
|
||||
const [addingMinor, setAddingMinor] = useState(false);
|
||||
|
||||
// ── Partner state (shared) ────────────────────────────────────────────────
|
||||
@@ -49,6 +50,13 @@ export default function AddChildAliasModal({ features = {}, onClose }) {
|
||||
}).catch(() => {});
|
||||
}, [isMixedAge]);
|
||||
|
||||
// Pre-populate DOB when a minor is selected from the dropdown
|
||||
useEffect(() => {
|
||||
if (!selectedMinorId) { setChildDob(''); return; }
|
||||
const minor = availableMinors.find(u => u.id === parseInt(selectedMinorId));
|
||||
setChildDob(minor?.date_of_birth ? minor.date_of_birth.slice(0, 10) : '');
|
||||
}, [selectedMinorId]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────────
|
||||
const set = k => e => setForm(p => ({ ...p, [k]: e.target.value }));
|
||||
|
||||
@@ -164,12 +172,14 @@ export default function AddChildAliasModal({ features = {}, onClose }) {
|
||||
|
||||
const handleAddMinor = async () => {
|
||||
if (!selectedMinorId) return;
|
||||
if (!childDob.trim()) return toast('Date of Birth is required', 'error');
|
||||
setAddingMinor(true);
|
||||
try {
|
||||
await api.addGuardianChild(parseInt(selectedMinorId));
|
||||
await api.addGuardianChild(parseInt(selectedMinorId), childDob.trim());
|
||||
const { users: fresh } = await api.getMinorPlayers();
|
||||
setMinorPlayers(fresh || []);
|
||||
setSelectedMinorId('');
|
||||
setChildDob('');
|
||||
toast('Child added and account activated', 'success');
|
||||
} catch (e) {
|
||||
toast(e.message, 'error');
|
||||
@@ -282,24 +292,36 @@ export default function AddChildAliasModal({ features = {}, onClose }) {
|
||||
<div className="text-sm font-medium" style={{ color: 'var(--text-secondary)', marginBottom: 8 }}>
|
||||
Add Child
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: 8 }}>
|
||||
<select
|
||||
<select
|
||||
className="input"
|
||||
style={{ marginBottom: 8 }}
|
||||
value={selectedMinorId}
|
||||
onChange={e => setSelectedMinorId(e.target.value)}
|
||||
>
|
||||
<option value="">— Select a player —</option>
|
||||
{availableMinors.map(u => (
|
||||
<option key={u.id} value={u.id}>
|
||||
{u.first_name} {u.last_name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<div style={{ marginBottom: 8 }}>
|
||||
{lbl('Date of Birth', true)}
|
||||
<input
|
||||
className="input"
|
||||
style={{ flex: 1 }}
|
||||
value={selectedMinorId}
|
||||
onChange={e => setSelectedMinorId(e.target.value)}
|
||||
>
|
||||
<option value="">— Select a player —</option>
|
||||
{availableMinors.map(u => (
|
||||
<option key={u.id} value={u.id}>
|
||||
{u.first_name} {u.last_name}{u.date_of_birth ? ` (${u.date_of_birth.slice(0, 10)})` : ''}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
type="text"
|
||||
placeholder="YYYY-MM-DD"
|
||||
value={childDob}
|
||||
onChange={e => setChildDob(e.target.value)}
|
||||
autoComplete="off"
|
||||
style={childDob === '' && selectedMinorId ? { borderColor: 'var(--error)' } : {}}
|
||||
/>
|
||||
</div>
|
||||
<div style={{ display: 'flex', justifyContent: 'flex-end' }}>
|
||||
<button
|
||||
className="btn btn-primary"
|
||||
onClick={handleAddMinor}
|
||||
disabled={addingMinor || !selectedMinorId}
|
||||
disabled={addingMinor || !selectedMinorId || !childDob.trim()}
|
||||
style={{ whiteSpace: 'nowrap' }}
|
||||
>
|
||||
{addingMinor ? 'Adding…' : 'Add'}
|
||||
|
||||
@@ -71,7 +71,7 @@ export const api = {
|
||||
},
|
||||
searchMinorUsers: (q) => req('GET', `/users/search-minors?q=${encodeURIComponent(q || '')}`),
|
||||
getMinorPlayers: () => req('GET', '/users/minor-players'),
|
||||
addGuardianChild: (minorId) => req('POST', `/users/me/guardian-children/${minorId}`),
|
||||
addGuardianChild: (minorId, dateOfBirth) => req('POST', `/users/me/guardian-children/${minorId}`, { dateOfBirth: dateOfBirth || null }),
|
||||
removeGuardianChild: (minorId) => req('DELETE', `/users/me/guardian-children/${minorId}`),
|
||||
approveGuardian: (id) => req('PATCH', `/users/${id}/approve-guardian`),
|
||||
denyGuardian: (id) => req('PATCH', `/users/${id}/deny-guardian`),
|
||||
|
||||
Reference in New Issue
Block a user