import PageContainer from '@/components/layout/page-container';
import UsersAdminList from '@/feactures/users/components/admin/users-admin-list';
import { UsersHeader } from '@/feactures/users/components/admin/users-header';
import UsersTableAction from '@/feactures/users/components/admin/surveys-tables/users-table-action';
import { searchParamsCache, serialize } from '@/feactures/users/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>
  );
}