@@ -3,7 +3,7 @@ import { dataTableRouterParsers } from '@lambdacurry/forms/remix-hook-form/data-
33import { DataTableColumnHeader } from '@lambdacurry/forms/ui/data-table/data-table-column-header' ;
44import type { Meta , StoryObj } from '@storybook/react' ;
55import type { ColumnDef } from '@tanstack/react-table' ;
6- import { type ActionFunctionArgs , useLoaderData } from 'react-router' ;
6+ import { type LoaderFunctionArgs , useLoaderData } from 'react-router' ;
77import { z } from 'zod' ;
88import { withReactRouterStubDecorator } from '../lib/storybook/react-router-stub' ;
99
@@ -135,7 +135,8 @@ function DataTableRouterFormExample() {
135135 ) ;
136136}
137137
138- const handleDataFetch = async ( { request } : ActionFunctionArgs ) => {
138+ // Loader function to handle data fetching based on URL parameters
139+ const handleDataFetch = async ( { request } : LoaderFunctionArgs ) => {
139140 // Add a small delay to simulate network latency
140141 await new Promise ( resolve => setTimeout ( resolve , 300 ) ) ;
141142
@@ -198,6 +199,7 @@ const handleDataFetch = async ({ request }: ActionFunctionArgs) => {
198199 // Log the data being returned for debugging
199200 console . log ( `Returning ${ paginatedData . length } items, page ${ safePage } , total ${ filteredData . length } ` ) ;
200201
202+ // Return the data response
201203 return {
202204 data : paginatedData ,
203205 meta : {
@@ -222,7 +224,6 @@ const meta = {
222224 path : '/' ,
223225 Component : DataTableRouterFormExample ,
224226 loader : handleDataFetch ,
225- action : handleDataFetch , // Add action to handle form submissions
226227 } ,
227228 ] ,
228229 } ) ,
0 commit comments