ConfirmFooter.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { PropsWithChildren } from 'react'
  2. import { Button, cn } from 'ui'
  3. interface ConfirmFooterProps {
  4. message: string
  5. cancelLabel?: string
  6. confirmLabel?: string
  7. confirmLabelLoading?: string
  8. isLoading?: boolean
  9. onCancel?: () => void | Promise<void>
  10. onConfirm?: () => void | Promise<void>
  11. }
  12. export const ConfirmFooter = ({
  13. message,
  14. cancelLabel = 'Cancel',
  15. confirmLabel = 'Confirm',
  16. confirmLabelLoading = 'Working...',
  17. isLoading = false,
  18. onCancel,
  19. onConfirm,
  20. }: PropsWithChildren<ConfirmFooterProps>) => {
  21. return (
  22. <div
  23. className={cn(
  24. 'flex items-center justify-between py-2 pr-2 pl-4 text-xs text-foreground',
  25. 'relative border border-t-0 overflow-hidden rounded-b-lg bg-border shadow-inset gap-3',
  26. 'bg-linear-to-r from-background-surface-75 to-background-surface-200'
  27. )}
  28. >
  29. <div className="flex-1 relative z-10">{message}</div>
  30. <div className="flex items-center gap-2 relative z-10">
  31. <Button size="tiny" type="outline" onClick={onCancel} disabled={isLoading}>
  32. {cancelLabel}
  33. </Button>
  34. <Button size="tiny" type="primary" onClick={onConfirm} disabled={isLoading}>
  35. {isLoading ? confirmLabelLoading : confirmLabel}
  36. </Button>
  37. </div>
  38. </div>
  39. )
  40. }