File size: 3,793 Bytes
cd99321
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import React, { useEffect, useCallback } from 'react'
import ReactDOM from 'react-dom'
import { Check, X } from 'lucide-react'
import { useTranslation } from '../../i18n'

interface CopyTripDialogProps {
  isOpen: boolean
  tripTitle: string
  onClose: () => void
  onConfirm: () => void
}

const WILL_COPY_KEYS = [
  'dashboard.confirm.copy.will1',
  'dashboard.confirm.copy.will2',
  'dashboard.confirm.copy.will3',
  'dashboard.confirm.copy.will4',
  'dashboard.confirm.copy.will5',
  'dashboard.confirm.copy.will6',
]

const WONT_COPY_KEYS = [
  'dashboard.confirm.copy.wont1',
  'dashboard.confirm.copy.wont2',
  'dashboard.confirm.copy.wont3',
  'dashboard.confirm.copy.wont4',
]

export default function CopyTripDialog({ isOpen, tripTitle, onClose, onConfirm }: CopyTripDialogProps) {
  const { t } = useTranslation()

  const handleEsc = useCallback((e: KeyboardEvent) => {
    if (e.key === 'Escape') onClose()
  }, [onClose])

  useEffect(() => {
    if (isOpen) document.addEventListener('keydown', handleEsc)
    return () => document.removeEventListener('keydown', handleEsc)
  }, [isOpen, handleEsc])

  if (!isOpen) return null

  return ReactDOM.createPortal(
    <div
      className="fixed inset-0 z-[10000] flex items-center justify-center px-4 trek-backdrop-enter bg-[rgba(15,23,42,0.5)]"
      style={{ paddingBottom: 'var(--bottom-nav-h)' }}
      onClick={onClose}
    >
      <div
        className="trek-modal-enter rounded-2xl shadow-2xl w-full max-w-md p-6 bg-surface-card"
        onClick={e => e.stopPropagation()}
      >
        <h3 className="text-base font-semibold mb-1 text-content">
          {t('dashboard.confirm.copy.title')}
        </h3>
        <p className="text-sm mb-4 text-content-secondary">
          {tripTitle}
        </p>

        <div className="flex flex-col gap-3">
          <div className="rounded-xl p-3 border border-edge-secondary" style={{ background: 'var(--bg-subtle)' }}>
            <p className="text-xs font-semibold uppercase tracking-wide mb-2 text-[#16a34a]">
              {t('dashboard.confirm.copy.willCopy')}
            </p>
            <ul className="flex flex-col gap-1">
              {WILL_COPY_KEYS.map(key => (
                <li key={key} className="flex items-center gap-2 text-sm text-content-secondary">
                  <Check size={13} className="flex-shrink-0 text-[#16a34a]" />
                  {t(key)}
                </li>
              ))}
            </ul>
          </div>

          <div className="rounded-xl p-3 border border-edge-secondary" style={{ background: 'var(--bg-subtle)' }}>
            <p className="text-xs font-semibold uppercase tracking-wide mb-2 text-content-muted">
              {t('dashboard.confirm.copy.wontCopy')}
            </p>
            <ul className="flex flex-col gap-1">
              {WONT_COPY_KEYS.map(key => (
                <li key={key} className="flex items-center gap-2 text-sm text-content-secondary">
                  <X size={13} className="flex-shrink-0 text-content-muted" />
                  {t(key)}
                </li>
              ))}
            </ul>
          </div>
        </div>

        <div className="flex justify-end gap-3 mt-5">
          <button
            onClick={onClose}
            className="px-4 py-2 text-sm font-medium rounded-lg transition-colors text-content-secondary border border-edge-secondary"
          >
            {t('common.cancel')}
          </button>
          <button
            onClick={() => { onConfirm(); onClose() }}
            className="px-4 py-2 text-sm font-medium rounded-lg transition-opacity hover:opacity-90 bg-content text-surface-card"
          >
            {t('dashboard.confirm.copy.confirm')}
          </button>
        </div>
      </div>
    </div>,
    document.body
  )
}