``refactor Standardize status/state naming across students, teachers, and user metas pages, update filters and tabs to use 'state' parameter consistently
``
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// src/app/dashboard/students/list/page.tsx
|
||||
'use client';
|
||||
|
||||
// src/app/dashboard/students/list/page.tsx
|
||||
//
|
||||
// RULES:
|
||||
// contains list page for students (Students)
|
||||
//
|
||||
@@ -15,12 +16,6 @@ import Stack from '@mui/material/Stack';
|
||||
import Typography from '@mui/material/Typography';
|
||||
import { Plus as PlusIcon } from '@phosphor-icons/react/dist/ssr/Plus';
|
||||
import type { ListResult, RecordModel } from 'pocketbase';
|
||||
|
||||
import { StudentsFilters } from '@/components/dashboard/student/students-filters';
|
||||
import { StudentsPagination } from '@/components/dashboard/student/students-pagination';
|
||||
import { StudentsSelectionProvider } from '@/components/dashboard/student/students-selection-context';
|
||||
import { StudentsTable } from '@/components/dashboard/student/students-table';
|
||||
import type { Student } from '@/components/dashboard/student/type.d';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { paths } from '@/paths';
|
||||
@@ -29,13 +24,18 @@ import { logger } from '@/lib/default-logger';
|
||||
import { pb } from '@/lib/pb';
|
||||
import ErrorDisplay from '@/components/dashboard/error';
|
||||
import { defaultStudent } from '@/components/dashboard/student/_constants';
|
||||
import { StudentsFilters } from '@/components/dashboard/student/students-filters';
|
||||
import { StudentsPagination } from '@/components/dashboard/student/students-pagination';
|
||||
import { StudentsSelectionProvider } from '@/components/dashboard/student/students-selection-context';
|
||||
import { StudentsTable } from '@/components/dashboard/student/students-table';
|
||||
import type { Student } from '@/components/dashboard/student/type.d';
|
||||
import FormLoading from '@/components/loading';
|
||||
|
||||
export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
||||
const { t } = useTranslation(['students']);
|
||||
const router = useRouter();
|
||||
|
||||
const { email, phone, sortDir, status } = searchParams;
|
||||
const { email, phone, sortDir, state } = searchParams;
|
||||
|
||||
const [studentsData, setStudentsData] = React.useState<Student[]>([]);
|
||||
|
||||
@@ -104,8 +104,8 @@ export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
||||
const tempFilter = [];
|
||||
let tempSortDir = '';
|
||||
|
||||
if (status) {
|
||||
tempFilter.push(`status = "${status}"`);
|
||||
if (state) {
|
||||
tempFilter.push(`state = "${state}"`);
|
||||
}
|
||||
|
||||
if (sortDir) {
|
||||
@@ -128,7 +128,7 @@ export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
||||
preFinalListOption = { ...preFinalListOption, sort: tempSortDir };
|
||||
}
|
||||
setListOption(preFinalListOption);
|
||||
}, [sortDir, email, phone, status]);
|
||||
}, [sortDir, email, phone, state]);
|
||||
|
||||
if (showLoading) return <FormLoading />;
|
||||
|
||||
@@ -176,7 +176,7 @@ export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
||||
<StudentsSelectionProvider students={f}>
|
||||
<Card>
|
||||
<StudentsFilters
|
||||
filters={{ email, phone, status }}
|
||||
filters={{ email, phone, status: state }}
|
||||
fullData={studentsData}
|
||||
sortDir={sortDir}
|
||||
/>
|
||||
@@ -210,7 +210,7 @@ interface PageProps {
|
||||
email?: string;
|
||||
phone?: string;
|
||||
sortDir?: 'asc' | 'desc';
|
||||
status?: string;
|
||||
state?: string;
|
||||
//
|
||||
};
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
// src/app/dashboard/teachers/list/page.tsx
|
||||
'use client';
|
||||
|
||||
// src/app/dashboard/teachers/list/page.tsx
|
||||
//
|
||||
// RULES:
|
||||
// contains list page for teachers (Teachers)
|
||||
//
|
||||
@@ -15,12 +16,6 @@ import Stack from '@mui/material/Stack';
|
||||
import Typography from '@mui/material/Typography';
|
||||
import { Plus as PlusIcon } from '@phosphor-icons/react/dist/ssr/Plus';
|
||||
import type { ListResult, RecordModel } from 'pocketbase';
|
||||
|
||||
import { TeachersFilters } from '@/components/dashboard/teacher/teachers-filters';
|
||||
import { TeachersPagination } from '@/components/dashboard/teacher/teachers-pagination';
|
||||
import { TeachersSelectionProvider } from '@/components/dashboard/teacher/teachers-selection-context';
|
||||
import { TeachersTable } from '@/components/dashboard/teacher/teachers-table';
|
||||
import type { Teacher } from '@/components/dashboard/teacher/type.d';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { paths } from '@/paths';
|
||||
@@ -29,13 +24,18 @@ import { logger } from '@/lib/default-logger';
|
||||
import { pb } from '@/lib/pb';
|
||||
import ErrorDisplay from '@/components/dashboard/error';
|
||||
import { defaultTeacher } from '@/components/dashboard/teacher/_constants';
|
||||
import { TeachersFilters } from '@/components/dashboard/teacher/teachers-filters';
|
||||
import { TeachersPagination } from '@/components/dashboard/teacher/teachers-pagination';
|
||||
import { TeachersSelectionProvider } from '@/components/dashboard/teacher/teachers-selection-context';
|
||||
import { TeachersTable } from '@/components/dashboard/teacher/teachers-table';
|
||||
import type { Teacher } from '@/components/dashboard/teacher/type.d';
|
||||
import FormLoading from '@/components/loading';
|
||||
|
||||
export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
||||
const { t } = useTranslation(['teachers']);
|
||||
const router = useRouter();
|
||||
|
||||
const { email, phone, sortDir, status } = searchParams;
|
||||
const { email, phone, sortDir, state } = searchParams;
|
||||
|
||||
const [teacherData, setTeacherData] = React.useState<Teacher[]>([]);
|
||||
|
||||
@@ -103,11 +103,11 @@ export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
||||
}, [currentPage, rowsPerPage, listOption]);
|
||||
|
||||
React.useEffect(() => {
|
||||
let tempFilter = [];
|
||||
const tempFilter = [];
|
||||
let tempSortDir = '';
|
||||
|
||||
if (status) {
|
||||
tempFilter.push(`status = "${status}"`);
|
||||
if (state) {
|
||||
tempFilter.push(`state = "${state}"`);
|
||||
}
|
||||
|
||||
if (sortDir) {
|
||||
@@ -130,7 +130,7 @@ export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
||||
preFinalListOption = { ...preFinalListOption, sort: tempSortDir };
|
||||
}
|
||||
setListOption(preFinalListOption);
|
||||
}, [sortDir, email, phone, status]);
|
||||
}, [sortDir, email, phone, state]);
|
||||
|
||||
if (showLoading) return <FormLoading />;
|
||||
|
||||
@@ -178,7 +178,7 @@ export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
||||
<TeachersSelectionProvider teachers={f}>
|
||||
<Card>
|
||||
<TeachersFilters
|
||||
filters={{ email, phone, status }}
|
||||
filters={{ email, phone, state }}
|
||||
fullData={teacherData}
|
||||
sortDir={sortDir}
|
||||
/>
|
||||
@@ -212,7 +212,7 @@ interface PageProps {
|
||||
email?: string;
|
||||
phone?: string;
|
||||
sortDir?: 'asc' | 'desc';
|
||||
status?: string;
|
||||
state?: string;
|
||||
//
|
||||
};
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
||||
const { t } = useTranslation(['user_metas']);
|
||||
const router = useRouter();
|
||||
|
||||
const { email, phone, sortDir, status } = searchParams;
|
||||
const { email, phone, sortDir, state } = searchParams;
|
||||
|
||||
const [userMetaData, setUserMetaData] = React.useState<UserMeta[]>([]);
|
||||
|
||||
@@ -99,8 +99,8 @@ export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
||||
let tempFilter = [];
|
||||
let tempSortDir = '';
|
||||
|
||||
if (status) {
|
||||
tempFilter.push(`status = "${status}"`);
|
||||
if (state) {
|
||||
tempFilter.push(`state = "${state}"`);
|
||||
}
|
||||
|
||||
if (sortDir) {
|
||||
@@ -123,7 +123,7 @@ export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
||||
preFinalListOption = { ...preFinalListOption, sort: tempSortDir };
|
||||
}
|
||||
setListOption(preFinalListOption);
|
||||
}, [sortDir, email, phone, status]);
|
||||
}, [sortDir, email, phone, state]);
|
||||
|
||||
if (showLoading) return <FormLoading />;
|
||||
|
||||
@@ -171,7 +171,7 @@ export default function Page({ searchParams }: PageProps): React.JSX.Element {
|
||||
<UserMetasSelectionProvider userMetas={f}>
|
||||
<Card>
|
||||
<UserMetasFilters
|
||||
filters={{ email, phone, status }}
|
||||
filters={{ email, phone, state }}
|
||||
fullData={userMetaData}
|
||||
sortDir={sortDir}
|
||||
/>
|
||||
@@ -205,7 +205,7 @@ interface PageProps {
|
||||
email?: string;
|
||||
phone?: string;
|
||||
sortDir?: 'asc' | 'desc';
|
||||
status?: string;
|
||||
state?: string;
|
||||
//
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user