Ts changes weren't staged, it compiles still doesnt build building

This commit is contained in:
Carlos-Mesquita
2024-11-06 19:49:02 +00:00
parent a371b171bb
commit 7045b4e3c7
13 changed files with 45 additions and 29 deletions

View File

@@ -1,19 +0,0 @@
import { Type as UserType} from "@/interfaces/user";
export type Type = Exclude<UserType, "admin" | "developer" | "agent" | "mastercorporate">;
export interface UserImport {
id: string;
email: string;
name: string;
passport_id: string;
type: Type;
groupName: string;
entity: string;
studentID: string;
demographicInformation: {
country: string;
passport_id: string;
phone: string;
};
}

View File

@@ -1,196 +0,0 @@
import React, { useState } from 'react';
import {
createColumnHelper,
flexRender,
getCoreRowModel,
useReactTable,
getPaginationRowModel,
getSortedRowModel,
getFilteredRowModel,
FilterFn,
} from '@tanstack/react-table';
import { UserImport } from "./IUserImport";
const globalFilterFn: FilterFn<any> = (row, columnId, filterValue: string) => {
const value = row.getValue(columnId);
return String(value).toLowerCase().includes(filterValue.toLowerCase());
};
const columnHelper = createColumnHelper<UserImport>();
const columns = [
columnHelper.accessor('name', {
cell: info => info.getValue(),
header: () => 'Name',
}),
columnHelper.accessor('studentID', {
cell: info => info.getValue(),
header: () => 'Student ID',
}),
columnHelper.accessor('demographicInformation.passport_id', {
cell: info => info.getValue(),
header: () => 'Passport/National ID',
}),
columnHelper.accessor('email', {
cell: info => info.getValue(),
header: () => 'Email',
}),
columnHelper.accessor('demographicInformation.phone', {
cell: info => info.getValue(),
header: () => 'Phone Number',
}),
columnHelper.accessor('groupName', {
cell: info => info.getValue(),
header: () => 'Classroom Name',
}),
columnHelper.accessor('demographicInformation.country', {
cell: info => info.getValue(),
header: () => 'Country',
}),
];
const UserTable: React.FC<{ users: UserImport[] }> = ({ users }) => {
const [globalFilter, setGlobalFilter] = useState('');
const table = useReactTable({
data: users,
columns,
getCoreRowModel: getCoreRowModel(),
getPaginationRowModel: getPaginationRowModel(),
getSortedRowModel: getSortedRowModel(),
getFilteredRowModel: getFilteredRowModel(),
globalFilterFn: globalFilterFn,
state: {
globalFilter,
},
onGlobalFilterChange: setGlobalFilter,
initialState: {
pagination: {
pageSize: 5,
},
}
});
return (
<div className='flex flex-col'>
<div className="flex flew-row w-full mb-4 justify-between gap-4">
<input
type="text"
value={globalFilter ?? ''}
onChange={e => setGlobalFilter(e.target.value)}
placeholder="Search ..."
className="p-2 border rounded flex-grow"
/>
<select
value={table.getState().pagination.pageSize}
onChange={e => {
table.setPageSize(Number(e.target.value));
}}
className="p-2 border rounded"
>
{[5, 10, 15, 20].map(pageSize => (
<option key={pageSize} value={pageSize}>
Show {pageSize}
</option>
))}
</select>
</div>
<table className="w-full">
<thead>
{table.getHeaderGroups().map(headerGroup => (
<tr key={headerGroup.id}>
{headerGroup.headers.map(header => (
<th
key={header.id}
className='bg-mti-purple-ultralight/80 first:rounded-tl-3xl last:rounded-tr-3xl py-4 first:pl-6 text-mti-purple-light cursor-pointer'
onClick={header.column.getToggleSortingHandler()}
>
{header.isPlaceholder ? null : (
<div className='flex flex-row justify-between'>
<span>
{flexRender(
header.column.columnDef.header,
header.getContext()
)}
</span>
<span className='pr-6'>
{{
asc: ' 🔼',
desc: ' 🔽',
}[header.column.getIsSorted() as string] ?? null}
</span>
</div>
)}
</th>
))}
</tr>
))}
</thead>
<tbody>
{table.getRowModel().rows.map((row, index, array) => {
const isLastRow = index === array.length - 1;
return (
<tr key={row.id}>
{row.getVisibleCells().map((cell) => {
return (
<td
key={cell.id}
className={
isLastRow
? `first:rounded-bl-3xl last:rounded-br-3xl py-4 first:pl-6 bg-mti-purple-ultralight/40`
: `first:pl-6 py-4 border-b bg-mti-purple-ultralight/40`
}
>
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</td>
);
})}
</tr>
);
})}
</tbody>
</table>
<div className="mt-4 flex items-center gap-4 mx-auto">
<button
onClick={() => table.setPageIndex(0)}
disabled={!table.getCanPreviousPage()}
className="px-4 py-2 bg-mti-purple-light text-white rounded disabled:opacity-50"
>
{'<<'}
</button>
<button
onClick={() => table.previousPage()}
disabled={!table.getCanPreviousPage()}
className="px-4 py-2 bg-mti-purple-light text-white rounded disabled:opacity-50"
>
{'<'}
</button>
<span>
Page{' '}
<strong>
{table.getState().pagination.pageIndex + 1} of{' '}
{table.getPageCount()}
</strong>
</span>
<button
onClick={() => table.nextPage()}
disabled={!table.getCanNextPage()}
className="px-4 py-2 bg-mti-purple-light text-white rounded disabled:opacity-50"
>
{'>'}
</button>
<button
onClick={() => table.setPageIndex(table.getPageCount() - 1)}
disabled={!table.getCanNextPage()}
className="px-4 py-2 bg-mti-purple-light text-white rounded disabled:opacity-50"
>
{'>>'}
</button>
</div>
</div>
);
};
export default UserTable;

View File

@@ -15,8 +15,8 @@ import ReactDatePicker from "react-datepicker";
import clsx from "clsx";
import countryCodes from "country-codes-list";
import { User, Type as UserType } from "@/interfaces/user";
import { Type, UserImport } from "./IUserImport";
import UserTable from "./UserTable";
import { Type, UserImport } from "../../../interfaces/IUserImport";
import UserTable from "../../../components/UserTable";
import { EntityWithRoles } from "@/interfaces/entity";
import Select from "@/components/Low/Select";

View File

@@ -20,6 +20,7 @@ import Modal from "@/components/Modal";
import {checkAccess} from "@/utils/permissions";
import useGroups from "@/hooks/useGroups";
import Button from "@/components/Low/Button";
import { EntityWithRoles } from "@/interfaces/entity";
const searchFields = [["module"], ["id"], ["createdBy"]];
@@ -56,7 +57,7 @@ const ExamOwnerSelector = ({options, exam, onSave}: {options: User[]; exam: Exam
);
};
export default function ExamList({user}: {user: User}) {
export default function ExamList({user, entities}: {user: User; entities: EntityWithRoles[];}) {
const [selectedExam, setSelectedExam] = useState<Exam>();
const {exams, reload} = useExams();

View File

@@ -21,7 +21,7 @@ async function get(req: NextApiRequest, res: NextApiResponse) {
queryParams.delete('module');
const result = await axios.get(`${process.env.BACKEND_URL}/${endpoint}${queryParams.size > 0 ? `?${queryParams.toString()}` : ""}`, {
const result = await axios.get(`${process.env.BACKEND_URL}/${endpoint}${Array.from(queryParams.entries()).length > 0 ? `?${queryParams.toString()}` : ""}`, {
headers: { Authorization: `Bearer ${process.env.BACKEND_JWT}` },
});
res.status(200).json(result.data);