|
|
|
@@ -2263,9 +2263,10 @@ function App() {
|
|
|
|
|
const [removingWorkspaceMemberId, setRemovingWorkspaceMemberId] = useState('');
|
|
|
|
|
const [expandedSettingsSection, setExpandedSettingsSection] = useState<SettingsSection | null>(null);
|
|
|
|
|
|
|
|
|
|
const flockBirds = useMemo(() => sortBirdsByName([...birds, ...memorializedBirds]), [birds, memorializedBirds]);
|
|
|
|
|
const selectedBird = useMemo(
|
|
|
|
|
() => birds.find((bird) => bird.id === selectedBirdId) ?? null,
|
|
|
|
|
[birds, selectedBirdId],
|
|
|
|
|
() => flockBirds.find((bird) => bird.id === selectedBirdId) ?? null,
|
|
|
|
|
[flockBirds, selectedBirdId],
|
|
|
|
|
);
|
|
|
|
|
const isBillingOwner = Boolean(
|
|
|
|
|
authSession?.user.email &&
|
|
|
|
@@ -2982,7 +2983,7 @@ function App() {
|
|
|
|
|
|
|
|
|
|
setBirds(nextBirds);
|
|
|
|
|
setMemorializedBirds(data.memorializedBirds ?? []);
|
|
|
|
|
setSelectedBirdId((current) => (current && nextBirds.some((bird) => bird.id === current) ? current : ''));
|
|
|
|
|
setSelectedBirdId((current) => (current && [...nextBirds, ...(data.memorializedBirds ?? [])].some((bird) => bird.id === current) ? current : ''));
|
|
|
|
|
|
|
|
|
|
if (membersResponse.ok) {
|
|
|
|
|
const membersData = (await readJsonSafely<{ members?: WorkspaceMember[] }>(membersResponse)) ?? {};
|
|
|
|
@@ -3680,6 +3681,7 @@ function App() {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const startEditBird = (bird: Bird) => {
|
|
|
|
|
if (bird.memorializedAt) return;
|
|
|
|
|
setSelectedBirdId(bird.id);
|
|
|
|
|
setEditingBirdId(bird.id);
|
|
|
|
|
setBirdEditorOpen(true);
|
|
|
|
@@ -4660,7 +4662,7 @@ function App() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const confirmed = window.confirm(
|
|
|
|
|
`Memorialize ${selectedBird.name}?\n\nThis cannot be undone by you. ${selectedBird.name} will become read-only, hidden from the standard flock view, and excluded from the subscription bird count.`,
|
|
|
|
|
`Memorialize ${selectedBird.name}?\n\nThis cannot be undone by you. ${selectedBird.name} will become read-only, shown softly faded in the flock, and excluded from the subscription bird count.`,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (!confirmed) {
|
|
|
|
@@ -4689,17 +4691,14 @@ function App() {
|
|
|
|
|
const memorializedBird = data.bird;
|
|
|
|
|
setBirds((current) => current.filter((bird) => bird.id !== memorializedBird.id));
|
|
|
|
|
setMemorializedBirds((current) => sortBirdsByName([...current.filter((bird) => bird.id !== memorializedBird.id), memorializedBird]));
|
|
|
|
|
setSelectedBirdId('');
|
|
|
|
|
setSelectedBirdId(memorializedBird.id);
|
|
|
|
|
setBirdEditorOpen(false);
|
|
|
|
|
setEditingBirdId('');
|
|
|
|
|
setBirdForm(emptyBirdForm);
|
|
|
|
|
setBirdPhotoName('');
|
|
|
|
|
setPhotoCrop(null);
|
|
|
|
|
setPhotoDrag(null);
|
|
|
|
|
setMemorializeBirdForm(emptyMemorializeBirdForm());
|
|
|
|
|
setWeights([]);
|
|
|
|
|
setVetVisits([]);
|
|
|
|
|
setMedications([]);
|
|
|
|
|
setMedicationAdministrations([]);
|
|
|
|
|
setAllBirdWeights((current) => {
|
|
|
|
|
const next = { ...current };
|
|
|
|
|
delete next[memorializedBird.id];
|
|
|
|
@@ -6364,7 +6363,7 @@ function App() {
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="bird-list">
|
|
|
|
|
{birds.map((bird) => {
|
|
|
|
|
{flockBirds.map((bird) => {
|
|
|
|
|
const weightRangeAlert = outOfRangeBirds.find((alert) => alert.bird.id === bird.id) ?? null;
|
|
|
|
|
const vetVisitAlertSignature = getVetVisitAlertSignature(bird.id);
|
|
|
|
|
const hasVetVisitAlert = vetVisitDueBirdIds.has(bird.id);
|
|
|
|
@@ -6372,7 +6371,7 @@ function App() {
|
|
|
|
|
return (
|
|
|
|
|
<article
|
|
|
|
|
key={bird.id}
|
|
|
|
|
className={`bird-card ${bird.id === selectedBird?.id ? 'active' : ''}`}
|
|
|
|
|
className={`bird-card ${bird.memorializedAt ? 'memorialized' : ''} ${bird.id === selectedBird?.id ? 'active' : ''}`}
|
|
|
|
|
style={bird.id === selectedBird?.id ? { borderColor: bird.chartColor, boxShadow: `0 16px 24px ${bird.chartColor}33` } : undefined}
|
|
|
|
|
>
|
|
|
|
|
<button className="bird-card-select" onClick={() => setSelectedBirdId(bird.id)} type="button">
|
|
|
|
@@ -6389,11 +6388,14 @@ function App() {
|
|
|
|
|
</span>
|
|
|
|
|
</span>
|
|
|
|
|
<small>{bird.species}</small>
|
|
|
|
|
{bird.memorializedAt ? <small className="memorial-label">In memory · Read-only</small> : null}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<strong>{formatWeight(bird.latestWeightGrams)}</strong>
|
|
|
|
|
{!bird.memorializedAt || bird.latestWeightGrams !== null ? (
|
|
|
|
|
<strong>{formatWeight(bird.latestWeightGrams)}</strong>
|
|
|
|
|
) : null}
|
|
|
|
|
</button>
|
|
|
|
|
{weightRangeAlert || hasVetVisitAlert ? (
|
|
|
|
|
{!bird.memorializedAt && (weightRangeAlert || hasVetVisitAlert) ? (
|
|
|
|
|
<div className="bird-alert-stack">
|
|
|
|
|
{weightRangeAlert ? (
|
|
|
|
|
<span className="bird-alert-badge">
|
|
|
|
@@ -7127,7 +7129,7 @@ function App() {
|
|
|
|
|
<p className="eyebrow">Flock member</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="member-header-actions">
|
|
|
|
|
{selectedBirdWeightRangeAlert || selectedBirdWeightDropAlerts.length || selectedBirdHasVetVisitAlert ? (
|
|
|
|
|
{!selectedBird.memorializedAt && (selectedBirdWeightRangeAlert || selectedBirdWeightDropAlerts.length || selectedBirdHasVetVisitAlert) ? (
|
|
|
|
|
<div className="bird-alert-stack" aria-label={`Critical alerts for ${selectedBird.name}`}>
|
|
|
|
|
{selectedBirdWeightRangeAlert ? (
|
|
|
|
|
<span className="bird-alert-badge">
|
|
|
|
@@ -7180,7 +7182,7 @@ function App() {
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<>
|
|
|
|
|
<section className="profile-hero">
|
|
|
|
|
<section className={`profile-hero ${selectedBird.memorializedAt ? 'memorialized-profile' : ''}`}>
|
|
|
|
|
<img className="profile-photo" src={selectedBird.photoDataUrl || defaultBirdPhoto} alt={`${selectedBird.name}`} />
|
|
|
|
|
<div className="profile-actions">
|
|
|
|
|
{selectedBird.publicProfileEnabled && selectedBird.publicProfileCode ? (
|
|
|
|
@@ -7190,7 +7192,7 @@ function App() {
|
|
|
|
|
</svg>
|
|
|
|
|
</button>
|
|
|
|
|
) : null}
|
|
|
|
|
<button className="profile-icon-button" onClick={() => startEditBird(selectedBird)} type="button" aria-label={`Edit details for ${selectedBird.name}`} title="Edit details">
|
|
|
|
|
<button disabled={Boolean(selectedBird.memorializedAt)} className="profile-icon-button" onClick={() => startEditBird(selectedBird)} type="button" aria-label={`Edit details for ${selectedBird.name}`} title="Edit details">
|
|
|
|
|
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
|
|
|
<path d="M4 20h4l10.5-10.5-4-4L4 16v4Z" />
|
|
|
|
|
<path d="m13.5 6.5 4 4" />
|
|
|
|
@@ -7217,7 +7219,8 @@ function App() {
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<div className="bird-detail-tab-panel">
|
|
|
|
|
{selectedBird.memorializedAt ? <p className="memorial-banner" role="status">In memory of {selectedBird.name}{selectedBird.memorializedOn ? ` · ${formatDate(selectedBird.memorializedOn)}` : ''}. This profile and its care history are read-only.</p> : null}
|
|
|
|
|
<div className="bird-detail-tab-panel">
|
|
|
|
|
{selectedBirdTab === 'info' ? (
|
|
|
|
|
<div className="flock-member-sections" role="tabpanel">
|
|
|
|
|
<div className="detail-grid">
|
|
|
|
@@ -7267,7 +7270,7 @@ function App() {
|
|
|
|
|
<h2>Medication schedule</h2>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="recent-list">{renderMedicationList({ showAdministrationControls: true })}</div>
|
|
|
|
|
<div className="recent-list">{renderMedicationList({ showAdministrationControls: !selectedBird.memorializedAt })}</div>
|
|
|
|
|
</section>
|
|
|
|
|
) : null}
|
|
|
|
|
</div>
|
|
|
|
@@ -7434,7 +7437,7 @@ function App() {
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<form className="form-panel inline-form" onSubmit={handleWeightSubmit}>
|
|
|
|
|
{!selectedBird.memorializedAt ? (<form className="form-panel inline-form" onSubmit={handleWeightSubmit}>
|
|
|
|
|
<label>
|
|
|
|
|
Weight in grams
|
|
|
|
|
<input
|
|
|
|
@@ -7465,16 +7468,16 @@ function App() {
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
<div className="button-row care-form-actions">
|
|
|
|
|
<button className="primary-button" type="submit">
|
|
|
|
|
<button className="primary-button" disabled={Boolean(selectedBird.memorializedAt)} type="submit">
|
|
|
|
|
{editingWeightId ? 'Save weight changes' : 'Save weight'}
|
|
|
|
|
</button>
|
|
|
|
|
{editingWeightId ? (
|
|
|
|
|
<button className="secondary-button" onClick={handleCancelWeightEdit} type="button">
|
|
|
|
|
<button className="secondary-button" onClick={handleCancelWeightEdit} disabled={Boolean(selectedBird.memorializedAt)} type="button">
|
|
|
|
|
Cancel edit
|
|
|
|
|
</button>
|
|
|
|
|
) : null}
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</form>) : null}
|
|
|
|
|
<div className="recent-list">
|
|
|
|
|
{editableWeights
|
|
|
|
|
.map((weight) => (
|
|
|
|
@@ -7483,7 +7486,7 @@ function App() {
|
|
|
|
|
<span>{formatDate(weight.recordedOn)}</span>
|
|
|
|
|
<small>{weight.notes || 'No notes recorded.'}</small>
|
|
|
|
|
<div className="button-row">
|
|
|
|
|
<button className="secondary-button" onClick={() => handleEditWeight(weight)} type="button">
|
|
|
|
|
<button className="secondary-button" onClick={() => handleEditWeight(weight)} disabled={Boolean(selectedBird.memorializedAt)} type="button">
|
|
|
|
|
Edit
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
@@ -7510,7 +7513,7 @@ function App() {
|
|
|
|
|
setVeterinaryInfoForm(toVeterinaryInfoForm(selectedBird));
|
|
|
|
|
setEditingVeterinaryInfo(true);
|
|
|
|
|
}}
|
|
|
|
|
type="button"
|
|
|
|
|
disabled={Boolean(selectedBird.memorializedAt)} type="button"
|
|
|
|
|
aria-label={`Edit veterinary info for ${selectedBird.name}`}
|
|
|
|
|
title="Edit veterinary info"
|
|
|
|
|
>
|
|
|
|
@@ -7522,7 +7525,7 @@ function App() {
|
|
|
|
|
</button>
|
|
|
|
|
) : null}
|
|
|
|
|
</div>
|
|
|
|
|
{editingVeterinaryInfo ? (
|
|
|
|
|
{editingVeterinaryInfo && !selectedBird.memorializedAt ? (
|
|
|
|
|
<form className="form-panel inline-form care-entry-form" onSubmit={handleVeterinaryInfoSubmit}>
|
|
|
|
|
<label>
|
|
|
|
|
Clinic name
|
|
|
|
@@ -7558,7 +7561,7 @@ function App() {
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
<div className="button-row care-form-actions">
|
|
|
|
|
<button className="primary-button" type="submit" disabled={savingVeterinaryInfo}>
|
|
|
|
|
<button className="primary-button" type="submit" disabled={Boolean(selectedBird.memorializedAt) || (savingVeterinaryInfo)}>
|
|
|
|
|
{savingVeterinaryInfo ? 'Saving veterinary info...' : 'Save veterinary info'}
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
@@ -7568,7 +7571,7 @@ function App() {
|
|
|
|
|
setEditingVeterinaryInfo(false);
|
|
|
|
|
}}
|
|
|
|
|
type="button"
|
|
|
|
|
disabled={savingVeterinaryInfo}
|
|
|
|
|
disabled={Boolean(selectedBird.memorializedAt) || (savingVeterinaryInfo)}
|
|
|
|
|
>
|
|
|
|
|
Cancel
|
|
|
|
|
</button>
|
|
|
|
@@ -7604,7 +7607,7 @@ function App() {
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<form className="form-panel inline-form care-entry-form" onSubmit={handleVetVisitSubmit}>
|
|
|
|
|
{!selectedBird.memorializedAt ? (<form className="form-panel inline-form care-entry-form" onSubmit={handleVetVisitSubmit}>
|
|
|
|
|
<label>
|
|
|
|
|
Visit date
|
|
|
|
|
<input
|
|
|
|
@@ -7640,16 +7643,16 @@ function App() {
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
<div className="button-row care-form-actions">
|
|
|
|
|
<button className="primary-button" type="submit">
|
|
|
|
|
<button className="primary-button" disabled={Boolean(selectedBird.memorializedAt)} type="submit">
|
|
|
|
|
{editingVetVisitId ? 'Save vet visit changes' : 'Save vet visit'}
|
|
|
|
|
</button>
|
|
|
|
|
{editingVetVisitId ? (
|
|
|
|
|
<button className="secondary-button" onClick={handleCancelVetVisitEdit} type="button">
|
|
|
|
|
<button className="secondary-button" onClick={handleCancelVetVisitEdit} disabled={Boolean(selectedBird.memorializedAt)} type="button">
|
|
|
|
|
Cancel edit
|
|
|
|
|
</button>
|
|
|
|
|
) : null}
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</form>) : null}
|
|
|
|
|
|
|
|
|
|
<div className="recent-list">
|
|
|
|
|
{vetVisits.length ? (
|
|
|
|
@@ -7661,7 +7664,7 @@ function App() {
|
|
|
|
|
</span>
|
|
|
|
|
<small>{visit.notes || 'No notes recorded.'}</small>
|
|
|
|
|
<div className="button-row">
|
|
|
|
|
<button className="secondary-button" onClick={() => handleEditVetVisit(visit)} type="button">
|
|
|
|
|
<button className="secondary-button" onClick={() => handleEditVetVisit(visit)} disabled={Boolean(selectedBird.memorializedAt)} type="button">
|
|
|
|
|
Edit
|
|
|
|
|
</button>
|
|
|
|
|
{editingVetVisitId === visit.id ? (
|
|
|
|
@@ -7669,7 +7672,7 @@ function App() {
|
|
|
|
|
className="secondary-button"
|
|
|
|
|
onClick={() => handleDeleteVetVisit(visit.id)}
|
|
|
|
|
type="button"
|
|
|
|
|
disabled={deletingVetVisitId === visit.id}
|
|
|
|
|
disabled={Boolean(selectedBird.memorializedAt) || (deletingVetVisitId === visit.id)}
|
|
|
|
|
>
|
|
|
|
|
{deletingVetVisitId === visit.id ? 'Deleting...' : 'Delete'}
|
|
|
|
|
</button>
|
|
|
|
@@ -7698,7 +7701,7 @@ function App() {
|
|
|
|
|
</div>
|
|
|
|
|
<p className="muted">{selectedBirdNotes.length} total</p>
|
|
|
|
|
</div>
|
|
|
|
|
<form className="form-panel care-entry-form" onSubmit={handleFlockNoteSubmit}>
|
|
|
|
|
{!selectedBird.memorializedAt ? (<form className="form-panel care-entry-form" onSubmit={handleFlockNoteSubmit}>
|
|
|
|
|
<label className="wide-field">
|
|
|
|
|
Note
|
|
|
|
|
<textarea
|
|
|
|
@@ -7709,10 +7712,10 @@ function App() {
|
|
|
|
|
required
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
<button className="primary-button" type="submit" disabled={savingFlockNote}>
|
|
|
|
|
<button className="primary-button" type="submit" disabled={Boolean(selectedBird.memorializedAt) || (savingFlockNote)}>
|
|
|
|
|
{savingFlockNote ? 'Saving...' : 'Save note'}
|
|
|
|
|
</button>
|
|
|
|
|
</form>
|
|
|
|
|
</form>) : null}
|
|
|
|
|
<div className="recent-list note-list">
|
|
|
|
|
{selectedBirdNotes.length ? (
|
|
|
|
|
selectedBirdNotes.map((note) => (
|
|
|
|
@@ -7727,7 +7730,7 @@ function App() {
|
|
|
|
|
className="secondary-button"
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => handleDeleteFlockNote(note.id)}
|
|
|
|
|
disabled={deletingFlockNoteId === note.id}
|
|
|
|
|
disabled={Boolean(selectedBird.memorializedAt) || (deletingFlockNoteId === note.id)}
|
|
|
|
|
>
|
|
|
|
|
{deletingFlockNoteId === note.id ? 'Deleting...' : 'Delete'}
|
|
|
|
|
</button>
|
|
|
|
@@ -7765,10 +7768,10 @@ function App() {
|
|
|
|
|
</article>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="button-row">
|
|
|
|
|
<button className="primary-button" onClick={() => handleOpenAdoptionReport(false)} type="button" disabled={creatingAdoptionReportCode}>
|
|
|
|
|
<button className="primary-button" onClick={() => handleOpenAdoptionReport(false)} type="button" disabled={Boolean(selectedBird.memorializedAt) || (creatingAdoptionReportCode)}>
|
|
|
|
|
{creatingAdoptionReportCode ? 'Preparing report...' : 'Open adoption report'}
|
|
|
|
|
</button>
|
|
|
|
|
<button className="secondary-button" onClick={() => handleOpenAdoptionReport(true)} type="button" disabled={creatingAdoptionReportCode}>
|
|
|
|
|
<button className="secondary-button" onClick={() => handleOpenAdoptionReport(true)} type="button" disabled={Boolean(selectedBird.memorializedAt) || (creatingAdoptionReportCode)}>
|
|
|
|
|
Print-friendly report
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
@@ -7852,7 +7855,7 @@ function App() {
|
|
|
|
|
</div>
|
|
|
|
|
) : null;
|
|
|
|
|
})()}
|
|
|
|
|
<form className="form-panel inline-form care-entry-form bird-timeline-form" onSubmit={handleBirdTimelineEventSubmit}>
|
|
|
|
|
{!selectedBird.memorializedAt ? (<form className="form-panel inline-form care-entry-form bird-timeline-form" onSubmit={handleBirdTimelineEventSubmit}>
|
|
|
|
|
<label>
|
|
|
|
|
Type
|
|
|
|
|
<select
|
|
|
|
@@ -7941,7 +7944,7 @@ function App() {
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
</label>
|
|
|
|
|
<button className="primary-button" type="submit" disabled={savingBirdTimelineEvent}>
|
|
|
|
|
<button className="primary-button" type="submit" disabled={Boolean(selectedBird.memorializedAt) || (savingBirdTimelineEvent)}>
|
|
|
|
|
{savingBirdTimelineEvent ? 'Adding...' : 'Add timeline item'}
|
|
|
|
|
</button>
|
|
|
|
|
{birdTimelineNotice ? (
|
|
|
|
@@ -7949,7 +7952,7 @@ function App() {
|
|
|
|
|
{birdTimelineNotice.message}
|
|
|
|
|
</p>
|
|
|
|
|
) : null}
|
|
|
|
|
</form>
|
|
|
|
|
</form>) : null}
|
|
|
|
|
<div className="recent-list bird-timeline-list">
|
|
|
|
|
{birdTimelineEvents.length ? (
|
|
|
|
|
birdTimelineEvents.map((event) => (
|
|
|
|
|