diff --git a/src/components/form/lexicon/CreateEditCategory.tsx b/src/components/form/lexicon/CreateEditCategory.tsx deleted file mode 100644 index 5659a92a..00000000 --- a/src/components/form/lexicon/CreateEditCategory.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import { Control, FieldErrors } from 'react-hook-form' -import Grid from '@mui/material/Grid2' -import { ControlledTextField, ControlledSelectField } from '@/components' - -/** - * CreateEditSample Component - * A reusable form component for creating and editing well information. - * - * @param control - The control object from useForm - * @param errors - The errors object from useForm - * @param mode - The mode of the component ('standalone' or 'step') - * @param fieldPrefix - The prefix for the field names - */ - -interface CreateEditCategoryProps { - control: Control - errors?: FieldErrors - mode?: 'standalone' | 'step' - fieldPrefix?: string -} - -export const CreateEditCategory: React.FC = ({ - control, - errors, - mode = 'standalone', - fieldPrefix = '', -}) => { - const getFieldName = (fieldName: string) => { - return mode === 'step' ? `${fieldPrefix}${fieldName}` : fieldName - } - - return ( - - - - - - - - - ) -} diff --git a/src/components/form/lexicon/CreateEditTerm.tsx b/src/components/form/lexicon/CreateEditTerm.tsx deleted file mode 100644 index 45f10a10..00000000 --- a/src/components/form/lexicon/CreateEditTerm.tsx +++ /dev/null @@ -1,80 +0,0 @@ -import { Control, FieldErrors } from 'react-hook-form' -import Grid from '@mui/material/Grid2' -import { ControlledTextField, ControlledSelectField } from '@/components' -import { useList } from '@refinedev/core' - -/** - * CreateEditSample Component - * A reusable form component for creating and editing well information. - * - * @param control - The control object from useForm - * @param errors - The errors object from useForm - * @param mode - The mode of the component ('standalone' or 'step') - * @param fieldPrefix - The prefix for the field names - */ - -interface CreateEditTermProps { - control: Control - errors?: FieldErrors - mode?: 'standalone' | 'step' - fieldPrefix?: string -} - -export const CreateEditTerm: React.FC = ({ - control, - errors, - mode = 'standalone', - fieldPrefix = '', -}) => { - const getFieldName = (fieldName: string) => { - return mode === 'step' ? `${fieldPrefix}${fieldName}` : fieldName - } - - const { data: categories, isLoading: categoriesLoading } = useList({ - resource: 'lexicon/category', - pagination: { - pageSize: 10000, - }, - }) - - console.log('categories', categories) - - return ( - - - - - - - - - - ({ - label: category.name, - value: category.id, - })) || [] - } - required - /> - - - ) -} diff --git a/src/pages/ocotillo/lexicon/create.tsx b/src/pages/ocotillo/lexicon/create.tsx index 792cd48d..7a047e77 100644 --- a/src/pages/ocotillo/lexicon/create.tsx +++ b/src/pages/ocotillo/lexicon/create.tsx @@ -1,45 +1,30 @@ -import type { HttpError } from '@refinedev/core' -import { Create, DateField } from '@refinedev/mui' -import Box from '@mui/material/Box' -import TextField from '@mui/material/TextField' -import { useForm } from '@refinedev/react-hook-form' -import { Nullable } from '../../../interfaces' -import { ICategory, ITerm } from '@/interfaces/ocotillo/ILexicon' -import { DatePicker } from '@mui/x-date-pickers' -import { Controller } from 'react-hook-form' -import { SelectThingComponent } from '@/components/form/thing/SelectThingComponent' -import { ControlledSelectField } from '@/components' -import { CreateEditCategory } from '@/components/form/lexicon/CreateEditCategory' -import { CreateEditTerm } from '@/components/form/lexicon/CreateEditTerm' -// import { CreateEditTerm } from '@/components/form/thing/CreateEditTerm' +import { Create } from '@refinedev/mui' +import { Typography } from '@mui/material' export const CategoryCreate: React.FC = () => { - const { - saveButtonProps, - register, - control, - watch, - formState: { errors }, - } = useForm>() - return ( - - + + + Lexicon Category are readonly + ) } export const TermCreate: React.FC = () => { - const { - saveButtonProps, - register, - control, - watch, - formState: { errors }, - } = useForm>() - return ( - - + + + Lexicon Terms are readonly + ) } diff --git a/src/pages/ocotillo/lexicon/edit.tsx b/src/pages/ocotillo/lexicon/edit.tsx index 9cc9e9fc..8807d6c3 100644 --- a/src/pages/ocotillo/lexicon/edit.tsx +++ b/src/pages/ocotillo/lexicon/edit.tsx @@ -1,46 +1,30 @@ -import type { HttpError } from '@refinedev/core' import { Edit } from '@refinedev/mui' -import Box from '@mui/material/Box' -import TextField from '@mui/material/TextField' -import { useForm } from '@refinedev/react-hook-form' - -import type { Nullable } from '@/interfaces' -import { ITerm, ICategory } from '@/interfaces/ocotillo/ILexicon' -import { DatePicker } from '@mui/x-date-pickers' -import { Controller } from 'react-hook-form' -import dayjs from 'dayjs' -import { CreateEditTerm } from '@/components/form/lexicon/CreateEditTerm' -import { CreateEditCategory } from '@/components/form/lexicon/CreateEditCategory' +import { Typography } from '@mui/material' export const CategoryEdit: React.FC = () => { - const { - saveButtonProps, - refineCore: { query: queryResult }, - register, - watch, - control, - formState: { errors }, - } = useForm>() - return ( - - + + + Lexicon Category are readonly + ) } -export const TermEdit: React.FC = () => { - const { - saveButtonProps, - refineCore: { query: queryResult }, - register, - watch, - control, - formState: { errors }, - } = useForm>() +export const TermEdit: React.FC = () => { return ( - - + + + Lexicon Terms are readonly + ) } diff --git a/src/pages/ocotillo/lexicon/list.tsx b/src/pages/ocotillo/lexicon/list.tsx index 62139c62..a5bcf234 100644 --- a/src/pages/ocotillo/lexicon/list.tsx +++ b/src/pages/ocotillo/lexicon/list.tsx @@ -1,13 +1,13 @@ import { DataGrid } from '@mui/x-data-grid' import { settings } from '@/settings' -import { CreateButton, ExportButton, List, useDataGrid } from '@refinedev/mui' +import { ExportButton, List, useDataGrid } from '@refinedev/mui' import React from 'react' -import { Card, Typography } from '@mui/material' +import { Card, CardContent, CardHeader, Typography } from '@mui/material' +import Grid from '@mui/material/Grid2' import { useExport } from '@refinedev/core' -import { actionColumnDef } from '@/components/CommonColumnDefs' export const LexiconList: React.FC = () => { - const headerButtons = ({ defaultButtons }) => { + const headerButtons = () => { const { triggerExport: triggerTermExport, isLoading: exportTermIsLoading } = useExport({ pageSize: 1000, @@ -25,20 +25,15 @@ export const LexiconList: React.FC = () => { return ( <> - Term - - Category - - Export Terms @@ -70,13 +65,12 @@ export const LexiconList: React.FC = () => { field: 'categories', headerName: 'Category', width: 150, - valueGetter: (params) => { - return params.map((c) => c.name).join(', ') + valueGetter: (params: any) => { + return params.map((c: { name: string }) => c.name).join(', ') }, sortable: false, filterable: false, }, - actionColumnDef(), ] const { dataGridProps: categoryDataGridProps } = useDataGrid({ resource: 'lexicon/category', @@ -89,54 +83,68 @@ export const LexiconList: React.FC = () => { const categoryColumns = [ { field: 'name', headerName: 'Name', width: 200 }, { field: 'description', headerName: 'Description', width: 300 }, - actionColumnDef({ resource: 'ocotillo.lexicon/category' }), ] return ( - <> - - - - {'The Lexicon (aka Glossary) stores all the terms and definitions used in' + - ' the data sytem'} - - - - Categories - setSelectedCategory(params.row)} - getRowClassName={(params) => - params.id === selectedCategory?.id ? 'selected-row' : '' - } + + + + theme.palette.secondary.light, - }, + marginTop: 1, + marginBottom: 1, + padding: 1, }} - /> - - - Terms - - - - + > + + The Lexicon (aka Glossary) stores all the terms and definitions + used in the data sytem + + + + + + + + setSelectedCategory(params.row)} + getRowClassName={(params) => + params.id === selectedCategory?.id ? 'selected-row' : '' + } + sx={{ + '& .selected-row': { + backgroundColor: (theme) => theme.palette.secondary.light, + }, + }} + /> + + + + + + + + + + + + + ) }