update page.tsx visual=true filter,
This commit is contained in:
@@ -23,7 +23,7 @@ import { paths } from '@/paths';
|
||||
import { FilterButton, FilterPopover, useFilterContext } from '@/components/core/filter-button';
|
||||
import { Option } from '@/components/core/option';
|
||||
|
||||
import { useLpCategoriesSelection } from './mf-categories-selection-context';
|
||||
import { useMfCategoriesSelection } from './mf-categories-selection-context';
|
||||
import { MfCategory } from './type';
|
||||
|
||||
export interface Filters {
|
||||
@@ -37,7 +37,7 @@ export interface Filters {
|
||||
|
||||
export type SortDir = 'asc' | 'desc';
|
||||
|
||||
export interface LpCategoriesFiltersProps {
|
||||
export interface MfCategoriesFiltersProps {
|
||||
filters?: Filters;
|
||||
sortDir?: SortDir;
|
||||
fullData: MfCategory[];
|
||||
@@ -47,7 +47,7 @@ export function MfCategoriesFilters({
|
||||
filters = {},
|
||||
sortDir = 'desc',
|
||||
fullData,
|
||||
}: LpCategoriesFiltersProps): React.JSX.Element {
|
||||
}: MfCategoriesFiltersProps): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const { email, phone, status, name, visible, type } = filters;
|
||||
|
||||
@@ -57,7 +57,7 @@ export function MfCategoriesFilters({
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const selection = useLpCategoriesSelection();
|
||||
const selection = useMfCategoriesSelection();
|
||||
|
||||
function getVisible(): number {
|
||||
return fullData.reduce((count, item: MfCategory) => {
|
||||
|
@@ -12,9 +12,9 @@ function noop(): void {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export interface LpCategoriesSelectionContextValue extends Selection {}
|
||||
export interface MfCategoriesSelectionContextValue extends Selection {}
|
||||
|
||||
export const LpCategoriesSelectionContext = React.createContext<LpCategoriesSelectionContextValue>({
|
||||
export const MfCategoriesSelectionContext = React.createContext<MfCategoriesSelectionContextValue>({
|
||||
deselectAll: noop,
|
||||
deselectOne: noop,
|
||||
selectAll: noop,
|
||||
@@ -24,7 +24,7 @@ export const LpCategoriesSelectionContext = React.createContext<LpCategoriesSele
|
||||
selectedAll: false,
|
||||
});
|
||||
|
||||
interface LpCategoriesSelectionProviderProps {
|
||||
interface MfCategoriesSelectionProviderProps {
|
||||
children: React.ReactNode;
|
||||
lessonCategories: MfCategory[];
|
||||
}
|
||||
@@ -32,15 +32,15 @@ interface LpCategoriesSelectionProviderProps {
|
||||
export function MfCategoriesSelectionProvider({
|
||||
children,
|
||||
lessonCategories = [],
|
||||
}: LpCategoriesSelectionProviderProps): React.JSX.Element {
|
||||
}: MfCategoriesSelectionProviderProps): React.JSX.Element {
|
||||
const customerIds = React.useMemo(() => lessonCategories.map((customer) => customer.id), [lessonCategories]);
|
||||
const selection = useSelection(customerIds);
|
||||
|
||||
return (
|
||||
<LpCategoriesSelectionContext.Provider value={{ ...selection }}>{children}</LpCategoriesSelectionContext.Provider>
|
||||
<MfCategoriesSelectionContext.Provider value={{ ...selection }}>{children}</MfCategoriesSelectionContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function useLpCategoriesSelection(): LpCategoriesSelectionContextValue {
|
||||
return React.useContext(LpCategoriesSelectionContext);
|
||||
export function useMfCategoriesSelection(): MfCategoriesSelectionContextValue {
|
||||
return React.useContext(MfCategoriesSelectionContext);
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ import { DataTable } from '@/components/core/data-table';
|
||||
import type { ColumnDef } from '@/components/core/data-table';
|
||||
|
||||
import ConfirmDeleteModal from './confirm-delete-modal';
|
||||
import { useLpCategoriesSelection } from './mf-categories-selection-context';
|
||||
import { useMfCategoriesSelection } from './mf-categories-selection-context';
|
||||
import type { MfCategory } from './type';
|
||||
|
||||
function columns(handleDeleteClick: (testId: string) => void): ColumnDef<MfCategory>[] {
|
||||
@@ -192,8 +192,8 @@ export interface LessonCategoriesTableProps {
|
||||
}
|
||||
|
||||
export function MfCategoriesTable({ rows, reloadRows }: LessonCategoriesTableProps): React.JSX.Element {
|
||||
const { t } = useTranslation(['lp_categories']);
|
||||
const { deselectAll, deselectOne, selectAll, selectOne, selected } = useLpCategoriesSelection();
|
||||
const { t } = useTranslation(['mf_categories']);
|
||||
const { deselectAll, deselectOne, selectAll, selectOne, selected } = useMfCategoriesSelection();
|
||||
|
||||
const [idToDelete, setIdToDelete] = React.useState('');
|
||||
const [open, setOpen] = React.useState(false);
|
||||
|
@@ -3,7 +3,7 @@
|
||||
import * as React from 'react';
|
||||
import RouterLink from 'next/link';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { COL_QUIZ_LP_CATEGORIES } from '@/constants';
|
||||
import { COL_QUIZ_MF_CATEGORIES } from '@/constants';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { LoadingButton } from '@mui/lab';
|
||||
import { Avatar, Divider, MenuItem, Select } from '@mui/material';
|
||||
@@ -68,7 +68,7 @@ export const defaultValues = {
|
||||
|
||||
export function MfCategoryCreateForm(): React.JSX.Element {
|
||||
const router = useRouter();
|
||||
const { t } = useTranslation(['lp_categories']);
|
||||
const { t } = useTranslation(['mf_categories']);
|
||||
|
||||
const [isCreating, setIsCreating] = React.useState<boolean>(false);
|
||||
|
||||
@@ -101,7 +101,7 @@ export function MfCategoryCreateForm(): React.JSX.Element {
|
||||
};
|
||||
|
||||
try {
|
||||
const result = await pb.collection(COL_QUIZ_LP_CATEGORIES).create(payload);
|
||||
const result = await pb.collection(COL_QUIZ_MF_CATEGORIES).create(payload);
|
||||
|
||||
logger.debug(result);
|
||||
toast.success(t('create.success'));
|
@@ -90,7 +90,7 @@ const defaultValues = {
|
||||
|
||||
export function MfCategoryEditForm(): React.JSX.Element {
|
||||
const router = useRouter();
|
||||
const { t } = useTranslation(['lp_categories']);
|
||||
const { t } = useTranslation(['mf_categories']);
|
||||
|
||||
const { cat_id: catId } = useParams<{ cat_id: string }>();
|
||||
//
|
||||
|
@@ -23,7 +23,7 @@ import { paths } from '@/paths';
|
||||
import { FilterButton, FilterPopover, useFilterContext } from '@/components/core/filter-button';
|
||||
import { Option } from '@/components/core/option';
|
||||
|
||||
import { useLpQuestionsSelection } from './mf-questions-selection-context';
|
||||
import { useMfQuestionsSelection } from './mf-questions-selection-context';
|
||||
import { MfQuestion } from './type';
|
||||
|
||||
export interface Filters {
|
||||
@@ -37,7 +37,7 @@ export interface Filters {
|
||||
|
||||
export type SortDir = 'asc' | 'desc';
|
||||
|
||||
export interface LpQuestionsFiltersProps {
|
||||
export interface MfQuestionsFiltersProps {
|
||||
filters?: Filters;
|
||||
sortDir?: SortDir;
|
||||
fullData: MfQuestion[];
|
||||
@@ -47,7 +47,7 @@ export function MfQuestionsFilters({
|
||||
filters = {},
|
||||
sortDir = 'desc',
|
||||
fullData,
|
||||
}: LpQuestionsFiltersProps): React.JSX.Element {
|
||||
}: MfQuestionsFiltersProps): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const { email, phone, status, name, visible, type } = filters;
|
||||
|
||||
@@ -57,7 +57,7 @@ export function MfQuestionsFilters({
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const selection = useLpQuestionsSelection();
|
||||
const selection = useMfQuestionsSelection();
|
||||
|
||||
function getVisible(): number {
|
||||
return fullData.reduce((count, item: MfQuestion) => {
|
||||
@@ -114,7 +114,7 @@ export function MfQuestionsFilters({
|
||||
}
|
||||
|
||||
// NOTE: modify according to COLLECTION
|
||||
router.push(`${paths.dashboard.lp_questions.list}?${searchParams.toString()}`);
|
||||
router.push(`${paths.dashboard.mf_questions.list}?${searchParams.toString()}`);
|
||||
},
|
||||
[router]
|
||||
);
|
||||
|
@@ -12,9 +12,9 @@ function noop(): void {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export interface LpQuestionsSelectionContextValue extends Selection {}
|
||||
export interface MfQuestionsSelectionContextValue extends Selection {}
|
||||
|
||||
export const LpQuestionsSelectionContext = React.createContext<LpQuestionsSelectionContextValue>({
|
||||
export const MfQuestionsSelectionContext = React.createContext<MfQuestionsSelectionContextValue>({
|
||||
deselectAll: noop,
|
||||
deselectOne: noop,
|
||||
selectAll: noop,
|
||||
@@ -24,7 +24,7 @@ export const LpQuestionsSelectionContext = React.createContext<LpQuestionsSelect
|
||||
selectedAll: false,
|
||||
});
|
||||
|
||||
interface LpQuestionsSelectionProviderProps {
|
||||
interface MfQuestionsSelectionProviderProps {
|
||||
children: React.ReactNode;
|
||||
lessonQuestions: MfQuestion[];
|
||||
}
|
||||
@@ -32,15 +32,15 @@ interface LpQuestionsSelectionProviderProps {
|
||||
export function MfQuestionsSelectionProvider({
|
||||
children,
|
||||
lessonQuestions = [],
|
||||
}: LpQuestionsSelectionProviderProps): React.JSX.Element {
|
||||
}: MfQuestionsSelectionProviderProps): React.JSX.Element {
|
||||
const customerIds = React.useMemo(() => lessonQuestions.map((customer) => customer.id), [lessonQuestions]);
|
||||
const selection = useSelection(customerIds);
|
||||
|
||||
return (
|
||||
<LpQuestionsSelectionContext.Provider value={{ ...selection }}>{children}</LpQuestionsSelectionContext.Provider>
|
||||
<MfQuestionsSelectionContext.Provider value={{ ...selection }}>{children}</MfQuestionsSelectionContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function useLpQuestionsSelection(): LpQuestionsSelectionContextValue {
|
||||
return React.useContext(LpQuestionsSelectionContext);
|
||||
export function useMfQuestionsSelection(): MfQuestionsSelectionContextValue {
|
||||
return React.useContext(MfQuestionsSelectionContext);
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ import { DataTable } from '@/components/core/data-table';
|
||||
import type { ColumnDef } from '@/components/core/data-table';
|
||||
|
||||
import ConfirmDeleteModal from './confirm-delete-modal';
|
||||
import { useLpQuestionsSelection } from './mf-questions-selection-context';
|
||||
import { useMfQuestionsSelection } from './mf-questions-selection-context';
|
||||
import type { MfQuestion } from './type';
|
||||
|
||||
function columns(handleDeleteClick: (testId: string) => void): ColumnDef<MfQuestion>[] {
|
||||
@@ -193,7 +193,7 @@ export interface LessonQuestionsTableProps {
|
||||
|
||||
export function MfQuestionsTable({ rows, reloadRows }: LessonQuestionsTableProps): React.JSX.Element {
|
||||
const { t } = useTranslation(['lp_categories']);
|
||||
const { deselectAll, deselectOne, selectAll, selectOne, selected } = useLpQuestionsSelection();
|
||||
const { deselectAll, deselectOne, selectAll, selectOne, selected } = useMfQuestionsSelection();
|
||||
|
||||
const [idToDelete, setIdToDelete] = React.useState('');
|
||||
const [open, setOpen] = React.useState(false);
|
||||
|
Reference in New Issue
Block a user