Build image / build-and-push (push) Successful in 10s
Gadfly on #107: - ClearBed reported a failure twice — ConfirmModal's inline Alert AND useClearObject's own onError toast. Dropped the toast from useClearObject (its only caller is that modal now), so the failure shows once, inline in the dialog where the action is. - LeaveGarden's onConfirm silently resolved (closing the dialog as if it worked) if me.data was missing, relying on confirmDisabled to prevent it. Throw instead, so a drift in that guard surfaces an error rather than a fake success. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01H3zbym8Doka2d7D48maSgZ
34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
import { ConfirmModal } from '@/components/ui/ConfirmModal'
|
|
import { useMe } from '@/lib/auth'
|
|
import type { Garden } from '@/lib/gardens'
|
|
import { useRemoveShare } from '@/lib/shares'
|
|
|
|
/** Confirmation for a recipient leaving a garden shared with them (removes their
|
|
* own share). */
|
|
export function LeaveGardenModal({ garden, onClose }: { garden: Garden; onClose: () => void }) {
|
|
const me = useMe()
|
|
const remove = useRemoveShare(garden.id)
|
|
return (
|
|
<ConfirmModal
|
|
title="Leave garden"
|
|
confirmLabel="Leave"
|
|
busyLabel="Leaving…"
|
|
confirmDisabled={!me.data}
|
|
errorFallback="Could not leave the garden."
|
|
onConfirm={async () => {
|
|
// The button is disabled without a current user; throw rather than
|
|
// silently resolve (which would close the dialog as if it had worked) if
|
|
// that guard ever drifts.
|
|
if (!me.data) throw new Error('Not signed in.')
|
|
await remove.mutateAsync(me.data.id)
|
|
}}
|
|
onClose={onClose}
|
|
>
|
|
<p className="text-sm text-muted">
|
|
Leave <span className="font-medium text-fg">{garden.name}</span>? You'll lose access until the owner
|
|
shares it with you again.
|
|
</p>
|
|
</ConfirmModal>
|
|
)
|
|
}
|