import PageContainer from '@/components/layout/page-container';
import UsersAdminList from '@/feactures/inventory/components/inventory/product-inventory-list';
import { UsersHeader } from '@/feactures/inventory/components/inventory/users-header';
import UsersTableAction from '@/feactures/inventory/components/inventory/product-tables/users-table-action';
import { searchParamsCache, serialize } from '@/feactures/inventory/utils/searchparams';
import { SearchParams } from 'nuqs';

type pageProps = {
  searchParams: Promise<SearchParams>;
};


export default async function SurveyAdminPage(props: pageProps) {
  const searchParams = await props.searchParams;
  searchParamsCache.parse(searchParams);
  const key = serialize({ ...searchParams });

  const page = Number(searchParamsCache.get('page')) || 1;
  const search = searchParamsCache.get('q');
  const pageLimit = Number(searchParamsCache.get('limit')) || 10;
  const type = searchParamsCache.get('type');

  return (
    <PageContainer scrollable={false}>
      <div className="flex flex-1 flex-col space-y-4">
        <UsersHeader />
        <UsersTableAction />
        <UsersAdminList
          initialPage={page}
          initialSearch={search}
          initialLimit={pageLimit}
          initialType={type}
        />
      </div>
    </PageContainer>
  );
}