@@ -4,7 +4,7 @@ import type { RouterOutputs } from "@cossistant/api/types";
44import { resolveCountryDetails } from "@cossistant/location/country-utils" ;
55import type { ContactDetailResponse } from "@cossistant/types" ;
66import { useQueryNormalizer } from "@normy/react-query" ;
7- import { useQueries , useQuery } from "@tanstack/react-query" ;
7+ import * as ReactQuery from "@tanstack/react-query" ;
88import { Monitor , Smartphone } from "lucide-react" ;
99import { useMemo } from "react" ;
1010import { Globe , type GlobeFocus , type GlobeVisitor } from "@/components/globe" ;
@@ -29,6 +29,10 @@ import { formatFullDateTime, formatLastSeenAt } from "@/lib/date";
2929import { useTRPC } from "@/lib/trpc/client" ;
3030import { cn } from "@/lib/utils" ;
3131import { getVisitorNameWithFallback } from "@/lib/visitors" ;
32+ import {
33+ DashboardOverlayCenteredState ,
34+ DashboardOverlayShell ,
35+ } from "./dashboard-overlay-shell" ;
3236
3337type ContactDetail = RouterOutputs [ "contact" ] [ "get" ] ;
3438type DetailContact = ContactDetailResponse [ "contact" ] ;
@@ -525,24 +529,6 @@ function DetailMetric({ label, tooltip, value }: DetailMetricProps) {
525529 return < TooltipOnHover content = { tooltip } > { content } </ TooltipOnHover > ;
526530}
527531
528- function DetailOverlayShell ( {
529- children,
530- mode,
531- } : {
532- children : React . ReactNode ;
533- mode : "contact" | "visitor" ;
534- } ) {
535- return (
536- < div
537- className = "absolute inset-x-0 top-15 bottom-0 z-20 flex flex-col overflow-hidden bg-background"
538- data-mode = { mode }
539- data-slot = "contact-visitor-detail-overlay"
540- >
541- { children }
542- </ div >
543- ) ;
544- }
545-
546532function DevicesSection ( {
547533 deviceDetailsById,
548534 heroVisitor,
@@ -957,20 +943,26 @@ export function ContactVisitorDetailView({
957943
958944 if ( isLoading ) {
959945 return (
960- < DetailOverlayShell mode = { mode } >
961- < div className = "flex h-full items-center justify-center" >
946+ < DashboardOverlayShell
947+ data-mode = { mode }
948+ dataSlot = "contact-visitor-detail-overlay"
949+ >
950+ < DashboardOverlayCenteredState >
962951 < div className = "flex items-center gap-3 text-primary/60 text-sm" >
963952 < Spinner className = "h-5 w-5" />
964953 < span > Loading details...</ span >
965954 </ div >
966- </ div >
967- </ DetailOverlayShell >
955+ </ DashboardOverlayCenteredState >
956+ </ DashboardOverlayShell >
968957 ) ;
969958 }
970959
971960 if ( isError ) {
972961 return (
973- < DetailOverlayShell mode = { mode } >
962+ < DashboardOverlayShell
963+ data-mode = { mode }
964+ dataSlot = "contact-visitor-detail-overlay"
965+ >
974966 < div className = "px-4 py-6 lg:px-6 lg:py-8" >
975967 < Alert variant = "destructive" >
976968 < AlertTitle > Unable to load details</ AlertTitle >
@@ -980,22 +972,28 @@ export function ContactVisitorDetailView({
980972 </ AlertDescription >
981973 </ Alert >
982974 </ div >
983- </ DetailOverlayShell >
975+ </ DashboardOverlayShell >
984976 ) ;
985977 }
986978
987979 if ( ! ( contact || heroVisitor ) && visitors . length === 0 ) {
988980 return (
989- < DetailOverlayShell mode = { mode } >
990- < div className = "flex h-full items-center justify-center px-6 text-center text-primary/60 text-sm" >
981+ < DashboardOverlayShell
982+ data-mode = { mode }
983+ dataSlot = "contact-visitor-detail-overlay"
984+ >
985+ < DashboardOverlayCenteredState className = "px-6 text-center text-primary/60 text-sm" >
991986 No details are available for this selection.
992- </ div >
993- </ DetailOverlayShell >
987+ </ DashboardOverlayCenteredState >
988+ </ DashboardOverlayShell >
994989 ) ;
995990 }
996991
997992 return (
998- < DetailOverlayShell mode = { mode } >
993+ < DashboardOverlayShell
994+ data-mode = { mode }
995+ dataSlot = "contact-visitor-detail-overlay"
996+ >
999997 < div
1000998 className = "grid h-full grid-cols-1 lg:grid-cols-2"
1001999 data-slot = "contact-visitor-detail-layout"
@@ -1019,7 +1017,7 @@ export function ContactVisitorDetailView({
10191017 visitors = { visitors }
10201018 />
10211019 </ div >
1022- </ DetailOverlayShell >
1020+ </ DashboardOverlayShell >
10231021 ) ;
10241022}
10251023
@@ -1044,7 +1042,7 @@ export function ContactVisitorDetailOverlay() {
10441042 return isContactDetailResponse ( candidate ) ? candidate : undefined ;
10451043 } , [ activeContactId , queryNormalizer ] ) ;
10461044
1047- const contactQuery = useQuery ( {
1045+ const contactQuery = ReactQuery . useQuery ( {
10481046 ...trpc . contact . get . queryOptions ( {
10491047 contactId : activeContactId ?? "" ,
10501048 websiteSlug : website . slug ,
@@ -1064,7 +1062,7 @@ export function ContactVisitorDetailOverlay() {
10641062 return queryNormalizer . getObjectById < VisitorDetail > ( leadVisitorId ) ;
10651063 } , [ leadVisitorId , queryNormalizer ] ) ;
10661064
1067- const visitorQuery = useQuery ( {
1065+ const visitorQuery = ReactQuery . useQuery ( {
10681066 ...trpc . conversation . getVisitorById . queryOptions ( {
10691067 visitorId : leadVisitorId ?? "" ,
10701068 websiteSlug : website . slug ,
@@ -1076,7 +1074,7 @@ export function ContactVisitorDetailOverlay() {
10761074 } ) ;
10771075 const resolvedHeroVisitor = visitorQuery . data ?? null ;
10781076
1079- const contactVisitorDetailsQueries = useQueries ( {
1077+ const contactVisitorDetailsQueries = ReactQuery . useQueries ( {
10801078 queries :
10811079 activeDetail ?. type === "contact"
10821080 ? ( contactQuery . data ?. visitors ?? [ ] ) . map ( ( visitor ) => ( {
0 commit comments