update build ok,
This commit is contained in:
@@ -5,10 +5,9 @@ import { useRouter } from 'next/navigation';
|
||||
// import { COL_LESSON_CATEGORIES } from '@/constants';
|
||||
|
||||
// RULES: Quiz
|
||||
import GetAllCount from '@/db/QuizListenings/GetAllCount';
|
||||
import GetHiddenCount from '@/db/QuizListenings/GetHiddenCount';
|
||||
// import GetVisibleCount from '@/db/QuizListenings/GetVisibleCount';
|
||||
// import GetVisibleCount from '@/db/Q';
|
||||
import GetAllCount from '@/db/QuizMFCategories/GetAllCount';
|
||||
import GetHiddenCount from '@/db/QuizMFCategories/GetHiddenCount';
|
||||
import GetVisibleCount from '@/db/QuizMFCategories/GetVisibleCount';
|
||||
//
|
||||
import Button from '@mui/material/Button';
|
||||
import Chip from '@mui/material/Chip';
|
||||
@@ -28,7 +27,7 @@ import { FilterButton, FilterPopover, useFilterContext } from '@/components/core
|
||||
import { Option } from '@/components/core/option';
|
||||
|
||||
import { useCrCategoriesSelection } from './cr-categories-selection-context';
|
||||
import { CrCategory } from './type';
|
||||
import type { CrCategory } from './type';
|
||||
|
||||
export interface Filters {
|
||||
email?: 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 './cr-questions-selection-context';
|
||||
import { useCrQuestionsSelection } from './cr-questions-selection-context';
|
||||
import { CrQuestion } from './type';
|
||||
|
||||
export interface Filters {
|
||||
@@ -57,7 +57,7 @@ export function CrQuestionsFilters({
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const selection = useLpQuestionsSelection();
|
||||
const selection = useCrQuestionsSelection();
|
||||
|
||||
function getVisible(): number {
|
||||
return fullData.reduce((count, item: CrQuestion) => {
|
||||
|
@@ -12,9 +12,9 @@ function noop(): void {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export interface LpQuestionsSelectionContextValue extends Selection {}
|
||||
export interface CrQuestionsSelectionContextValue extends Selection {}
|
||||
|
||||
export const LpQuestionsSelectionContext = React.createContext<LpQuestionsSelectionContextValue>({
|
||||
export const CrQuestionsSelectionContext = React.createContext<CrQuestionsSelectionContextValue>({
|
||||
deselectAll: noop,
|
||||
deselectOne: noop,
|
||||
selectAll: noop,
|
||||
@@ -24,7 +24,7 @@ export const LpQuestionsSelectionContext = React.createContext<LpQuestionsSelect
|
||||
selectedAll: false,
|
||||
});
|
||||
|
||||
interface LpQuestionsSelectionProviderProps {
|
||||
interface CrQuestionsSelectionProviderProps {
|
||||
children: React.ReactNode;
|
||||
lessonQuestions: CrQuestion[];
|
||||
}
|
||||
@@ -32,15 +32,15 @@ interface LpQuestionsSelectionProviderProps {
|
||||
export function CrQuestionsSelectionProvider({
|
||||
children,
|
||||
lessonQuestions = [],
|
||||
}: LpQuestionsSelectionProviderProps): React.JSX.Element {
|
||||
}: CrQuestionsSelectionProviderProps): 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>
|
||||
<CrQuestionsSelectionContext.Provider value={{ ...selection }}>{children}</CrQuestionsSelectionContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function useLpQuestionsSelection(): LpQuestionsSelectionContextValue {
|
||||
return React.useContext(LpQuestionsSelectionContext);
|
||||
export function useCrQuestionsSelection(): CrQuestionsSelectionContextValue {
|
||||
return React.useContext(CrQuestionsSelectionContext);
|
||||
}
|
||||
|
@@ -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 './cr-questions-selection-context';
|
||||
import { useCrQuestionsSelection } from './cr-questions-selection-context';
|
||||
import type { CrQuestion } from './type';
|
||||
|
||||
function columns(handleDeleteClick: (testId: string) => void): ColumnDef<CrQuestion>[] {
|
||||
@@ -40,7 +40,7 @@ function columns(handleDeleteClick: (testId: string) => void): ColumnDef<CrQuest
|
||||
<Link
|
||||
color="inherit"
|
||||
component={RouterLink}
|
||||
href={paths.dashboard.lp_categories.details(row.id)}
|
||||
href={paths.dashboard.cr_questions.details(row.id)}
|
||||
sx={{ whiteSpace: 'nowrap' }}
|
||||
variant="subtitle2"
|
||||
>
|
||||
@@ -163,7 +163,7 @@ function columns(handleDeleteClick: (testId: string) => void): ColumnDef<CrQuest
|
||||
//
|
||||
color="secondary"
|
||||
component={RouterLink}
|
||||
href={paths.dashboard.lp_categories.details(row.id)}
|
||||
href={paths.dashboard.cr_questions.details(row.id)}
|
||||
>
|
||||
<PencilSimpleIcon size={24} />
|
||||
</LoadingButton>
|
||||
@@ -193,7 +193,7 @@ export interface LessonQuestionsTableProps {
|
||||
|
||||
export function CrQuestionsTable({ rows, reloadRows }: LessonQuestionsTableProps): React.JSX.Element {
|
||||
const { t } = useTranslation(['lp_categories']);
|
||||
const { deselectAll, deselectOne, selectAll, selectOne, selected } = useLpQuestionsSelection();
|
||||
const { deselectAll, deselectOne, selectAll, selectOne, selected } = useCrQuestionsSelection();
|
||||
|
||||
const [idToDelete, setIdToDelete] = React.useState('');
|
||||
const [open, setOpen] = React.useState(false);
|
||||
|
@@ -17,6 +17,10 @@ const COL_QUIZ_LP_QUESTIONS = 'QuizLPQuestions';
|
||||
const COL_QUIZ_MF_CATEGORIES = 'QuizMFCategories';
|
||||
const COL_QUIZ_MF_QUESTIONS = 'QuizMFQuestions';
|
||||
|
||||
// New CR versions
|
||||
const COL_QUIZ_CR_CATEGORIES = 'QuizCRCategories';
|
||||
const COL_QUIZ_CR_QUESTIONS = 'QuizCRQuestions';
|
||||
|
||||
export {
|
||||
COL_LESSON_TYPES,
|
||||
NO_VALUE,
|
||||
@@ -32,4 +36,7 @@ export {
|
||||
COL_QUIZ_MF_CATEGORIES,
|
||||
COL_QUIZ_MF_QUESTIONS,
|
||||
//
|
||||
COL_QUIZ_CR_CATEGORIES,
|
||||
COL_QUIZ_CR_QUESTIONS,
|
||||
//
|
||||
};
|
||||
|
@@ -2,7 +2,7 @@ import { COL_LESSON_CATEGORIES } from '@/constants';
|
||||
import type { RecordModel } from 'pocketbase';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
import type { CreateFormProps } from '@/components/dashboard/lp_categories/type';
|
||||
import type { CreateFormProps } from '@/components/dashboard/lp/categories/type';
|
||||
|
||||
export default function createLessonCategory(data: CreateFormProps): Promise<RecordModel> {
|
||||
return pb.collection(COL_LESSON_CATEGORIES).create(data);
|
||||
|
@@ -2,7 +2,7 @@ import { COL_LESSON_CATEGORIES } from '@/constants';
|
||||
import type { RecordModel } from 'pocketbase';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
import type { CreateFormProps } from '@/components/dashboard/lp_categories/type';
|
||||
import type { CreateFormProps } from '@/components/dashboard/lp/categories/type';
|
||||
|
||||
export default function updateLessonCategory(id: string, data: CreateFormProps): Promise<RecordModel> {
|
||||
return pb.collection(COL_LESSON_CATEGORIES).update(id, data);
|
||||
|
9
002_source/cms/src/db/QuizCRCategories/Create.tsx
Normal file
9
002_source/cms/src/db/QuizCRCategories/Create.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import { COL_QUIZ_CR_CATEGORIES } from '@/constants';
|
||||
import type { RecordModel } from 'pocketbase';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
import { CreateFormProps } from '@/components/dashboard/cr/categories/type';
|
||||
|
||||
export default function createQuizCRCategory(data: CreateFormProps): Promise<RecordModel> {
|
||||
return pb.collection(COL_QUIZ_CR_CATEGORIES).create(data);
|
||||
}
|
7
002_source/cms/src/db/QuizCRCategories/Delete.tsx
Normal file
7
002_source/cms/src/db/QuizCRCategories/Delete.tsx
Normal file
@@ -0,0 +1,7 @@
|
||||
import { COL_QUIZ_CR_CATEGORIES } from '@/constants';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
|
||||
export default function deleteQuizCRCategories(id: string): Promise<boolean> {
|
||||
return pb.collection(COL_QUIZ_CR_CATEGORIES).delete(id);
|
||||
}
|
7
002_source/cms/src/db/QuizCRCategories/GetAll.tsx
Normal file
7
002_source/cms/src/db/QuizCRCategories/GetAll.tsx
Normal file
@@ -0,0 +1,7 @@
|
||||
import { COL_QUIZ_CR_CATEGORIES } from '@/constants';
|
||||
import type { RecordModel } from 'pocketbase';
|
||||
import { pb } from '@/lib/pb';
|
||||
|
||||
export default function getAllQuizCRCategories(): Promise<RecordModel[]> {
|
||||
return pb.collection(COL_QUIZ_CR_CATEGORIES).getFullList();
|
||||
}
|
9
002_source/cms/src/db/QuizCRCategories/GetAllCount.tsx
Normal file
9
002_source/cms/src/db/QuizCRCategories/GetAllCount.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
// REQ0006
|
||||
import { COL_QUIZ_CR_CATEGORIES } from '@/constants';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
|
||||
export default async function GetAllCount(): Promise<number> {
|
||||
const { totalItems: count } = await pb.collection(COL_QUIZ_CR_CATEGORIES).getList(1, 9999, {});
|
||||
return count;
|
||||
}
|
8
002_source/cms/src/db/QuizCRCategories/GetById.tsx
Normal file
8
002_source/cms/src/db/QuizCRCategories/GetById.tsx
Normal file
@@ -0,0 +1,8 @@
|
||||
import { COL_QUIZ_CR_CATEGORIES } from '@/constants';
|
||||
import type { RecordModel } from 'pocketbase';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
|
||||
export default function getQuizCRCategoryById(id: string): Promise<RecordModel> {
|
||||
return pb.collection(COL_QUIZ_CR_CATEGORIES).getOne(id);
|
||||
}
|
13
002_source/cms/src/db/QuizCRCategories/GetHiddenCount.tsx
Normal file
13
002_source/cms/src/db/QuizCRCategories/GetHiddenCount.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
// REQ0006
|
||||
import { COL_QUIZ_CR_CATEGORIES } from '@/constants';
|
||||
import { pb } from '@/lib/pb';
|
||||
|
||||
export default async function getHiddenQuizCRCategoriesCount(): Promise<number> {
|
||||
try {
|
||||
const result = await pb.collection(COL_QUIZ_CR_CATEGORIES).getList(1, 9999, { filter: 'visible = "hidden"' });
|
||||
const { totalItems: count } = result;
|
||||
return count;
|
||||
} catch (error) {
|
||||
return 0;
|
||||
}
|
||||
}
|
14
002_source/cms/src/db/QuizCRCategories/GetVisibleCount.tsx
Normal file
14
002_source/cms/src/db/QuizCRCategories/GetVisibleCount.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
// REQ0006
|
||||
import { COL_QUIZ_CR_CATEGORIES } from '@/constants';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
|
||||
export default async function getVisibleQuizCRCategoriesCount(): Promise<number> {
|
||||
try {
|
||||
const result = await pb.collection(COL_QUIZ_CR_CATEGORIES).getList(1, 9999, { filter: 'visible = "visible"' });
|
||||
const { totalItems: count } = result;
|
||||
return count;
|
||||
} catch (error) {
|
||||
return 0;
|
||||
}
|
||||
}
|
9
002_source/cms/src/db/QuizCRCategories/Update.tsx
Normal file
9
002_source/cms/src/db/QuizCRCategories/Update.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import { COL_QUIZ_CR_CATEGORIES } from '@/constants';
|
||||
import type { RecordModel } from 'pocketbase';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
import type { CreateFormProps } from '@/components/dashboard/cr/categories/type';
|
||||
|
||||
export default function updateQuizCRCategory(id: string, data: CreateFormProps): Promise<RecordModel> {
|
||||
return pb.collection(COL_QUIZ_CR_CATEGORIES).update(id, data);
|
||||
}
|
13
002_source/cms/src/db/QuizCRQuestions/Create.tsx
Normal file
13
002_source/cms/src/db/QuizCRQuestions/Create.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import { COL_QUIZ_CR_QUESTIONS } from '@/constants';
|
||||
import type { RecordModel } from 'pocketbase';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
import type { CreateFormProps } from '@/components/dashboard/cr/questions/type';
|
||||
|
||||
// interface CreateForm {
|
||||
// // TODO: Add QuizCRQuestions fields
|
||||
// }
|
||||
|
||||
export default function createQuizCRQuestion(data: CreateFormProps): Promise<RecordModel> {
|
||||
return pb.collection(COL_QUIZ_CR_QUESTIONS).create(data);
|
||||
}
|
7
002_source/cms/src/db/QuizCRQuestions/Delete.tsx
Normal file
7
002_source/cms/src/db/QuizCRQuestions/Delete.tsx
Normal file
@@ -0,0 +1,7 @@
|
||||
import { COL_QUIZ_CR_QUESTIONS } from '@/constants';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
|
||||
export default function deleteQuizCRQuestions(id: string): Promise<boolean> {
|
||||
return pb.collection(COL_QUIZ_CR_QUESTIONS).delete(id);
|
||||
}
|
8
002_source/cms/src/db/QuizCRQuestions/GetAll.tsx
Normal file
8
002_source/cms/src/db/QuizCRQuestions/GetAll.tsx
Normal file
@@ -0,0 +1,8 @@
|
||||
import { COL_QUIZ_CR_QUESTIONS } from '@/constants';
|
||||
import type { RecordModel } from 'pocketbase';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
|
||||
export default function getAllQuizCRQuestions(): Promise<RecordModel[]> {
|
||||
return pb.collection(COL_QUIZ_CR_QUESTIONS).getFullList();
|
||||
}
|
9
002_source/cms/src/db/QuizCRQuestions/GetAllCount.tsx
Normal file
9
002_source/cms/src/db/QuizCRQuestions/GetAllCount.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
// REQ0006
|
||||
import { COL_QUIZ_CR_QUESTIONS } from '@/constants';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
|
||||
export default async function GetAllCount(): Promise<number> {
|
||||
const { totalItems: count } = await pb.collection(COL_QUIZ_CR_QUESTIONS).getList(1, 9999, {});
|
||||
return count;
|
||||
}
|
14
002_source/cms/src/db/QuizCRQuestions/GetHiddenCount.tsx
Normal file
14
002_source/cms/src/db/QuizCRQuestions/GetHiddenCount.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
// REQ0006
|
||||
import { COL_QUIZ_CR_QUESTIONS } from '@/constants';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
|
||||
export default async function getHiddenQuizCRQuestionsCount(): Promise<number> {
|
||||
try {
|
||||
const result = await pb.collection(COL_QUIZ_CR_QUESTIONS).getList(1, 9999, { filter: 'visible = "hidden"' });
|
||||
const { totalItems: count } = result;
|
||||
return count;
|
||||
} catch (error) {
|
||||
return 0;
|
||||
}
|
||||
}
|
14
002_source/cms/src/db/QuizCRQuestions/GetVisibleCount.tsx
Normal file
14
002_source/cms/src/db/QuizCRQuestions/GetVisibleCount.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
// REQ0006
|
||||
import { COL_QUIZ_CR_QUESTIONS } from '@/constants';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
|
||||
export default async function getVisibleQuizCRQuestionsCount(): Promise<number> {
|
||||
try {
|
||||
const result = await pb.collection(COL_QUIZ_CR_QUESTIONS).getList(1, 9999, { filter: 'visible = "visible"' });
|
||||
const { totalItems: count } = result;
|
||||
return count;
|
||||
} catch (error) {
|
||||
return 0;
|
||||
}
|
||||
}
|
@@ -2,7 +2,7 @@ import { COL_QUIZ_LP_CATEGORIES } from '@/constants';
|
||||
import type { RecordModel } from 'pocketbase';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
import type { CreateFormProps } from '@/components/dashboard/lp_categories/type';
|
||||
import type { CreateFormProps } from '@/components/dashboard/lp/categories/type';
|
||||
|
||||
export default function updateQuizLPCategory(id: string, data: CreateFormProps): Promise<RecordModel> {
|
||||
return pb.collection(COL_QUIZ_LP_CATEGORIES).update(id, data);
|
||||
|
@@ -2,7 +2,7 @@ import { COL_QUIZ_LP_CATEGORIES } from '@/constants';
|
||||
import type { RecordModel } from 'pocketbase';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
import type { CreateFormProps } from '@/components/dashboard/lp_categories/type';
|
||||
import type { CreateFormProps } from '@/components/dashboard/lp/categories/type';
|
||||
|
||||
export default function updateQuizLPCategory(id: string, data: CreateFormProps): Promise<RecordModel> {
|
||||
return pb.collection(COL_QUIZ_LP_CATEGORIES).update(id, data);
|
||||
|
@@ -2,7 +2,7 @@ import { COL_QUIZ_MF_CATEGORIES } from '@/constants';
|
||||
import type { RecordModel } from 'pocketbase';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
import type { CreateFormProps } from '@/components/dashboard/mf_categories/type';
|
||||
import type { CreateFormProps } from '@/components/dashboard/mf/categories/type';
|
||||
|
||||
export default function createQuizMFCategory(data: CreateFormProps): Promise<RecordModel> {
|
||||
return pb.collection(COL_QUIZ_MF_CATEGORIES).create(data);
|
||||
|
@@ -2,7 +2,7 @@ import { COL_QUIZ_MF_CATEGORIES } from '@/constants';
|
||||
import type { RecordModel } from 'pocketbase';
|
||||
|
||||
import { pb } from '@/lib/pb';
|
||||
import type { CreateFormProps } from '@/components/dashboard/mf_categories/type';
|
||||
import type { CreateFormProps } from '@/components/dashboard/mf/categories/type';
|
||||
|
||||
export default function updateQuizMFCategory(id: string, data: CreateFormProps): Promise<RecordModel> {
|
||||
return pb.collection(COL_QUIZ_MF_CATEGORIES).update(id, data);
|
||||
|
Reference in New Issue
Block a user