@prenta/admin 2.14.5 → 2.14.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -292,6 +292,21 @@ describe('FormEntries (All Entries)', () => {
292
292
  await waitFor(() => expect(fetchEntry).toHaveBeenCalledWith('e1'))
293
293
  })
294
294
 
295
+ it('keeps a short Message card tight against Submission (#1127)', async () => {
296
+ render(<FormEntries onNavigate={() => {}} />)
297
+ fireEvent.click(await screen.findByRole('article', { name: /Jordan Avery/ }))
298
+
299
+ const message = await screen.findByRole('heading', { name: /^Message/ })
300
+ const submission = screen.getByRole('heading', { name: /^Submission/ })
301
+ const attribution = screen.getByRole('button', { name: /Attribution & technical/ })
302
+ const stack = message.closest('article')?.parentElement
303
+ expect(stack).toBe(submission.closest('article')?.parentElement)
304
+ expect(stack?.className).toContain('col-start-1')
305
+ const aside = attribution.closest('article')
306
+ expect(aside?.parentElement).toBe(stack?.parentElement)
307
+ expect(aside?.className).not.toContain('row-span-3')
308
+ })
309
+
295
310
  it('shows the attribution an entry was captured with', async () => {
296
311
  const attributed = makeEntry({
297
312
  attribution: { channel: 'paid', source: 'google', clickIds: { gclid: 'abc123' } },
@@ -375,7 +390,7 @@ it('keeps checkbox selection separate from opening an entry', async () => {
375
390
  expect(screen.getByRole('heading', { name: 'No entry selected' })).toBeTruthy()
376
391
  })
377
392
 
378
- it('puts the message in a card and reveals contact and empty fields on demand', async () => {
393
+ it('puts the message in a card and lists every other submission field', async () => {
379
394
  const entry = makeEntry({
380
395
  unread: false,
381
396
  data: {
@@ -395,17 +410,12 @@ it('puts the message in a card and reveals contact and empty fields on demand',
395
410
  const card = heading.closest('article')!
396
411
  expect(within(card).getByText('A project description')).toBeTruthy()
397
412
  const submission = screen.getByRole('heading', { name: /Submission/ }).closest('article')!
398
- expect(within(submission).queryByText('Email')).toBeNull()
399
- expect(within(submission).queryByText('Company')).toBeNull()
400
- expect(within(submission).getByText('$500')).toBeTruthy()
401
- expect(within(submission).queryByText('A project description')).toBeNull()
402
- fireEvent.click(
403
- within(submission).getByRole('button', { name: 'Show all fields (2 shown above, 1 empty)' }),
404
- )
405
413
  expect(within(submission).getByText('Email')).toBeTruthy()
406
414
  expect(within(submission).getByText('Not answered')).toBeTruthy()
407
- fireEvent.click(within(submission).getByRole('button', { name: 'Show fewer fields' }))
408
- expect(within(submission).queryByText('Email')).toBeNull()
415
+ expect(within(submission).getByText('$500')).toBeTruthy()
416
+ expect(within(submission).queryByText('A project description')).toBeNull()
417
+ expect(within(submission).queryByRole('button', { name: /Show all fields/ })).toBeNull()
418
+ expect(within(submission).queryByRole('button', { name: 'Show fewer fields' })).toBeNull()
409
419
  })
410
420
 
411
421
  it('shortens landing URLs without changing their destination and hides Direct source text', async () => {
@@ -444,7 +454,6 @@ it('keeps a surname visible when the contact header only displays the first name
444
454
  'article',
445
455
  )!
446
456
  expect(within(submission).getByText('Avery')).toBeTruthy()
447
- expect(
448
- within(submission).getByRole('button', { name: 'Show all fields (2 shown above)' }),
449
- ).toBeTruthy()
457
+ expect(within(submission).getByText('jordan@example.com')).toBeTruthy()
458
+ expect(within(submission).queryByRole('button', { name: /Show all fields/ })).toBeNull()
450
459
  })
@@ -2087,7 +2087,6 @@ function EntryDetail({
2087
2087
  const [fields, setFields] = useState<FormField[]>([])
2088
2088
  const [otherCount, setOtherCount] = useState<number>(entry.otherEntryCount ?? 0)
2089
2089
  const [metaOpen, setMetaOpen] = useState(true)
2090
- const [showAllFields, setShowAllFields] = useState(false)
2091
2090
  const [noteText, setNoteText] = useState('')
2092
2091
  const notes = entry.notes ?? []
2093
2092
  const index = list.findIndex((item) => item.id === entry.id)
@@ -2107,7 +2106,6 @@ function EntryDetail({
2107
2106
  )
2108
2107
 
2109
2108
  useEffect(() => {
2110
- setShowAllFields(false)
2111
2109
  setNoteText('')
2112
2110
  setOtherCount(entry.otherEntryCount ?? 0)
2113
2111
  let cancelled = false
@@ -2163,33 +2161,6 @@ function EntryDetail({
2163
2161
  () => present.filter(({ key }) => key !== msgEntry?.key),
2164
2162
  [present, msgEntry],
2165
2163
  )
2166
- // Collapse only values actually represented by the contact header. Some
2167
- // legacy submissions store a first name as senderName without the surname.
2168
- const headerFieldKeys = new Set(
2169
- ['name', 'first_name', 'last_name', 'full_name'].filter((key) => {
2170
- const value = displayValue(entry.data[key]).trim().toLocaleLowerCase()
2171
- return value && ` ${name.toLocaleLowerCase()} `.includes(` ${value} `)
2172
- }),
2173
- )
2174
- if (email && displayValue(entry.data.email) === email) headerFieldKeys.add('email')
2175
- if (phone && displayValue(entry.data.phone) === phone) headerFieldKeys.add('phone')
2176
- if (website) headerFieldKeys.add('website')
2177
- const hiddenHeaderRows = submissionRows.filter(({ key }) => headerFieldKeys.has(key))
2178
- const emptyRows = submissionRows.filter(({ key }) => !displayValue(entry.data[key]))
2179
- const visibleRows = showAllFields
2180
- ? submissionRows
2181
- : submissionRows.filter(
2182
- ({ key }) => !headerFieldKeys.has(key) && Boolean(displayValue(entry.data[key])),
2183
- )
2184
- const hiddenHeaderCount = hiddenHeaderRows.filter(({ key }) =>
2185
- displayValue(entry.data[key]),
2186
- ).length
2187
- const hiddenFieldSummary = [
2188
- hiddenHeaderCount ? `${hiddenHeaderCount} shown above` : '',
2189
- emptyRows.length ? `${emptyRows.length} empty` : '',
2190
- ]
2191
- .filter(Boolean)
2192
- .join(', ')
2193
2164
  const messageTitle = msgEntry
2194
2165
  ? (
2195
2166
  {
@@ -2789,154 +2760,147 @@ function EntryDetail({
2789
2760
  </div>
2790
2761
  </div>
2791
2762
 
2792
- {/* Grey body area: cards */}
2763
+ {/* Grey body area: cards. The left stack is one grid cell so a short
2764
+ Message card does not inherit the height of the attribution column. */}
2793
2765
  <div className="mx-auto max-w-[860px] px-8 pt-[22px] pb-12 max-[900px]:px-4 max-[900px]:pt-4 max-[900px]:pb-10 @[1240px]:grid @[1240px]:max-w-[1180px] @[1240px]:grid-cols-[minmax(0,1fr)_400px] @[1240px]:items-start @[1240px]:gap-x-5">
2794
- {msgEntry ? (
2795
- <article
2796
- className="group border-bdr bg-card shadow-shd mb-3.5 overflow-hidden rounded-[10px] border @[1240px]:col-start-1"
2797
- aria-labelledby="d-msg-l"
2798
- >
2799
- <h3
2800
- id="d-msg-l"
2801
- className="border-bdr text-txt m-0 flex items-center gap-2 border-b px-5 py-3 text-[13px] font-semibold"
2766
+ <div className="min-w-0 @[1240px]:col-start-1 @[1240px]:row-start-1">
2767
+ {msgEntry ? (
2768
+ <article
2769
+ className="group border-bdr bg-card shadow-shd mb-3.5 overflow-hidden rounded-[10px] border"
2770
+ aria-labelledby="d-msg-l"
2802
2771
  >
2803
- {messageTitle}
2804
- <button
2805
- type="button"
2806
- title={`Copy ${messageTitle}`}
2807
- aria-label={`Copy ${messageTitle}`}
2808
- onClick={() => copyValue(msgText)}
2809
- className="text-faint hover:bg-acc-l hover:text-acc ml-auto inline-flex size-6 items-center justify-center rounded-[6px] opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100"
2772
+ <h3
2773
+ id="d-msg-l"
2774
+ className="border-bdr text-txt m-0 flex items-center gap-2 border-b px-5 py-3 text-[13px] font-semibold"
2810
2775
  >
2811
- <Copy size={13} aria-hidden />
2812
- </button>
2813
- </h3>
2814
- <div
2815
- dir="auto"
2816
- className="text-txt px-5 pt-4 pb-5 text-[15px] leading-[1.7] [text-wrap:pretty] break-words whitespace-pre-wrap"
2817
- >
2818
- {formatFieldDisplay(msgEntry.key, msgText, fieldMap.get(msgEntry.key))}
2819
- </div>
2820
- </article>
2821
- ) : null}
2822
- {/* Submission card */}
2823
- <article className="border-bdr bg-card shadow-shd mb-3.5 overflow-hidden rounded-[10px] border @[1240px]:col-start-1">
2824
- <h3 className="border-bdr text-faint m-0 flex items-center gap-2 border-b px-5 py-3 text-[11px] font-bold tracking-[0.6px] uppercase">
2825
- Submission
2826
- <span className="ml-auto text-[11.5px] font-semibold tracking-normal normal-case">
2827
- {answeredCount} of {present.length} answered
2828
- </span>
2829
- </h3>
2830
- <dl className="divide-bdr m-0 divide-y">
2831
- {visibleRows.map(({ key, label }) => {
2832
- const raw = displayValue(entry.data[key])
2833
- const formatted = formatFieldDisplay(key, raw, fieldMap.get(key))
2834
- return (
2835
- <DetailRow
2836
- key={key}
2837
- label={label}
2838
- copyText={formatted || undefined}
2839
- onCopy={copyValue}
2776
+ {messageTitle}
2777
+ <button
2778
+ type="button"
2779
+ title={`Copy ${messageTitle}`}
2780
+ aria-label={`Copy ${messageTitle}`}
2781
+ onClick={() => copyValue(msgText)}
2782
+ className="text-faint hover:bg-acc-l hover:text-acc ml-auto inline-flex size-6 items-center justify-center rounded-[6px] opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100"
2840
2783
  >
2841
- {formatted || <span className="text-faint">Not answered</span>}
2842
- </DetailRow>
2843
- )
2844
- })}
2845
- </dl>
2846
- {hiddenFieldSummary ? (
2847
- <button
2848
- type="button"
2849
- aria-expanded={showAllFields}
2850
- onClick={() => setShowAllFields((v) => !v)}
2851
- className="border-bdr text-acc hover:bg-acc-l block w-full cursor-pointer border-0 border-t bg-transparent px-5 py-2.5 text-left text-[12.5px] font-medium"
2852
- >
2853
- {showAllFields ? 'Show fewer fields' : `Show all fields (${hiddenFieldSummary})`}
2854
- </button>
2784
+ <Copy size={13} aria-hidden />
2785
+ </button>
2786
+ </h3>
2787
+ <div
2788
+ dir="auto"
2789
+ className="text-txt px-5 pt-4 pb-5 text-[15px] leading-[1.7] [text-wrap:pretty] break-words whitespace-pre-wrap"
2790
+ >
2791
+ {formatFieldDisplay(msgEntry.key, msgText, fieldMap.get(msgEntry.key))}
2792
+ </div>
2793
+ </article>
2855
2794
  ) : null}
2856
- </article>
2857
-
2858
- {/* Team notes card */}
2859
- {entry.spamStatus !== 'spam' && !entry.partial ? (
2860
- <article className="border-bdr bg-card shadow-shd mb-3.5 overflow-hidden rounded-[10px] border @[1240px]:col-start-1">
2795
+ {/* Submission card */}
2796
+ <article className="border-bdr bg-card shadow-shd mb-3.5 overflow-hidden rounded-[10px] border">
2861
2797
  <h3 className="border-bdr text-faint m-0 flex items-center gap-2 border-b px-5 py-3 text-[11px] font-bold tracking-[0.6px] uppercase">
2862
- Team notes
2798
+ Submission
2863
2799
  <span className="ml-auto text-[11.5px] font-semibold tracking-normal normal-case">
2864
- {notes.length} {notes.length === 1 ? 'note' : 'notes'}
2800
+ {answeredCount} of {present.length} answered
2865
2801
  </span>
2866
2802
  </h3>
2867
- <div className="flex flex-col gap-3.5 px-5 pt-3.5 pb-4">
2868
- {notes.map((n, idx) => {
2869
- const author =
2870
- team.find((t) => t.id === n.authorId)?.name ||
2871
- n.authorName ||
2872
- n.authorId ||
2873
- 'Team'
2803
+ <dl className="divide-bdr m-0 divide-y">
2804
+ {submissionRows.map(({ key, label }) => {
2805
+ const raw = displayValue(entry.data[key])
2806
+ const formatted = formatFieldDisplay(key, raw, fieldMap.get(key))
2874
2807
  return (
2875
- <div key={idx} className="flex gap-2.5">
2876
- <span
2877
- className="flex size-[26px] shrink-0 items-center justify-center rounded-full text-[11px] font-bold"
2878
- style={{ background: avatarColor(author), color: 'var(--on-avatar)' }}
2879
- >
2880
- {initials(author)}
2881
- </span>
2882
- <div className="min-w-0 flex-1">
2883
- <div className="flex items-baseline gap-2 text-[12.5px]">
2884
- <b className="text-txt font-semibold">{author}</b>
2885
- <span className="text-faint text-[11.5px]">{fullEntryTime(n.at)}</span>
2886
- </div>
2887
- <div className="text-txt mt-0.5 text-[13px] leading-[1.5] whitespace-pre-wrap">
2888
- {n.text}
2889
- </div>
2890
- </div>
2891
- </div>
2808
+ <DetailRow
2809
+ key={key}
2810
+ label={label}
2811
+ copyText={formatted || undefined}
2812
+ onCopy={copyValue}
2813
+ >
2814
+ {formatted || <span className="text-faint">Not answered</span>}
2815
+ </DetailRow>
2892
2816
  )
2893
2817
  })}
2894
- {notes.length === 0 ? (
2895
- <div className="text-faint text-[12.5px]">
2896
- No notes yet. Notes are only visible to your team.
2897
- </div>
2898
- ) : null}
2899
- <div className="border-bdr flex gap-2.5 border-t pt-3">
2900
- <span
2901
- className="flex size-[26px] shrink-0 items-center justify-center rounded-full text-[11px] font-bold"
2902
- style={{ background: avatarColor(currentUserName), color: 'var(--on-avatar)' }}
2903
- >
2904
- {initials(currentUserName)}
2818
+ </dl>
2819
+ </article>
2820
+
2821
+ {/* Team notes card */}
2822
+ {entry.spamStatus !== 'spam' && !entry.partial ? (
2823
+ <article className="border-bdr bg-card shadow-shd mb-3.5 overflow-hidden rounded-[10px] border">
2824
+ <h3 className="border-bdr text-faint m-0 flex items-center gap-2 border-b px-5 py-3 text-[11px] font-bold tracking-[0.6px] uppercase">
2825
+ Team notes
2826
+ <span className="ml-auto text-[11.5px] font-semibold tracking-normal normal-case">
2827
+ {notes.length} {notes.length === 1 ? 'note' : 'notes'}
2905
2828
  </span>
2906
- <div className="min-w-0 flex-1">
2907
- <textarea
2908
- rows={2}
2909
- value={noteText}
2910
- placeholder="Add a note for your team…"
2911
- aria-label="Add a note"
2912
- onChange={(e) => setNoteText(e.target.value)}
2913
- onKeyDown={(e) => {
2914
- if (e.key === 'Enter' && (e.metaKey || e.ctrlKey) && noteText.trim()) {
2915
- e.preventDefault()
2916
- addNote()
2917
- }
2918
- }}
2919
- className="border-bdr bg-card text-txt focus-visible:outline-acc min-h-[58px] w-full resize-y rounded-[9px] border px-2.5 py-2 text-[13px] leading-[1.45] focus-visible:outline focus-visible:outline-offset-2"
2920
- />
2921
- <div className="text-faint mt-1.5 flex items-center gap-2.5 text-[11.5px]">
2922
- <span className="flex-1">⌘ Enter to save · only visible to your team</span>
2923
- <button
2924
- type="button"
2925
- disabled={!noteText.trim()}
2926
- onClick={addNote}
2927
- className="bg-acc inline-flex items-center gap-1.5 rounded-[8px] px-[15px] py-2 text-[13px] font-medium text-[var(--on-acc)] disabled:cursor-not-allowed disabled:opacity-45"
2928
- >
2929
- Add note
2930
- </button>
2829
+ </h3>
2830
+ <div className="flex flex-col gap-3.5 px-5 pt-3.5 pb-4">
2831
+ {notes.map((n, idx) => {
2832
+ const author =
2833
+ team.find((t) => t.id === n.authorId)?.name ||
2834
+ n.authorName ||
2835
+ n.authorId ||
2836
+ 'Team'
2837
+ return (
2838
+ <div key={idx} className="flex gap-2.5">
2839
+ <span
2840
+ className="flex size-[26px] shrink-0 items-center justify-center rounded-full text-[11px] font-bold"
2841
+ style={{ background: avatarColor(author), color: 'var(--on-avatar)' }}
2842
+ >
2843
+ {initials(author)}
2844
+ </span>
2845
+ <div className="min-w-0 flex-1">
2846
+ <div className="flex items-baseline gap-2 text-[12.5px]">
2847
+ <b className="text-txt font-semibold">{author}</b>
2848
+ <span className="text-faint text-[11.5px]">{fullEntryTime(n.at)}</span>
2849
+ </div>
2850
+ <div className="text-txt mt-0.5 text-[13px] leading-[1.5] whitespace-pre-wrap">
2851
+ {n.text}
2852
+ </div>
2853
+ </div>
2854
+ </div>
2855
+ )
2856
+ })}
2857
+ {notes.length === 0 ? (
2858
+ <div className="text-faint text-[12.5px]">
2859
+ No notes yet. Notes are only visible to your team.
2860
+ </div>
2861
+ ) : null}
2862
+ <div className="border-bdr flex gap-2.5 border-t pt-3">
2863
+ <span
2864
+ className="flex size-[26px] shrink-0 items-center justify-center rounded-full text-[11px] font-bold"
2865
+ style={{ background: avatarColor(currentUserName), color: 'var(--on-avatar)' }}
2866
+ >
2867
+ {initials(currentUserName)}
2868
+ </span>
2869
+ <div className="min-w-0 flex-1">
2870
+ <textarea
2871
+ rows={2}
2872
+ value={noteText}
2873
+ placeholder="Add a note for your team…"
2874
+ aria-label="Add a note"
2875
+ onChange={(e) => setNoteText(e.target.value)}
2876
+ onKeyDown={(e) => {
2877
+ if (e.key === 'Enter' && (e.metaKey || e.ctrlKey) && noteText.trim()) {
2878
+ e.preventDefault()
2879
+ addNote()
2880
+ }
2881
+ }}
2882
+ className="border-bdr bg-card text-txt focus-visible:outline-acc min-h-[58px] w-full resize-y rounded-[9px] border px-2.5 py-2 text-[13px] leading-[1.45] focus-visible:outline focus-visible:outline-offset-2"
2883
+ />
2884
+ <div className="text-faint mt-1.5 flex items-center gap-2.5 text-[11.5px]">
2885
+ <span className="flex-1">⌘ Enter to save · only visible to your team</span>
2886
+ <button
2887
+ type="button"
2888
+ disabled={!noteText.trim()}
2889
+ onClick={addNote}
2890
+ className="bg-acc inline-flex items-center gap-1.5 rounded-[8px] px-[15px] py-2 text-[13px] font-medium text-[var(--on-acc)] disabled:cursor-not-allowed disabled:opacity-45"
2891
+ >
2892
+ Add note
2893
+ </button>
2894
+ </div>
2931
2895
  </div>
2932
2896
  </div>
2933
2897
  </div>
2934
- </div>
2935
- </article>
2936
- ) : null}
2898
+ </article>
2899
+ ) : null}
2900
+ </div>
2937
2901
 
2938
2902
  {/* Attribution & technical card */}
2939
- <article className="border-bdr bg-card shadow-shd mb-3.5 overflow-hidden rounded-[10px] border @[1240px]:sticky @[1240px]:top-[68px] @[1240px]:col-start-2 @[1240px]:row-span-3 @[1240px]:row-start-1">
2903
+ <article className="border-bdr bg-card shadow-shd mb-3.5 overflow-hidden rounded-[10px] border @[1240px]:sticky @[1240px]:top-[68px] @[1240px]:col-start-2 @[1240px]:row-start-1">
2940
2904
  <h3 className="m-0">
2941
2905
  <button
2942
2906
  type="button"