11import  {  invariantResponse  }  from  '@epic-web/invariant' 
22import  {  type  SEOHandle  }  from  '@nasa-gcn/remix-seo' 
33import  {  useState  }  from  'react' 
4- import  { 
5- 	data , 
6- 	type  LoaderFunctionArgs , 
7- 	type  ActionFunctionArgs , 
8- 	type  HeadersFunction , 
9- 	useFetcher , 
10- 	useLoaderData , 
11- }  from  'react-router' 
4+ import  {  data ,  useFetcher  }  from  'react-router' 
125import  {  Icon  }  from  '#app/components/ui/icon.tsx' 
136import  {  StatusButton  }  from  '#app/components/ui/status-button.tsx' 
147import  { 
@@ -29,6 +22,7 @@ import {
2922import  {  prisma  }  from  '#app/utils/db.server.ts' 
3023import  {  makeTimings  }  from  '#app/utils/timing.server.ts' 
3124import  {  createToastHeaders  }  from  '#app/utils/toast.server.ts' 
25+ import  {  type  Info ,  type  Route  }  from  './+types/profile.connections.ts' 
3226import  {  type  BreadcrumbHandle  }  from  './profile.tsx' 
3327
3428export  const  handle : BreadcrumbHandle  &  SEOHandle  =  { 
@@ -50,7 +44,7 @@ async function userCanDeleteConnections(userId: string) {
5044	return  Boolean ( user ?. _count . connections  &&  user ?. _count . connections  >  1 ) 
5145} 
5246
53- export  async  function  loader ( {  request } : LoaderFunctionArgs )  { 
47+ export  async  function  loader ( {  request } : Route . LoaderArgs )  { 
5448	const  userId  =  await  requireUserId ( request ) 
5549	const  timings  =  makeTimings ( 'profile connections loader' ) 
5650	const  rawConnections  =  await  prisma . connection . findMany ( { 
@@ -90,14 +84,14 @@ export async function loader({ request }: LoaderFunctionArgs) {
9084	) 
9185} 
9286
93- export  const  headers :  HeadersFunction   =   ( {  loaderHeaders } )   =>  { 
87+ export  function  headers ( {  loaderHeaders } :  Route . HeadersArgs )  { 
9488	const  headers  =  { 
9589		'Server-Timing' : loaderHeaders . get ( 'Server-Timing' )  ??  '' , 
9690	} 
9791	return  headers 
9892} 
9993
100- export  async  function  action ( {  request } : ActionFunctionArgs )  { 
94+ export  async  function  action ( {  request } : Route . ActionArgs )  { 
10195	const  userId  =  await  requireUserId ( request ) 
10296	const  formData  =  await  request . formData ( ) 
10397	invariantResponse ( 
@@ -123,20 +117,18 @@ export async function action({ request }: ActionFunctionArgs) {
123117	return  data ( {  status : 'success'  }  as  const ,  {  headers : toastHeaders  } ) 
124118} 
125119
126- export  default  function  Connections ( )  { 
127- 	const  data  =  useLoaderData < typeof  loader > ( ) 
128- 
120+ export  default  function  Connections ( {  loaderData } : Route . ComponentProps )  { 
129121	return  ( 
130122		< div  className = "mx-auto max-w-md" > 
131- 			{ data . connections . length  ? ( 
123+ 			{ loaderData . connections . length  ? ( 
132124				< div  className = "flex flex-col gap-2" > 
133125					< p > Here are your current connections:</ p > 
134126					< ul  className = "flex flex-col gap-4" > 
135- 						{ data . connections . map ( ( c )  =>  ( 
127+ 						{ loaderData . connections . map ( ( c )  =>  ( 
136128							< li  key = { c . id } > 
137129								< Connection 
138130									connection = { c } 
139- 									canDelete = { data . canDeleteConnections } 
131+ 									canDelete = { loaderData . canDeleteConnections } 
140132								/> 
141133							</ li > 
142134						) ) } 
@@ -158,13 +150,11 @@ export default function Connections() {
158150	) 
159151} 
160152
161- type  SerializeFrom < T >  =  ReturnType < typeof  useLoaderData < T > > 
162- 
163153function  Connection ( { 
164154	connection, 
165155	canDelete, 
166156} : { 
167- 	connection : SerializeFrom < typeof   loader > [ 'connections' ] [ number ] 
157+ 	connection : Info [ 'loaderData' ] [ 'connections' ] [ number ] 
168158	canDelete : boolean 
169159} )  { 
170160	const  deleteFetcher  =  useFetcher < typeof  action > ( ) 
0 commit comments