Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
import { t } from '@app/lib/i18n';
import SpinnerIcon from '@icon/system/regular/spinner.svg';
import CloseIcon from '@icon/system/regular/x.svg';
import { ActionDialogShell } from '@ui/components/ActionDialogShell';
import { Button, type ButtonVariant } from '@ui/components/Button';
import type { ConfirmDialogProps } from '@ui/components/ConfirmDialog';
import { createUniqueId, Show } from 'solid-js';
import { MobileDrawer } from './MobileDrawer';
/** Controlled confirmation sheet; pending actions remain visible until resolved. */
export function ConfirmDrawer(props: ConfirmDialogProps) {
const titleId = createUniqueId();
const descriptionId = createUniqueId();
const close = () => {
if (!props.pending) props.onOpenChange(false);
};
const confirmVariant = (): ButtonVariant => {
if (props.tone === 'danger') return 'danger';
if (props.tone === 'success') return 'success';
return 'primary';
};
return (
<MobileDrawer
side="bottom"
open={props.open}
onOpenChange={(open) => !open && close()}
onFinalFocus={props.onCloseAutoFocus}
restoreFocus={!!props.mobileHero || !!props.onCloseAutoFocus}
closeOnOutsidePointer={!props.pending}
closeOnEscapeKeyDown={!props.pending}
>
<MobileDrawer.Portal>
<MobileDrawer.Overlay />
<MobileDrawer.Content
aria-labelledby={titleId}
aria-describedby={descriptionId}
class="overflow-hidden"
>
<MobileDrawer.Handle class="pb-1" />
<Show
when={props.mobileHero}
fallback={
<>
<div class="flex shrink-0 items-center justify-between gap-3 px-6 pb-4">
<h2
id={titleId}
class="text-[18px] leading-6 font-semibold text-ink"
>
{props.title}
</h2>
<Button
variant="ghost"
size="icon-lg"
aria-label={t('mobile.closeConfirmation')}
class="bg-ink/6"
disabled={props.pending}
onClick={close}
>
<CloseIcon class="size-5" />
</Button>
</div>
<MobileDrawer.ScrollBody>
<div
id={descriptionId}
class="px-6 pb-6 text-sm leading-5 text-ink-muted"
>
{props.body ?? props.children}
</div>
</MobileDrawer.ScrollBody>
<ActionDialogShell.Footer class="gap-3">
<Button
variant="ghost"
size="xl"
class="min-w-0 flex-1"
disabled={props.pending}
onClick={close}
>
{props.cancelLabel ?? t('mobile.cancel')}
</Button>
<Button
variant={confirmVariant()}
size="xl"
class="min-w-0 flex-1"
disabled={props.pending}
onClick={() => !props.pending && props.onConfirm()}
>
<Show when={props.pending}>
<SpinnerIcon class="size-4 animate-spin" />
</Show>
{props.confirmLabel ?? t('mobile.confirm')}
</Button>
</ActionDialogShell.Footer>
</>
}
>
<MobileDrawer.ScrollBody class="pb-0">
<div class="flex flex-col items-center px-6 pt-6 pb-8 text-center">
<div
class="mb-6 flex items-center justify-center gap-3"
aria-hidden="true"
>
{props.mobileHero}
</div>
<h2
id={titleId}
class="text-xl leading-7 font-semibold text-ink break-words max-w-full"
>
{props.title}
</h2>
<div
id={descriptionId}
class="mt-2 text-base leading-6 text-ink-muted"
>
{props.body ?? props.children}
</div>
</div>
</MobileDrawer.ScrollBody>
<div class="shrink-0 px-4 pb-[max(24px,var(--mobile-sheet-safe-padding))]">
<Button
variant={confirmVariant()}
size="xl"
fullWidth
class="h-12 rounded-2xl"
disabled={props.pending}
onClick={() => !props.pending && props.onConfirm()}
>
<Show when={props.pending}>
<SpinnerIcon class="size-4 animate-spin" />
</Show>
{props.confirmLabel ?? t('mobile.confirm')}
</Button>
</div>
</Show>
</MobileDrawer.Content>
</MobileDrawer.Portal>
</MobileDrawer>
);
}