BannerTableEditorQueueOperations.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { LOCAL_STORAGE_KEYS } from 'common'
  2. import { useParams } from 'common/hooks'
  3. import Link from 'next/link'
  4. import { Badge, Button, Card, CardContent, CardHeader } from 'ui'
  5. import { BannerCard } from '../BannerCard'
  6. import { useBannerStack } from '../BannerStackProvider'
  7. import { useIsQueueOperationsEnabled } from '@/components/interfaces/Account/Preferences/useDashboardSettings'
  8. import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
  9. const DASHBOARD_SETTINGS_URL = '/account/me#dashboard'
  10. export const BannerTableEditorQueueOperations = () => {
  11. const { ref } = useParams()
  12. const isQueueOperationsEnabled = useIsQueueOperationsEnabled()
  13. const { dismissBanner } = useBannerStack()
  14. const [, setIsDismissed] = useLocalStorageQuery(
  15. LOCAL_STORAGE_KEYS.TABLE_EDITOR_QUEUE_OPERATIONS_BANNER_DISMISSED(ref ?? ''),
  16. false
  17. )
  18. return (
  19. <BannerCard
  20. onDismiss={() => {
  21. setIsDismissed(true)
  22. dismissBanner('table-editor-queue-operations-banner')
  23. }}
  24. >
  25. <div className="flex flex-col gap-y-4">
  26. <div className="flex flex-col gap-y-2 items-start">
  27. <Badge variant="success" className="-ml-0.5 uppercase inline-flex items-center mb-2">
  28. New
  29. </Badge>
  30. <Card className="text-xs w-full">
  31. <CardHeader className="flex flex-row gap-2 px-2 py-2">
  32. <div className="min-w-0 flex-1">
  33. <div className="text-xs text-foreground ml-0.5">
  34. <span>name</span>
  35. <span className="text-foreground-muted mx-1.5">·</span>
  36. <span>where id = 10</span>
  37. </div>
  38. </div>
  39. </CardHeader>
  40. <CardContent className="font-mono text-xs px-2 py-1">
  41. <div className="flex gap-2 py-0.5">
  42. <span className="text-destructive select-none font-medium">-</span>
  43. <span className="text-destructive truncate max-w-full">Red</span>
  44. </div>
  45. <div className="flex gap-2 py-0.5">
  46. <span className="text-brand-link select-none font-medium">+</span>
  47. <span className="text-brand-link truncate max-w-full">Blue</span>
  48. </div>
  49. </CardContent>
  50. </Card>
  51. </div>
  52. <div className="flex flex-col gap-y-1 mb-2">
  53. <p className="text-sm font-medium">Queue row edits in Table Editor</p>
  54. <p className="text-xs text-foreground-lighter text-balance">
  55. Batch multiple row edits and review them before saving to your database
  56. </p>
  57. </div>
  58. <Button asChild type="default" className="w-min">
  59. <Link href={DASHBOARD_SETTINGS_URL}>
  60. {isQueueOperationsEnabled ? 'View' : 'Enable in'} preferences
  61. </Link>
  62. </Button>
  63. </div>
  64. </BannerCard>
  65. )
  66. }