Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

💂‍♀️upgrade to react-table v8, log supabase error messages, and better modules folder struture (#2)

Brad Barbin7a6736f34074
diff --git a/README.md b/README.md
index 1171ab67fa..f720f300d8 100644
--- a/README.md
+++ b/README.md
@@ -86,7 +86,7 @@ Finally, start the apps and packages:
yarn dev # yarn dev in all apps & packages
```
-To kill the database containers, you can run, but fair warning that this will delete the database:
+To kill the database containers in a non-recoverable way, you can run:
```bash
$ yarn db:kill # stop and delete all database containers
diff --git a/apps/carbon/app/components/Data/Table/Table.tsx b/apps/carbon/app/components/Data/Table/Table.tsx
index 97275706e5..61e71b00ab 100644
--- a/apps/carbon/app/components/Data/Table/Table.tsx
+++ b/apps/carbon/app/components/Data/Table/Table.tsx
@@ -1,34 +1,36 @@
-import { forwardRef, Fragment, useEffect } from "react";
+import { useEffect, useState } from "react";
+import { forwardRef } from "react";
import { useColor } from "@carbon/react";
import type { ThemeTypings } from "@chakra-ui/react";
import { Checkbox } from "@chakra-ui/react";
import {
Box,
- Flex,
Table as ChakraTable,
Thead,
Tbody,
Tr,
Th,
Td,
- chakra,
} from "@chakra-ui/react";
-import type { Column } from "react-table";
-import { useTable, useSortBy, useRowSelect } from "react-table";
+import type { ColumnDef, RowSelectionState } from "@tanstack/react-table";
+import {
+ flexRender,
+ getCoreRowModel,
+ useReactTable,
+} from "@tanstack/react-table";
import { AiFillCaretUp, AiFillCaretDown } from "react-icons/ai";
-import { Pagination } from "./components/Pagination";
-import { useUrlParams } from "~/hooks";
-import { parseNumberFromUrlParam } from "~/utils/http";
+import { Pagination, usePagination } from "./components";
interface TableProps<T extends object> {
- columns: Column<T>[];
+ columns: ColumnDef<T>[];
data: T[];
count: number;
colorScheme?: ThemeTypings["colorSchemes"];
selectableRows?: boolean;
+ shouldPaginate?: boolean;
onRowClick?: (row: T) => void;
- onSelectedRowsChange?: (rows: T[]) => void;
+ onSelectedRowsChange?: (selectedRows: T[]) => void;
}
const Table = <T extends object>({
@@ -36,120 +38,52 @@ const Table = <T extends object>({
columns,
count,
colorScheme = "blackAlpha",
+ shouldPaginate = true,
selectableRows,
onRowClick,
onSelectedRowsChange,
}: TableProps<T>) => {
- const {
- headerGroups,
- rows,
- selectedFlatRows,
- getTableProps,
- getTableBodyProps,
- prepareRow,
- } = useTable(
- {
- columns,
- data,
+ const pagination = usePagination(count);
+ const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
+
+ if (selectableRows) columns.unshift(getSelectableColumn<T>());
+ const table = useReactTable({
+ data,
+ columns,
+ state: {
+ rowSelection,
},
- useSortBy,
- useRowSelect,
- (hooks) => {
- selectableRows &&
- hooks.visibleColumns.push((columns) => [
- {
- id: "selection",
- Header: ({ getToggleAllRowsSelectedProps }) => (
- <div>
- <IndeterminateCheckbox {...getToggleAllRowsSelectedProps()} />
- </div>
- ),
- // @ts-ignore
- Cell: ({ row }) => (
- <div>
- <IndeterminateCheckbox {...row.getToggleRowSelectedProps()} />
- </div>
- ),
- },
- ...columns,
- ]);
- }
- );
-
- const rowBackground = useColor("gray.50");
-
- const [params, setParams] = useUrlParams();
- const limit = parseNumberFromUrlParam(params, "limit", 10);
- const offset = parseNumberFromUrlParam(params, "offset", 0);
-
- const pageIndex = Math.floor(offset / limit) + 1;
- const pageCount = Math.ceil(count / limit);
- const canPreviousPage = pageIndex > 1;
- const canNextPage = pageIndex < Math.ceil(count / limit);
-
- const gotoPage = (page: number) => {
- setParams({
- offset: (page - 1) * limit,
- limit,
- });
- };
-
- const previousPage = () => {
- gotoPage(pageIndex - 1);
- };
-
- const nextPage = () => {
- gotoPage(pageIndex + 1);
- };
-
- const setPageSize = (pageSize: number) => {
- setParams({
- offset: 0,
- limit: pageSize,
- });
- };
+ onRowSelectionChange: setRowSelection,
+ getCoreRowModel: getCoreRowModel(),
+ });
useEffect(() => {
- if (selectableRows && typeof onSelectedRowsChange === "function") {
- onSelectedRowsChange(selectedFlatRows.map((row) => row.original));
+ if (typeof onSelectedRowsChange === "function") {
+ onSelectedRowsChange(
+ table.getSelectedRowModel().flatRows.map((row) => row.original)
+ );
}
- }, [selectableRows, selectedFlatRows, onSelectedRowsChange]);
+ }, [rowSelection, table, onSelectedRowsChange]);
+
+ const rows = table.getRowModel().rows;
+ const rowBackground = useColor("gray.50");
return (
<Box w="full">
- <ChakraTable {...getTableProps()}>
+ <ChakraTable>
<Thead>
- {headerGroups.map((headerGroup, headerIdx) => (
- <Tr
- {...headerGroup.getHeaderGroupProps()}
- key={`${headerGroup.id}-${headerIdx}`}
- >
- {headerGroup.headers.map((column) => (
- <Fragment key={column.id}>
- <Th
- {...column.getHeaderProps(column.getSortByToggleProps())}
- px={4}
- >
- <Flex
- justify="flex-start"
- align="center"
- fontSize="xs"
- color="gray.500"
- >
- {column.render("Header")}
- <chakra.span pl="4">
- {column.isSorted ? (
- column.isSortedDesc ? (
- <AiFillCaretDown aria-label="sorted descending" />
- ) : (
- <AiFillCaretUp aria-label="sorted ascending" />
- )
- ) : null}
- </chakra.span>
- </Flex>
+ {table.getHeaderGroups().map((headerGroup) => (
+ <Tr key={headerGroup.id}>
+ {headerGroup.headers.map((header) => {
+ return (
+ <Th key={header.id} colSpan={header.colSpan} px={4} py={3}>
+ {flexRender(
+ header.column.columnDef.header,
+ header.getContext()
+ )}
</Th>
- </Fragment>
- ))}
+ );
+ })}
</Tr>
))}
</Thead>
@@ -160,13 +94,11 @@ const Table = <T extends object>({
</Empty>
</Box>
) : ( */}
- <Tbody {...getTableBodyProps()}>
- {rows.map((row, rowIndex) => {
- prepareRow(row);
+ <Tbody>
+ {rows.map((row) => {
return (
<Tr
- {...row.getRowProps()}
- key={`${row.id}-${rowIndex}`}
+ key={row.id}
onClick={() => {
if (typeof onRowClick === "function") {
onRowClick(row.original);
@@ -178,34 +110,25 @@ const Table = <T extends object>({
background: rowBackground,
}}
>
- {row.cells.map((cell, colIndex) => (
- <Fragment key={`${cell.column.id}-${colIndex}`}>
- <Td fontSize="sm" px={4} py={3} {...cell.getCellProps()}>
- {cell.render("Cell")}
+ {row.getVisibleCells().map((cell) => {
+ return (
+ <Td key={cell.id} fontSize="sm" px={4} py={2}>
+ {flexRender(
+ cell.column.columnDef.cell,
+ cell.getContext()
+ )}
</Td>
- </Fragment>
- ))}
+ );
+ })}
</Tr>
);
})}
</Tbody>
{/* )} */}
</ChakraTable>
- {rows.length > 0 && (
- <Pagination
- count={count}
- offset={offset}
- pageIndex={pageIndex}
- pageSize={limit}
- canPreviousPage={canPreviousPage}
- canNextPage={canNextPage}
- pageCount={pageCount}
- gotoPage={gotoPage}
- nextPage={nextPage}
- previousPage={previousPage}
- setPageSize={setPageSize}
- colorScheme={colorScheme}
- />
+
+ {rows.length > 0 && shouldPaginate && (
+ <Pagination {...pagination} colorScheme={colorScheme} />
)}
</Box>
);
@@ -235,4 +158,28 @@ const IndeterminateCheckbox = forwardRef<
IndeterminateCheckbox.displayName = "IndeterminateCheckbox";
+function getSelectableColumn<T>(): ColumnDef<T> {
+ return {
+ id: "select",
+ header: ({ table }) => (
+ <IndeterminateCheckbox
+ {...{
+ checked: table.getIsAllRowsSelected(),
+ indeterminate: table.getIsSomeRowsSelected(),
+ onChange: table.getToggleAllRowsSelectedHandler(),
+ }}
+ />
+ ),
+ cell: ({ row }) => (
+ <IndeterminateCheckbox
+ {...{
+ checked: row.getIsSelected(),
+ indeterminate: row.getIsSomeSelected(),
+ onChange: row.getToggleSelectedHandler(),
+ }}
+ />
+ ),
+ };
+}
+
export default Table;
diff --git a/apps/carbon/app/components/Data/Table/components/Pagination.tsx b/apps/carbon/app/components/Data/Table/components/Pagination.tsx
index f4504a4529..12df612cda 100644
--- a/apps/carbon/app/components/Data/Table/components/Pagination.tsx
+++ b/apps/carbon/app/components/Data/Table/components/Pagination.tsx
@@ -37,7 +37,7 @@ export function Pagination({
previousPage,
setPageSize,
}: PaginationProps) {
- const pageSizes = [10, 25, 50, 100];
+ const pageSizes = [15, 25, 50, 100];
const pageSizeLabel = "results per page";
if (!pageSizes.includes(pageSize)) {
pageSizes.push(pageSize);
diff --git a/apps/carbon/app/components/Data/Table/components/index.ts b/apps/carbon/app/components/Data/Table/components/index.ts
new file mode 100644
index 0000000000..bae5bfe273
--- /dev/null
+++ b/apps/carbon/app/components/Data/Table/components/index.ts
@@ -0,0 +1,4 @@
+import { Pagination } from "./Pagination";
+import { usePagination } from "./usePagination";
+
+export { Pagination, usePagination };
diff --git a/apps/carbon/app/components/Data/Table/components/react.table.d.ts b/apps/carbon/app/components/Data/Table/components/react.table.d.ts
deleted file mode 100644
index 4413076ed2..0000000000
--- a/apps/carbon/app/components/Data/Table/components/react.table.d.ts
+++ /dev/null
@@ -1,129 +0,0 @@
-// @ts-nocheck
-import type {
- UseColumnOrderInstanceProps,
- UseColumnOrderState,
- UseExpandedHooks,
- UseExpandedInstanceProps,
- UseExpandedOptions,
- UseExpandedRowProps,
- UseExpandedState,
- UseFiltersColumnOptions,
- UseFiltersColumnProps,
- UseFiltersInstanceProps,
- UseFiltersOptions,
- UseFiltersState,
- UseGlobalFiltersColumnOptions,
- UseGlobalFiltersInstanceProps,
- UseGlobalFiltersOptions,
- UseGlobalFiltersState,
- UseGroupByCellProps,
- UseGroupByColumnOptions,
- UseGroupByColumnProps,
- UseGroupByHooks,
- UseGroupByInstanceProps,
- UseGroupByOptions,
- UseGroupByRowProps,
- UseGroupByState,
- UsePaginationInstanceProps,
- UsePaginationOptions,
- UsePaginationState,
- UseResizeColumnsColumnOptions,
- UseResizeColumnsColumnProps,
- UseResizeColumnsOptions,
- UseResizeColumnsState,
- UseRowSelectHooks,
- UseRowSelectInstanceProps,
- UseRowSelectOptions,
- UseRowSelectRowProps,
- UseRowSelectState,
- UseRowStateCellProps,
- UseRowStateInstanceProps,
- UseRowStateOptions,
- UseRowStateRowProps,
- UseRowStateState,
- UseSortByColumnOptions,
- UseSortByColumnProps,
- UseSortByHooks,
- UseSortByInstanceProps,
- UseSortByOptions,
- UseSortByState,
-} from "react-table";
-
-declare module "react-table" {
- // take this file as-is, or comment out the sections that don't apply to your plugin configuration
-
- export interface TableOptions<
- D extends Record<string, unknown>
- > extends UseExpandedOptions<D>,
- UseFiltersOptions<D>,
- UseGlobalFiltersOptions<D>,
- UseGroupByOptions<D>,
- UsePaginationOptions<D>,
- UseResizeColumnsOptions<D>,
- UseRowSelectOptions<D>,
- UseRowStateOptions<D>,
- UseSortByOptions<D>,
- // note that having Record here allows you to add anything to the options, this matches the spirit of the
- // underlying js library, but might be cleaner if it's replaced by a more specific type that matches your
- // feature set, this is a safe default.
- Record<string, any> {}
-
- export interface Hooks<
- D extends Record<string, unknown> = Record<string, unknown>
- > extends UseExpandedHooks<D>,
- UseGroupByHooks<D>,
- UseRowSelectHooks<D>,
- UseSortByHooks<D> {}
-
- export interface TableInstance<
- D extends Record<string, unknown> = Record<string, unknown>
- > extends UseColumnOrderInstanceProps<D>,
- UseExpandedInstanceProps<D>,
- UseFiltersInstanceProps<D>,
- UseGlobalFiltersInstanceProps<D>,
- UseGroupByInstanceProps<D>,
- UsePaginationInstanceProps<D>,
- UseRowSelectInstanceProps<D>,
- UseRowStateInstanceProps<D>,
- UseSortByInstanceProps<D> {}
-
- export interface TableState<
- D extends Record<string, unknown> = Record<string, unknown>
- > extends UseColumnOrderState<D>,
- UseExpandedState<D>,
- UseFiltersState<D>,
- UseGlobalFiltersState<D>,
- UseGroupByState<D>,
- UsePaginationState<D>,
- UseResizeColumnsState<D>,
- UseRowSelectState<D>,
- UseRowStateState<D>,
- UseSortByState<D> {}
-
- export interface ColumnInterface<
- D extends Record<string, unknown> = Record<string, unknown>
- > extends UseFiltersColumnOptions<D>,
- UseGlobalFiltersColumnOptions<D>,
- UseGroupByColumnOptions<D>,
- UseResizeColumnsColumnOptions<D>,
- UseSortByColumnOptions<D> {}
-
- export interface ColumnInstance<
- D extends Record<string, unknown> = Record<string, unknown>
- > extends UseFiltersColumnProps<D>,
- UseGroupByColumnProps<D>,
- UseResizeColumnsColumnProps<D>,
- UseSortByColumnProps<D> {}
-
- export interface Cell<
- D extends Record<string, unknown> = Record<string, unknown>
- > extends UseGroupByCellProps<D>,
- UseRowStateCellProps<D> {}
-
- export interface Row<
- D extends Record<string, unknown> = Record<string, unknown>
- > extends UseExpandedRowProps<D>,
- UseGroupByRowProps<D>,
- UseRowSelectRowProps<D>,
- UseRowStateRowProps<D> {}
-}
diff --git a/apps/carbon/app/components/Data/Table/components/usePagination.tsx b/apps/carbon/app/components/Data/Table/components/usePagination.tsx
new file mode 100644
index 0000000000..2e542a0518
--- /dev/null
+++ b/apps/carbon/app/components/Data/Table/components/usePagination.tsx
@@ -0,0 +1,49 @@
+import { useUrlParams } from "~/hooks";
+import { parseNumberFromUrlParam } from "~/utils/http";
+
+export function usePagination(count: number) {
+ const [params, setParams] = useUrlParams();
+ const pageSize = parseNumberFromUrlParam(params, "limit", 15);
+ const offset = parseNumberFromUrlParam(params, "offset", 0);
+
+ const pageIndex = Math.floor(offset / pageSize) + 1;
+ const pageCount = Math.ceil(count / pageSize);
+ const canPreviousPage = pageIndex > 1;
+ const canNextPage = pageIndex < Math.ceil(count / pageSize);
+
+ const gotoPage = (page: number) => {
+ setParams({
+ offset: (page - 1) * pageSize,
+ limit: pageSize,
+ });
+ };
+
+ const previousPage = () => {
+ gotoPage(pageIndex - 1);
+ };
+
+ const nextPage = () => {
+ gotoPage(pageIndex + 1);
+ };
+
+ const setPageSize = (pageSize: number) => {
+ setParams({
+ offset: 0,
+ limit: pageSize,
+ });
+ };
+
+ return {
+ count,
+ offset,
+ pageIndex,
+ pageCount,
+ pageSize,
+ canPreviousPage,
+ canNextPage,
+ gotoPage,
+ nextPage,
+ previousPage,
+ setPageSize,
+ };
+}
diff --git a/apps/carbon/app/components/Navigation/Topbar/Topbar.tsx b/apps/carbon/app/components/Navigation/Topbar/Topbar.tsx
index 6d8afa9fcf..abf429d12e 100644
--- a/apps/carbon/app/components/Navigation/Topbar/Topbar.tsx
+++ b/apps/carbon/app/components/Navigation/Topbar/Topbar.tsx
@@ -16,10 +16,14 @@ const Topbar = () => {
display="grid"
gap={4}
gridTemplateColumns="auto 1fr auto 1fr"
+ // backdropFilter="auto"
+ // backdropBlur="8px"
bg={useColor("white")}
borderBottom={1}
borderBottomColor={borderColor}
borderBottomStyle="solid"
+ position="sticky"
+ top={0}
zIndex={1}
>
<Logo />
diff --git a/apps/carbon/app/lib/logger.ts b/apps/carbon/app/lib/logger.ts
index 6dc48e5c54..a86efd0958 100644
--- a/apps/carbon/app/lib/logger.ts
+++ b/apps/carbon/app/lib/logger.ts
@@ -1,5 +1,5 @@
import Logger from "@carbon/logger";
-const logger = Logger.create("routing");
+const logger = Logger.create("carbon");
export default logger;
diff --git a/apps/carbon/app/modules/Users/EmployeeTypeForm/EmployeeTypeForm.tsx b/apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypeForm/EmployeeTypeForm.tsx
similarity index 96%
rename from apps/carbon/app/modules/Users/EmployeeTypeForm/EmployeeTypeForm.tsx
rename to apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypeForm/EmployeeTypeForm.tsx
index f87e20e35b..ff263ed1df 100644
--- a/apps/carbon/app/modules/Users/EmployeeTypeForm/EmployeeTypeForm.tsx
+++ b/apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypeForm/EmployeeTypeForm.tsx
@@ -15,9 +15,9 @@ import { useNavigate } from "@remix-run/react";
import { useState } from "react";
import { ValidatedForm } from "remix-validated-form";
import { Color, Hidden, Input, Submit } from "~/components/Form";
+import PermissionCheckboxes from "~/modules/Users/components/Permission";
+import type { Permission } from "~/modules/Users/types";
import { employeeTypeValidator } from "~/services/users";
-import PermissionCheckboxes from "../Permission";
-import type { Permission } from "../types";
type EmployeeTypeFormProps = {
initialValues: {
diff --git a/apps/carbon/app/modules/Users/EmployeeTypeForm/index.ts b/apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypeForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/EmployeeTypeForm/index.ts
rename to apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypeForm/index.ts
diff --git a/apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypesTable/EmployeeTypesTable.tsx b/apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypesTable/EmployeeTypesTable.tsx
new file mode 100644
index 0000000000..01853b9645
--- /dev/null
+++ b/apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypesTable/EmployeeTypesTable.tsx
@@ -0,0 +1,95 @@
+import { ActionMenu } from "@carbon/react";
+import { Box, Flex, MenuItem, VisuallyHidden } from "@chakra-ui/react";
+import { useNavigate } from "@remix-run/react";
+import { memo } from "react";
+import { BsPencilSquare } from "react-icons/bs";
+import { IoMdTrash } from "react-icons/io";
+import { Table } from "~/components/Data";
+import { usePermissions } from "~/hooks";
+import type { EmployeeType } from "~/modules/Users/types";
+
+type EmployeeTypesTableProps = {
+ data: EmployeeType[];
+ count: number;
+};
+
+const EmployeeTypesTable = memo(({ data, count }: EmployeeTypesTableProps) => {
+ const navigate = useNavigate();
+ const permissions = usePermissions();
+
+ const rows = data.map((row) => ({
+ id: row.id,
+ protected: row.protected,
+ name: row.name,
+ color: row.color,
+ }));
+
+ return (
+ <Table<typeof rows[number]>
+ data={rows}
+ columns={[
+ {
+ accessorKey: "name",
+ header: "Employee Type",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "color",
+ header: "Color",
+ cell: (item) => (
+ <Box
+ aria-label="Color"
+ w={6}
+ h={6}
+ borderRadius="md"
+ bg={item.getValue() ?? "#000000"}
+ role="img"
+ />
+ ),
+ },
+ {
+ accessorKey: "id",
+ header: () => <VisuallyHidden>Actions</VisuallyHidden>,
+ cell: ({ row }) => (
+ <Flex justifyContent="end">
+ {!row.original.protected &&
+ (permissions.can("update", "users") ||
+ permissions.can("delete", "users")) && (
+ <ActionMenu>
+ {permissions.can("update", "users") && (
+ <MenuItem
+ icon={<BsPencilSquare />}
+ onClick={() => {
+ navigate(
+ `/app/users/employee-types/${row.original.id}`
+ );
+ }}
+ >
+ Edit Employee Type
+ </MenuItem>
+ )}
+ {permissions.can("delete", "users") && (
+ <MenuItem
+ icon={<IoMdTrash />}
+ onClick={() => {
+ navigate(
+ `/app/users/employee-types/delete/${row.original.id}`
+ );
+ }}
+ >
+ Delete Employee Type
+ </MenuItem>
+ )}
+ </ActionMenu>
+ )}
+ </Flex>
+ ),
+ },
+ ]}
+ count={count}
+ />
+ );
+});
+
+EmployeeTypesTable.displayName = "EmployeeTypesTable";
+export default EmployeeTypesTable;
diff --git a/apps/carbon/app/modules/Users/EmployeeTypesTable/index.ts b/apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypesTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/EmployeeTypesTable/index.ts
rename to apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypesTable/index.ts
diff --git a/apps/carbon/app/modules/Users/EmployeeTypes/index.ts b/apps/carbon/app/modules/Users/EmployeeTypes/index.ts
new file mode 100644
index 0000000000..2a2e11e473
--- /dev/null
+++ b/apps/carbon/app/modules/Users/EmployeeTypes/index.ts
@@ -0,0 +1,4 @@
+import EmployeeTypesTable from "./EmployeeTypesTable";
+import EmployeeTypeForm from "./EmployeeTypeForm";
+
+export { EmployeeTypesTable, EmployeeTypeForm };
diff --git a/apps/carbon/app/modules/Users/EmployeeTypesTable/EmployeeTypesTable.tsx b/apps/carbon/app/modules/Users/EmployeeTypesTable/EmployeeTypesTable.tsx
deleted file mode 100644
index aeba61bf2a..0000000000
--- a/apps/carbon/app/modules/Users/EmployeeTypesTable/EmployeeTypesTable.tsx
+++ /dev/null
@@ -1,87 +0,0 @@
-import { ActionMenu } from "@carbon/react";
-import { Box, Flex, MenuItem, VisuallyHidden } from "@chakra-ui/react";
-import { useNavigate } from "@remix-run/react";
-import { memo } from "react";
-import { BsPencilSquare } from "react-icons/bs";
-import { IoMdTrash } from "react-icons/io";
-import { Table } from "~/components/Data";
-import { usePermissions } from "~/hooks";
-import type { EmployeeType } from "~/modules/Users/types";
-
-type EmployeeTypesTableProps = {
- data: EmployeeType[];
- count: number;
-};
-
-const EmployeeTypesTable = memo(({ data, count }: EmployeeTypesTableProps) => {
- const navigate = useNavigate();
- const permissions = usePermissions();
-
- const rows = data.map((row) => ({
- id: row.id,
- protected: row.protected,
- name: row.name,
- color: (
- <Box
- aria-label="Color"
- w={6}
- h={6}
- borderRadius="md"
- bg={row.color ?? "#000000"}
- role="img"
- />
- ),
- actions: (
- <Flex justifyContent="end">
- {!row.protected &&
- (permissions.can("update", "users") ||
- permissions.can("delete", "users")) && (
- <ActionMenu>
- {permissions.can("update", "users") && (
- <MenuItem icon={<BsPencilSquare />}>
- Edit Employee Type
- </MenuItem>
- )}
- {permissions.can("delete", "users") && (
- <MenuItem
- icon={<IoMdTrash />}
- onClick={(e) => {
- e.stopPropagation();
- navigate(`/app/users/employee-types/delete/${row.id}`);
- }}
- >
- Delete Employee Type
- </MenuItem>
- )}
- </ActionMenu>
- )}
- </Flex>
- ),
- }));
- return (
- <Table
- data={rows}
- columns={[
- {
- Header: "Employee Type",
- accessor: "name",
- },
- {
- Header: "Color",
- accessor: "color",
- },
- {
- Header: <VisuallyHidden>Actions</VisuallyHidden>,
- accessor: "actions",
- },
- ]}
- count={count}
- onRowClick={(row) => {
- if (!row.protected) navigate(`/app/users/employee-types/${row.id}`);
- }}
- />
- );
-});
-
-EmployeeTypesTable.displayName = "EmployeeTypesTable";
-export default EmployeeTypesTable;
diff --git a/apps/carbon/app/modules/Users/CreateEmployeeModal/CreateEmployeeModal.tsx b/apps/carbon/app/modules/Users/Employees/CreateEmployeeModal/CreateEmployeeModal.tsx
similarity index 100%
rename from apps/carbon/app/modules/Users/CreateEmployeeModal/CreateEmployeeModal.tsx
rename to apps/carbon/app/modules/Users/Employees/CreateEmployeeModal/CreateEmployeeModal.tsx
diff --git a/apps/carbon/app/modules/Users/CreateEmployeeModal/index.ts b/apps/carbon/app/modules/Users/Employees/CreateEmployeeModal/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/CreateEmployeeModal/index.ts
rename to apps/carbon/app/modules/Users/Employees/CreateEmployeeModal/index.ts
diff --git a/apps/carbon/app/modules/Users/EmployeePermissionsForm/EmployeePermissionsForm.tsx b/apps/carbon/app/modules/Users/Employees/EmployeePermissionsForm/EmployeePermissionsForm.tsx
similarity index 95%
rename from apps/carbon/app/modules/Users/EmployeePermissionsForm/EmployeePermissionsForm.tsx
rename to apps/carbon/app/modules/Users/Employees/EmployeePermissionsForm/EmployeePermissionsForm.tsx
index 12f68d3d15..f509468d9a 100644
--- a/apps/carbon/app/modules/Users/EmployeePermissionsForm/EmployeePermissionsForm.tsx
+++ b/apps/carbon/app/modules/Users/Employees/EmployeePermissionsForm/EmployeePermissionsForm.tsx
@@ -16,10 +16,10 @@ import type { PostgrestResponse } from "@supabase/supabase-js";
import { useEffect, useState } from "react";
import { ValidatedForm } from "remix-validated-form";
import { Hidden, Select, Submit } from "~/components/Form";
+import PermissionCheckboxes from "~/modules/Users/components/Permission";
+import type { EmployeeType, Permission } from "~/modules/Users/types";
import { employeeValidator } from "~/services/users";
import { mapRowsToOptions } from "~/utils/form";
-import PermissionCheckboxes from "../Permission";
-import type { EmployeeType, Permission } from "../types";
type EmployeePermissionsFormProps = {
name: string;
diff --git a/apps/carbon/app/modules/Users/EmployeePermissionsForm/index.ts b/apps/carbon/app/modules/Users/Employees/EmployeePermissionsForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/EmployeePermissionsForm/index.ts
rename to apps/carbon/app/modules/Users/Employees/EmployeePermissionsForm/index.ts
diff --git a/apps/carbon/app/modules/Users/EmployeesTable/EmployeesTable.tsx b/apps/carbon/app/modules/Users/Employees/EmployeesTable/EmployeesTable.tsx
similarity index 50%
rename from apps/carbon/app/modules/Users/EmployeesTable/EmployeesTable.tsx
rename to apps/carbon/app/modules/Users/Employees/EmployeesTable/EmployeesTable.tsx
index a6bf563d2d..25e3c94737 100644
--- a/apps/carbon/app/modules/Users/EmployeesTable/EmployeesTable.tsx
+++ b/apps/carbon/app/modules/Users/Employees/EmployeesTable/EmployeesTable.tsx
@@ -6,7 +6,7 @@ import { BsPencilSquare } from "react-icons/bs";
import { IoMdTrash } from "react-icons/io";
import { Table } from "~/components/Data";
import { usePermissions } from "~/hooks";
-import type { Employee, User } from "../types";
+import type { Employee, User } from "~/modules/Users/types";
type EmployeesTableProps = {
data: Employee[];
@@ -39,31 +39,9 @@ const EmployeesTable = memo(
id: user.id,
firstName: user.firstName,
lastName: user.lastName,
+ fullName: `${user.firstName} ${user.lastName}`,
email: user.email,
employeeType: employeeType.name,
- actions: (
- <Flex justifyContent="end">
- {permissions.can("update", "users") && (
- <ActionMenu>
- <MenuItem
- icon={<BsPencilSquare />}
- onClick={() => navigate(`/app/users/employees/${user.id}`)}
- >
- Edit Employee
- </MenuItem>
- <MenuItem
- icon={<IoMdTrash />}
- onClick={(e) => {
- e.stopPropagation();
- navigate(`/app/users/employeess/deactivate/${user.id}`);
- }}
- >
- Deactivate Employee
- </MenuItem>
- </ActionMenu>
- )}
- </Flex>
- ),
};
});
@@ -72,29 +50,59 @@ const EmployeesTable = memo(
data={rows}
columns={[
{
- Header: "First Name",
- accessor: "firstName",
+ accessorKey: "firstName",
+ header: "First Name",
+ cell: (item) => item.getValue(),
},
{
- Header: "Last Name",
- accessor: "lastName",
+ accessorKey: "lastName",
+ header: "Last Name",
+ cell: (item) => item.getValue(),
},
{
- Header: "Email",
- accessor: "email",
+ accessorKey: "email",
+ header: "Email",
+ cell: (item) => item.getValue(),
},
{
- Header: "Employee Type",
- accessor: "employeeType",
+ accessorKey: "employeeType",
+ header: "Employee Type",
+ cell: (item) => item.getValue(),
},
{
- Header: <VisuallyHidden>Actions</VisuallyHidden>,
- accessor: "actions",
+ header: () => <VisuallyHidden>Actions</VisuallyHidden>,
+ accessorKey: "id",
+ cell: (item) => (
+ <Flex justifyContent="end">
+ {permissions.can("update", "users") && (
+ <ActionMenu>
+ <MenuItem
+ icon={<BsPencilSquare />}
+ onClick={() =>
+ navigate(`/app/users/employees/${item.getValue()}`)
+ }
+ >
+ Edit Employee
+ </MenuItem>
+ <MenuItem
+ icon={<IoMdTrash />}
+ onClick={(e) => {
+ e.stopPropagation();
+ navigate(
+ `/app/users/employeess/deactivate/${item.getValue()}`
+ );
+ }}
+ >
+ Deactivate Employee
+ </MenuItem>
+ </ActionMenu>
+ )}
+ </Flex>
+ ),
},
]}
count={count}
selectableRows={selectableRows}
- // @ts-ignore
onSelectedRowsChange={onSelectedRowsChange}
/>
);
diff --git a/apps/carbon/app/modules/Users/EmployeesTable/index.ts b/apps/carbon/app/modules/Users/Employees/EmployeesTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/EmployeesTable/index.ts
rename to apps/carbon/app/modules/Users/Employees/EmployeesTable/index.ts
diff --git a/apps/carbon/app/modules/Users/Employees/index.ts b/apps/carbon/app/modules/Users/Employees/index.ts
new file mode 100644
index 0000000000..1eb3ecfa6a
--- /dev/null
+++ b/apps/carbon/app/modules/Users/Employees/index.ts
@@ -0,0 +1,5 @@
+import CreateEmployeeModal from "./CreateEmployeeModal";
+import EmployeePermissionsForm from "./EmployeePermissionsForm";
+import EmployeesTable from "./EmployeesTable";
+
+export { CreateEmployeeModal, EmployeePermissionsForm, EmployeesTable };
diff --git a/apps/carbon/app/modules/Users/Permission/Permission.tsx b/apps/carbon/app/modules/Users/components/Permission/Permission.tsx
similarity index 96%
rename from apps/carbon/app/modules/Users/Permission/Permission.tsx
rename to apps/carbon/app/modules/Users/components/Permission/Permission.tsx
index 12ecdf2afc..ba1215adef 100644
--- a/apps/carbon/app/modules/Users/Permission/Permission.tsx
+++ b/apps/carbon/app/modules/Users/components/Permission/Permission.tsx
@@ -1,6 +1,6 @@
import { Box, Checkbox, Stack } from "@chakra-ui/react";
import { capitalize } from "~/utils/string";
-import type { Permission } from "../types";
+import type { Permission } from "~/modules/Users/types";
type PermissionProps = {
module: string;
diff --git a/apps/carbon/app/modules/Users/Permission/index.ts b/apps/carbon/app/modules/Users/components/Permission/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/Permission/index.ts
rename to apps/carbon/app/modules/Users/components/Permission/index.ts
diff --git a/apps/carbon/app/modules/Users/index.ts b/apps/carbon/app/modules/Users/index.ts
index 0d0aa750d2..3b5dbf4b25 100644
--- a/apps/carbon/app/modules/Users/index.ts
+++ b/apps/carbon/app/modules/Users/index.ts
@@ -1,15 +1,3 @@
-import CreateEmployeeModal from "./CreateEmployeeModal";
-import EmployeePermissionsForm from "./EmployeePermissionsForm";
-import EmployeesTable from "./EmployeesTable";
-import EmployeeTypesTable from "./EmployeeTypesTable";
-import EmployeeTypeForm from "./EmployeeTypeForm";
import useUsersSidebar from "./useUsersSidebar";
-export {
- CreateEmployeeModal,
- EmployeePermissionsForm,
- EmployeesTable,
- EmployeeTypeForm,
- EmployeeTypesTable,
- useUsersSidebar,
-};
+export { useUsersSidebar };
diff --git a/apps/carbon/app/routes/_auth.callback.tsx b/apps/carbon/app/routes/_auth.callback.tsx
index 33c69ab04d..6f36c8a665 100644
--- a/apps/carbon/app/routes/_auth.callback.tsx
+++ b/apps/carbon/app/routes/_auth.callback.tsx
@@ -11,10 +11,11 @@ import {
commitAuthSession,
destroyAuthSession,
getAuthSession,
- setSessionFlash,
+ flash,
} from "~/services/session";
import { assertIsPost } from "~/utils/http";
import type { FormActionData } from "~/types";
+import { error } from "~/utils/result";
export async function loader({ request }: LoaderArgs) {
const authSession = await getAuthSession(request);
@@ -30,13 +31,9 @@ export async function action({ request }: ActionArgs): FormActionData {
const validation = await callbackValidator.validate(await request.formData());
if (validation.error) {
- return json(
- {
- success: false,
- message: "Invalid request",
- },
- { status: 400 }
- );
+ return json(error(validation.error, "Invalid callback form"), {
+ status: 400,
+ });
}
const { refreshToken } = validation.data;
@@ -48,15 +45,13 @@ export async function action({ request }: ActionArgs): FormActionData {
if (!authSession) {
return redirect(
"/",
- await setSessionFlash(request, {
- success: false,
- message: "Invalid token",
- })
+ await flash(request, error(authSession, "Invalid refresh token"))
);
}
// user has an account, skip creation and just commit the session
- if ((await getUserByEmail(authSession.email))?.data) {
+ const user = await getUserByEmail(authSession.email);
+ if (user?.data) {
return redirect("/reset-password", {
headers: {
"Set-Cookie": await commitAuthSession(request, {
@@ -67,10 +62,7 @@ export async function action({ request }: ActionArgs): FormActionData {
} else {
return redirect(
"/",
- await setSessionFlash(request, {
- success: false,
- message: "User not found",
- })
+ await flash(request, error(user.error, "User not found"))
);
}
}
diff --git a/apps/carbon/app/routes/_auth.forgot-password.tsx b/apps/carbon/app/routes/_auth.forgot-password.tsx
index d044bacc92..3aa0894675 100644
--- a/apps/carbon/app/routes/_auth.forgot-password.tsx
+++ b/apps/carbon/app/routes/_auth.forgot-password.tsx
@@ -21,6 +21,7 @@ import { forgotPasswordValidator, sendMagicLink } from "~/services/auth";
import { getUserByEmail } from "~/services/users";
import { assertIsPost } from "~/utils/http";
import type { FormActionData, Result } from "~/types";
+import { error } from "~/utils/result";
export const meta: MetaFunction = () => ({
title: "Carbon | Forgot Password",
@@ -48,10 +49,9 @@ export async function action({ request }: ActionArgs): FormActionData {
const authSession = await sendMagicLink(email);
if (!authSession) {
- return json(
- { success: false, message: "Failed to send email" },
- { status: 500 }
- );
+ return json(error(authSession, "Failed to send magic link"), {
+ status: 500,
+ });
}
}
diff --git a/apps/carbon/app/routes/_auth.login.tsx b/apps/carbon/app/routes/_auth.login.tsx
index c3cd28aa33..3ed39ab320 100644
--- a/apps/carbon/app/routes/_auth.login.tsx
+++ b/apps/carbon/app/routes/_auth.login.tsx
@@ -23,6 +23,7 @@ import {
} from "~/services/auth";
import type { FormActionData, Result } from "~/types";
import { assertIsPost } from "~/utils/http";
+import { error } from "~/utils/result";
export const meta: MetaFunction = () => ({
title: "Carbon | Login",
@@ -50,10 +51,9 @@ export async function action({ request }: ActionArgs): FormActionData {
const authSession = await signInWithEmail(email, password);
if (!authSession) {
- return json(
- { success: false, message: "Invalid email/password" },
- { status: 400 }
- );
+ return json(error(authSession, "Invalid email/password"), {
+ status: 400,
+ });
}
return createAuthSession({
diff --git a/apps/carbon/app/routes/_auth.reset-password.tsx b/apps/carbon/app/routes/_auth.reset-password.tsx
index f37cdb8708..d65be5a715 100644
--- a/apps/carbon/app/routes/_auth.reset-password.tsx
+++ b/apps/carbon/app/routes/_auth.reset-password.tsx
@@ -16,7 +16,8 @@ import { ValidatedForm, validationError } from "remix-validated-form";
import { Password, Submit } from "~/components/Form";
import { getSupabaseAdmin } from "~/lib/supabase";
import { resetPasswordValidator } from "~/services/auth/auth.form";
-import { requireAuthSession, setSessionFlash } from "~/services/session";
+import { requireAuthSession, flash } from "~/services/session";
+import { error, success } from "~/utils/result";
import { assertIsPost } from "~/utils/http";
export async function loader({ request }: LoaderArgs) {
@@ -37,27 +38,24 @@ export async function action({ request }: ActionArgs) {
const { password } = validation.data;
const { userId } = await requireAuthSession(request, { verify: true });
- const { error } = await getSupabaseAdmin().auth.admin.updateUserById(userId, {
- password,
- });
+ const updatePassword = await getSupabaseAdmin().auth.admin.updateUserById(
+ userId,
+ {
+ password,
+ }
+ );
- if (error) {
+ if (updatePassword.error) {
return json(
{},
- await setSessionFlash(request, {
- success: false,
- message: "Failed to reset password",
- })
+ await flash(
+ request,
+ error(updatePassword.error, "Failed to update password")
+ )
);
}
- return redirect(
- "/app",
- await setSessionFlash(request, {
- success: true,
- message: "Password updated",
- })
- );
+ return redirect("/app", await flash(request, success("Password updated")));
}
export default function ResetPasswordRoute() {
diff --git a/apps/carbon/app/routes/app.users.employee-types.$employeeTypeId.tsx b/apps/carbon/app/routes/app.users.employee-types.$employeeTypeId.tsx
index b3e0f1c0c4..2d7763d3d9 100644
--- a/apps/carbon/app/routes/app.users.employee-types.$employeeTypeId.tsx
+++ b/apps/carbon/app/routes/app.users.employee-types.$employeeTypeId.tsx
@@ -3,7 +3,7 @@ import { redirect } from "@remix-run/node";
import { json } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
import { validationError } from "remix-validated-form";
-import { EmployeeTypeForm } from "~/modules/Users";
+import { EmployeeTypeForm } from "~/modules/Users/EmployeeTypes";
import { requirePermissions } from "~/services/auth";
import {
employeeTypeValidator,
@@ -14,8 +14,9 @@ import {
upsertEmployeeType,
upsertEmployeeTypePermissions,
} from "~/services/users";
-import { setSessionFlash } from "~/services/session";
+import { flash } from "~/services/session";
import { assertIsPost } from "~/utils/http";
+import { error, success } from "~/utils/result";
export async function loader({ request, params }: LoaderArgs) {
const { client } = await requirePermissions(request, {
@@ -64,10 +65,10 @@ export async function action({ request }: ActionArgs) {
if (jsonValidation.success === false) {
return json(
{},
- await setSessionFlash(request, {
- success: false,
- message: "Failed to parse permissions",
- })
+ await flash(
+ request,
+ error(jsonValidation.error, "Failed to parse permissions")
+ )
);
}
@@ -80,10 +81,10 @@ export async function action({ request }: ActionArgs) {
if (updateEmployeeType.error) {
return json(
{},
- await setSessionFlash(request, {
- success: false,
- message: updateEmployeeType.error.message,
- })
+ await flash(
+ request,
+ error(updateEmployeeType.error, "Failed to update employee type")
+ )
);
}
@@ -96,19 +97,19 @@ export async function action({ request }: ActionArgs) {
if (updateEmployeeTypePermissions.error) {
return json(
{},
- await setSessionFlash(request, {
- success: false,
- message: updateEmployeeTypePermissions.error.message,
- })
+ await flash(
+ request,
+ error(
+ updateEmployeeTypePermissions.error,
+ "Failed to update employee type permissions"
+ )
+ )
);
}
return redirect(
"/app/users/employee-types",
- await setSessionFlash(request, {
- success: true,
- message: "Updated employee type",
- })
+ await flash(request, success("Updated employee type"))
);
}
diff --git a/apps/carbon/app/routes/app.users.employee-types.delete.$employeeTypeId.tsx b/apps/carbon/app/routes/app.users.employee-types.delete.$employeeTypeId.tsx
index 3ff110f128..f382c51af3 100644
--- a/apps/carbon/app/routes/app.users.employee-types.delete.$employeeTypeId.tsx
+++ b/apps/carbon/app/routes/app.users.employee-types.delete.$employeeTypeId.tsx
@@ -13,7 +13,8 @@ import { json, redirect } from "@remix-run/node";
import { Form, useLoaderData, useNavigate, useParams } from "@remix-run/react";
import { requirePermissions } from "~/services/auth";
import { deleteEmployeeType, getEmployeeType } from "~/services/users";
-import { setSessionFlash } from "~/services/session";
+import { flash } from "~/services/session";
+import { error, success } from "~/utils/result";
export async function loader({ request, params }: LoaderArgs) {
const { client } = await requirePermissions(request, {
@@ -33,10 +34,7 @@ export async function action({ request, params }: ActionArgs) {
if (!employeeTypeId) {
return redirect(
"/app/users/employee-types",
- await setSessionFlash(request, {
- success: false,
- message: "Employee type ID is required",
- })
+ await flash(request, error(params, "Failed to get an employee type id"))
);
}
@@ -44,10 +42,10 @@ export async function action({ request, params }: ActionArgs) {
if (deleteType.error) {
return redirect(
"/app/users/employee-types",
- await setSessionFlash(request, {
- success: false,
- message: deleteType.error.message,
- })
+ await flash(
+ request,
+ error(deleteType.error, "Failed to delete employee type")
+ )
);
}
@@ -55,10 +53,7 @@ export async function action({ request, params }: ActionArgs) {
return redirect(
"/app/users/employee-types",
- await setSessionFlash(request, {
- success: true,
- message: "Successfully deleted employee type",
- })
+ await flash(request, success("Successfully deleted employee type"))
);
}
diff --git a/apps/carbon/app/routes/app.users.employee-types.new.tsx b/apps/carbon/app/routes/app.users.employee-types.new.tsx
index 6f2f410bee..4758fdf523 100644
--- a/apps/carbon/app/routes/app.users.employee-types.new.tsx
+++ b/apps/carbon/app/routes/app.users.employee-types.new.tsx
@@ -4,7 +4,7 @@ import { json } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
import { validationError } from "remix-validated-form";
import { getSupabase } from "~/lib/supabase";
-import { EmployeeTypeForm } from "~/modules/Users";
+import { EmployeeTypeForm } from "~/modules/Users/EmployeeTypes";
import { requirePermissions } from "~/services/auth";
import {
employeeTypeValidator,
@@ -14,8 +14,9 @@ import {
upsertEmployeeType,
upsertEmployeeTypePermissions,
} from "~/services/users";
-import { requireAuthSession, setSessionFlash } from "~/services/session";
+import { requireAuthSession, flash } from "~/services/session";
import { assertIsPost } from "~/utils/http";
+import { error, success } from "~/utils/result";
export async function loader({ request }: LoaderArgs) {
const { accessToken } = await requireAuthSession(request);
@@ -25,10 +26,7 @@ export async function loader({ request }: LoaderArgs) {
if (features.error || features.data === null) {
return redirect(
"/app/users/employee-types",
- await setSessionFlash(request, {
- success: false,
- message: "Failed to fetch features",
- })
+ await flash(request, error(features.error, "Failed to get features"))
);
}
@@ -59,10 +57,10 @@ export async function action({ request }: ActionArgs) {
if (jsonValidation.success === false) {
return json(
{},
- await setSessionFlash(request, {
- success: false,
- message: "Failed to parse permissions",
- })
+ await flash(
+ request,
+ error(jsonValidation.error, "Failed to parse permissions")
+ )
);
}
@@ -73,10 +71,10 @@ export async function action({ request }: ActionArgs) {
if (insertEmployeeType.error) {
return json(
{},
- await setSessionFlash(request, {
- success: false,
- message: insertEmployeeType.error.message,
- })
+ await flash(
+ request,
+ error(insertEmployeeType.error, "Failed to insert employee type")
+ )
);
}
@@ -84,10 +82,10 @@ export async function action({ request }: ActionArgs) {
if (!employeeTypeId) {
return json(
{},
- await setSessionFlash(request, {
- success: false,
- message: "Failed to created employee type",
- })
+ await flash(
+ request,
+ error(insertEmployeeType, "Failed to insert employee type")
+ )
);
}
const insertEmployeeTypePermissions = await upsertEmployeeTypePermissions(
@@ -99,19 +97,19 @@ export async function action({ request }: ActionArgs) {
if (insertEmployeeTypePermissions.error) {
return json(
{},
- await setSessionFlash(request, {
- success: false,
- message: insertEmployeeTypePermissions.error.message,
- })
+ await flash(
+ request,
+ error(
+ insertEmployeeTypePermissions.error,
+ "Failed to insert employee type permissions"
+ )
+ )
);
}
return redirect(
"/app/users/employee-types",
- await setSessionFlash(request, {
- success: true,
- message: "Employee type updated",
- })
+ await flash(request, success("Employee type created"))
);
}
diff --git a/apps/carbon/app/routes/app.users.employee-types.tsx b/apps/carbon/app/routes/app.users.employee-types.tsx
index b3ea36d910..57f1a09ec0 100644
--- a/apps/carbon/app/routes/app.users.employee-types.tsx
+++ b/apps/carbon/app/routes/app.users.employee-types.tsx
@@ -6,7 +6,7 @@ import { Link, Outlet, useLoaderData } from "@remix-run/react";
import { IoMdAdd } from "react-icons/io";
import { DebouncedInput } from "~/components/Search";
import { usePermissions } from "~/hooks";
-import { EmployeeTypesTable } from "~/modules/Users";
+import { EmployeeTypesTable } from "~/modules/Users/EmployeeTypes";
import { requirePermissions } from "~/services/auth";
import { getEmployeeTypes } from "~/services/users";
import { getPaginationParams } from "~/utils/http";
diff --git a/apps/carbon/app/routes/app.users.employees.$employeeId.tsx b/apps/carbon/app/routes/app.users.employees.$employeeId.tsx
index c80a9eccc9..0a078fb88c 100644
--- a/apps/carbon/app/routes/app.users.employees.$employeeId.tsx
+++ b/apps/carbon/app/routes/app.users.employees.$employeeId.tsx
@@ -3,9 +3,9 @@ import { json } from "@remix-run/node";
import { redirect } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
import { validationError } from "remix-validated-form";
-import { EmployeePermissionsForm } from "~/modules/Users";
+import { EmployeePermissionsForm } from "~/modules/Users/Employees";
import { requirePermissions } from "~/services/auth";
-import { setSessionFlash } from "~/services/session";
+import { flash } from "~/services/session";
import {
employeePermissionsValidator,
employeeValidator,
@@ -15,6 +15,7 @@ import {
updateEmployee,
} from "~/services/users";
import { assertIsPost } from "~/utils/http";
+import { error } from "~/utils/result";
export async function loader({ request, params }: LoaderArgs) {
const { client } = await requirePermissions(request, {
@@ -32,10 +33,13 @@ export async function loader({ request, params }: LoaderArgs) {
if (claims.error || employee.error || claims.data === null) {
redirect(
"/app/users/employees",
- await setSessionFlash(request, {
- success: false,
- message: "Failed to fetch employee data",
- })
+ await flash(
+ request,
+ error(
+ { claims: claims.error, employee: employee.error },
+ "Failed to load employee"
+ )
+ )
);
}
@@ -43,10 +47,7 @@ export async function loader({ request, params }: LoaderArgs) {
if (permissions === null) {
redirect(
"/app/users/employees",
- await setSessionFlash(request, {
- success: false,
- message: "Failed to parse permissions",
- })
+ await flash(request, error(claims.data, "Failed to parse claims"))
);
}
@@ -77,10 +78,7 @@ export async function action({ request }: ActionArgs) {
) {
return json(
{},
- await setSessionFlash(request, {
- success: false,
- message: "Failed to parse permissions",
- })
+ await flash(request, error(permissions, "Failed to parse permissions"))
);
}
@@ -90,10 +88,7 @@ export async function action({ request }: ActionArgs) {
permissions,
});
- return redirect(
- "/app/users/employees",
- await setSessionFlash(request, result)
- );
+ return redirect("/app/users/employees", await flash(request, result));
}
export default function UsersEmployeeRoute() {
diff --git a/apps/carbon/app/routes/app.users.employees.new.tsx b/apps/carbon/app/routes/app.users.employees.new.tsx
index e2ffe1ab89..20f52f663d 100644
--- a/apps/carbon/app/routes/app.users.employees.new.tsx
+++ b/apps/carbon/app/routes/app.users.employees.new.tsx
@@ -2,13 +2,13 @@ import type { ActionArgs } from "@remix-run/node";
import { redirect } from "@remix-run/node";
import { validationError } from "remix-validated-form";
import { requirePermissions } from "~/services/auth";
-import { setSessionFlash } from "~/services/session";
+import { flash } from "~/services/session";
import {
createEmployeeAccount,
createEmployeeValidator,
} from "~/services/users";
import { assertIsPost } from "~/utils/http";
-import { CreateEmployeeModal } from "~/modules/Users";
+import { CreateEmployeeModal } from "~/modules/Users/Employees";
export async function action({ request }: ActionArgs) {
assertIsPost(request);
@@ -32,10 +32,7 @@ export async function action({ request }: ActionArgs) {
employeeType,
});
- return redirect(
- "/app/users/employees",
- await setSessionFlash(request, result)
- );
+ return redirect("/app/users/employees", await flash(request, result));
}
export default function () {
diff --git a/apps/carbon/app/routes/app.users.employees.tsx b/apps/carbon/app/routes/app.users.employees.tsx
index 227bc5b96d..f8faddb005 100644
--- a/apps/carbon/app/routes/app.users.employees.tsx
+++ b/apps/carbon/app/routes/app.users.employees.tsx
@@ -8,7 +8,7 @@ import { BsCheckSquare } from "react-icons/bs";
import { IoMdAdd } from "react-icons/io";
import { DebouncedInput } from "~/components/Search";
import { usePermissions, useUrlParams } from "~/hooks";
-import { EmployeesTable } from "~/modules/Users";
+import { EmployeesTable } from "~/modules/Users/Employees";
import type { User } from "~/modules/Users/types";
import { requirePermissions } from "~/services/auth";
import { getEmployees, getEmployeeTypes } from "~/services/users";
diff --git a/apps/carbon/app/routes/resource.groups.tsx b/apps/carbon/app/routes/resource.groups.tsx
index a930044a4e..cef561ebd2 100644
--- a/apps/carbon/app/routes/resource.groups.tsx
+++ b/apps/carbon/app/routes/resource.groups.tsx
@@ -1,22 +1,19 @@
import type { LoaderArgs } from "@remix-run/node";
import { json } from "@remix-run/node";
import { arrayToTree } from "performant-array-to-tree";
-import { getSupabase } from "~/lib/supabase";
import type { Group } from "~/modules/Users/types";
-import { requireAuthSession, setSessionFlash } from "~/services/session";
+import { requirePermissions } from "~/services/auth";
+import { flash } from "~/services/session";
+import { error } from "~/utils/result";
export async function loader({ request }: LoaderArgs) {
- const { accessToken } = await requireAuthSession(request);
- const client = getSupabase(accessToken);
+ const { client } = await requirePermissions(request, {});
const groups = await client.from("groups_view").select("*");
if (groups.error) {
return json(
{ groups: [], error: groups.error },
- await setSessionFlash(request, {
- success: false,
- message: "Failed to load groups",
- })
+ await flash(request, error(groups.error, "Failed to load groups"))
);
}
diff --git a/apps/carbon/app/routes/resource.users.employee-types.tsx b/apps/carbon/app/routes/resource.users.employee-types.tsx
index dd5148fa65..d9ca9992d0 100644
--- a/apps/carbon/app/routes/resource.users.employee-types.tsx
+++ b/apps/carbon/app/routes/resource.users.employee-types.tsx
@@ -1,12 +1,12 @@
import type { LoaderArgs } from "@remix-run/node";
import { json } from "@remix-run/node";
-import { getSupabase } from "~/lib/supabase";
import { getEmployeeTypes } from "~/services/users";
-import { requireAuthSession } from "~/services/session";
+import { requirePermissions } from "~/services/auth";
export async function loader({ request }: LoaderArgs) {
- const { accessToken } = await requireAuthSession(request);
- const client = getSupabase(accessToken);
+ const { client } = await requirePermissions(request, {
+ view: "users",
+ });
return json(await getEmployeeTypes(client));
}
diff --git a/apps/carbon/app/services/auth/auth.server.ts b/apps/carbon/app/services/auth/auth.server.ts
index 43a30beec6..91351d9b92 100644
--- a/apps/carbon/app/services/auth/auth.server.ts
+++ b/apps/carbon/app/services/auth/auth.server.ts
@@ -3,8 +3,9 @@ import type { AuthSession as SupabaseAuthSession } from "@supabase/supabase-js";
import { SERVER_URL } from "~/config/env";
import { REFRESH_ACCESS_TOKEN_THRESHOLD } from "~/config/env";
import { getSupabase, getSupabaseAdmin } from "~/lib/supabase";
-import { requireAuthSession, setSessionFlash } from "~/services/session";
+import { requireAuthSession, flash } from "~/services/session";
import { getPermissions } from "~/services/users";
+import { error } from "~/utils/result";
import type { AuthSession } from "./types";
export async function createEmailAuthAccount(
@@ -101,10 +102,10 @@ export async function requirePermissions(
if (!hasRequiredPermissions) {
throw redirect(
"/app",
- await setSessionFlash(request, {
- success: false,
- message: "Access Denied",
- })
+ await flash(
+ request,
+ error({ myPermissions, requirePermissions }, "Access Denied")
+ )
);
}
diff --git a/apps/carbon/app/services/session/session.server.ts b/apps/carbon/app/services/session/session.server.ts
index ede6b1cc99..db4bd101c1 100644
--- a/apps/carbon/app/services/session/session.server.ts
+++ b/apps/carbon/app/services/session/session.server.ts
@@ -20,6 +20,30 @@ import { refreshAccessToken, verifyAuthSession } from "../auth/auth.server";
import type { AuthSession } from "../auth/types";
import type { Result } from "~/types";
+async function assertAuthSession(
+ request: Request,
+ { onFailRedirectTo }: { onFailRedirectTo?: string } = {}
+) {
+ const authSession = await getAuthSession(request);
+
+ // If there is no user session, Fly, You Fools! 🧙‍♂️
+ if (!authSession?.accessToken || !authSession?.refreshToken) {
+ throw redirect(
+ `${onFailRedirectTo || "/login"}?${makeRedirectToFromHere(request)}`,
+ {
+ headers: {
+ "Set-Cookie": await commitAuthSession(request, {
+ authSession: null,
+ flashErrorMessage: "No user session found", // TODO: handle this in UI
+ }),
+ },
+ }
+ );
+ }
+
+ return authSession;
+}
+
const sessionStorage = createCookieSessionStorage({
cookie: {
name: "__authSession",
@@ -50,18 +74,6 @@ export async function createAuthSession({
});
}
-async function getSession(request: Request) {
- const cookie = request.headers.get("Cookie");
- return sessionStorage.getSession(cookie);
-}
-
-export async function getAuthSession(
- request: Request
-): Promise<AuthSession | null> {
- const session = await getSession(request);
- return session.get(SESSION_KEY);
-}
-
export async function commitAuthSession(
request: Request,
{
@@ -107,43 +119,49 @@ export async function destroyAuthSession(
);
}
-async function assertAuthSession(
- request: Request,
- { onFailRedirectTo }: { onFailRedirectTo?: string } = {}
-) {
- const authSession = await getAuthSession(request);
-
- // If there is no user session, Fly, You Fools! 🧙‍♂️
- if (!authSession?.accessToken || !authSession?.refreshToken) {
- throw redirect(
- `${onFailRedirectTo || "/login"}?${makeRedirectToFromHere(request)}`,
- {
- headers: {
- "Set-Cookie": await commitAuthSession(request, {
- authSession: null,
- flashErrorMessage: "No user session found", // TODO: handle this in UI
- }),
- },
- }
- );
+export async function flash(request: Request, result: Result) {
+ const session = await getSession(request);
+ if (typeof result.success === "boolean") {
+ session.flash("success", result.success);
+ session.flash("message", result.message);
}
- return authSession;
+ return {
+ headers: { "Set-Cookie": await sessionStorage.commitSession(session) },
+ };
+}
+
+export async function getAuthSession(
+ request: Request
+): Promise<AuthSession | null> {
+ const session = await getSession(request);
+ return session.get(SESSION_KEY);
+}
+
+export async function getSessionFlash(request: Request) {
+ const session = await getSession(request);
+
+ const result: Result = {
+ success: session.get("success") === true,
+ message: session.get("message"),
+ };
+
+ if (!result.message) return null;
+
+ const headers = { "Set-Cookie": await sessionStorage.commitSession(session) };
+
+ return { result, headers };
+}
+
+async function getSession(request: Request) {
+ const cookie = request.headers.get("Cookie");
+ return sessionStorage.getSession(cookie);
+}
+
+function isExpiringSoon(expiresAt: number) {
+ return (expiresAt - REFRESH_ACCESS_TOKEN_THRESHOLD) * 1000 < Date.now();
}
-/**
- * Assert auth session is present and verified from supabase auth api
- *
- * If used in loader (GET method)
- * - Refresh tokens if session is expired
- * - Return auth session if not expired
- * - Destroy session if refresh token is expired
- *
- * If used in action (POST method)
- * - Try to refresh session if expired and return this new session (it's your job to handle session commit)
- * - Return auth session if not expired
- * - Destroy session if refresh token is expired
- */
export async function requireAuthSession(
request: Request,
{
@@ -170,10 +188,6 @@ export async function requireAuthSession(
return authSession;
}
-function isExpiringSoon(expiresAt: number) {
- return (expiresAt - REFRESH_ACCESS_TOKEN_THRESHOLD) * 1000 < Date.now();
-}
-
export async function refreshAuthSession(
request: Request
): Promise<AuthSession> {
@@ -216,30 +230,3 @@ export async function refreshAuthSession(
// we can't redirect because we are in an action, so, deal with it and don't forget to handle session commit 👮‍♀️
return refreshedAuthSession;
}
-
-export async function getSessionFlash(request: Request) {
- const session = await getSession(request);
-
- const result: Result = {
- success: session.get("success") === true,
- message: session.get("message"),
- };
-
- if (!result.message) return null;
-
- const headers = { "Set-Cookie": await sessionStorage.commitSession(session) };
-
- return { result, headers };
-}
-
-export async function setSessionFlash(request: Request, result: Result) {
- const session = await getSession(request);
- if (typeof result.success === "boolean") {
- session.flash("success", result.success);
- session.flash("message", result.message);
- }
-
- return {
- headers: { "Set-Cookie": await sessionStorage.commitSession(session) },
- };
-}
diff --git a/apps/carbon/app/services/users/users.server.ts b/apps/carbon/app/services/users/users.server.ts
index 5072dd4d18..840cb7e71e 100644
--- a/apps/carbon/app/services/users/users.server.ts
+++ b/apps/carbon/app/services/users/users.server.ts
@@ -11,8 +11,9 @@ import type {
User,
} from "~/modules/Users/types";
import { deleteAuthAccount, sendInviteByEmail } from "~/services/auth";
-import { requireAuthSession, setSessionFlash } from "~/services/session";
+import { requireAuthSession, flash } from "~/services/session";
import type { Result } from "~/types";
+import { error, success } from "~/utils/result";
export async function createEmployeeAccount(
client: SupabaseClient<Database>,
@@ -32,21 +33,17 @@ export async function createEmployeeAccount(
client,
employeeType
);
- if (employeeTypePermissions.error) {
- return {
- success: false,
- message: employeeTypePermissions.error.message,
- };
- }
+ if (employeeTypePermissions.error)
+ return error(
+ employeeTypePermissions.error,
+ "Failed to get employee type permissions"
+ );
// TODO: we should only send this after we've done the other stuff
const invitation = await sendInviteByEmail(email);
if (invitation.error)
- return {
- success: false,
- message: invitation.error.message,
- };
+ return error(invitation.error.message, "Failed to send invitation email");
const userId = invitation.data.user.id;
@@ -54,10 +51,7 @@ export async function createEmployeeAccount(
const claimsUpdate = await setUserClaims(userId, claims);
if (claimsUpdate.error) {
await deleteAuthAccount(userId);
- return {
- success: false,
- message: claimsUpdate.error.message,
- };
+ return error(claimsUpdate.error, "Failed to set user claims");
}
const insertUser = await createUser(client, {
@@ -67,36 +61,21 @@ export async function createEmployeeAccount(
lastName,
});
- if (insertUser.error) {
- return {
- success: false,
- message: insertUser.error.message,
- };
- }
+ if (insertUser.error)
+ return error(insertUser.error, "Failed to create a new user");
- if (!insertUser.data) {
- return {
- success: false,
- message: "No data returned from createUser",
- };
- }
+ if (!insertUser.data)
+ return error(insertUser, "No data returned from create user");
const createEmployee = await insertEmployee(client, {
id: insertUser.data[0].id,
employeeTypeId: employeeType,
});
- if (createEmployee.error) {
- return {
- success: false,
- message: createEmployee.error.message,
- };
- }
+ if (createEmployee.error)
+ return error(createEmployee.error, "Failed to create an employee");
- return {
- success: true,
- message: "Employee account created",
- };
+ return success("Employee account created");
}
async function createUser(
@@ -224,9 +203,13 @@ export async function getPermissions(
) {
const { userId } = await requireAuthSession(request);
- let permissions: Record<string, Permission> | null = JSON.parse(
- (await redis.get(getPermissionCacheKey(userId))) || "null"
- );
+ let permissions: Record<string, Permission> | null = null;
+
+ try {
+ permissions = JSON.parse(
+ (await redis.get(getPermissionCacheKey(userId))) || "null"
+ );
+ } catch {}
// if we don't have permissions from redis, get them from the database
if (!permissions) {
@@ -234,10 +217,7 @@ export async function getPermissions(
if (claims.error || claims.data === null) {
throw redirect(
"/app",
- await setSessionFlash(request, {
- success: false,
- message: "Failed to parse claims",
- })
+ await flash(request, error(claims.error, "Failed to get claims"))
);
}
// convert claims to permissions
@@ -249,10 +229,7 @@ export async function getPermissions(
if (!permissions) {
throw redirect(
"/app",
- await setSessionFlash(request, {
- success: false,
- message: "Failed to parse claims",
- })
+ await flash(request, error(claims, "Failed to parse claims"))
);
}
}
@@ -270,10 +247,7 @@ export async function getUser(
if (user?.error || user?.data === null) {
throw redirect(
"/app",
- await setSessionFlash(request, {
- success: false,
- message: "Failed to get user",
- })
+ await flash(request, error(user.error, "Failed to get user"))
);
}
@@ -466,12 +440,8 @@ export async function updateEmployee(
.from("employee")
.upsert([{ id, employeeTypeId: employeeType }]);
- if (updateEmployeeEmployeeType.error) {
- return {
- success: false,
- message: "Failed to update employee type",
- };
- }
+ if (updateEmployeeEmployeeType.error)
+ return error(updateEmployeeEmployeeType.error, "Failed to update employee");
return updatePermissions(client, { id, permissions });
}
@@ -483,12 +453,8 @@ export async function updatePermissions(
if (await client.rpc("is_claims_admin")) {
const getClaims = await getClaimsById(client, id);
- if (getClaims.error) {
- return {
- success: false,
- message: "Failed parse claims",
- };
- }
+ if (getClaims.error) return error(getClaims.error, "Failed to get claims");
+
const currentClaims =
typeof getClaims.data !== "object" ||
Array.isArray(getClaims.data) ||
@@ -508,24 +474,14 @@ export async function updatePermissions(
...currentClaims,
...newClaims,
});
- if (claimsUpdate.error) {
- return {
- success: false,
- message: "Failed to update permissions",
- };
- }
+ if (claimsUpdate.error)
+ return error(claimsUpdate.error, "Failed to update claims");
await redis.del(getPermissionCacheKey(id));
- return {
- success: true,
- message: "Permissions updated",
- };
+ return success("Permissions updated");
} else {
- return {
- success: false,
- message: "Unauthorized",
- };
+ return error(null, "You do not have permission to update permissions");
}
}
diff --git a/apps/carbon/app/utils/http.ts b/apps/carbon/app/utils/http.ts
index 7b3bbc03c4..6c711ebc8c 100644
--- a/apps/carbon/app/utils/http.ts
+++ b/apps/carbon/app/utils/http.ts
@@ -108,7 +108,7 @@ export function getPaginationParams(params: URLSearchParams): {
limit: number;
offset: number;
} {
- const limit = parseNumberFromUrlParam(params, "limit", 10);
+ const limit = parseNumberFromUrlParam(params, "limit", 15);
const offset = parseNumberFromUrlParam(params, "offset", 0);
return { limit, offset };
diff --git a/apps/carbon/app/utils/result.ts b/apps/carbon/app/utils/result.ts
new file mode 100644
index 0000000000..a50698c5a4
--- /dev/null
+++ b/apps/carbon/app/utils/result.ts
@@ -0,0 +1,18 @@
+import logger from "~/lib/logger";
+import type { Result } from "~/types";
+
+export function error(error: any, message = "Request failed"): Result {
+ logger.error({ error, message });
+
+ return {
+ success: false,
+ message,
+ };
+}
+
+export function success(message = "Request succeeded"): Result {
+ return {
+ success: true,
+ message,
+ };
+}
diff --git a/apps/carbon/package.json b/apps/carbon/package.json
index 1f6616c910..9cbe4574d8 100644
--- a/apps/carbon/package.json
+++ b/apps/carbon/package.json
@@ -26,10 +26,11 @@
"@carbon/react": "*",
"@carbon/utils": "*",
"@supabase/supabase-js": "^2.1.0",
+ "@tanstack/react-table": "^8.7.3",
"@vercel/node": "^2.8.0",
"framer-motion": "^7.6.19",
- "lodash/words": "^4.2.2",
- "lodash/debounce": "^4.0.8",
+ "lodash.words": "^4.2.0",
+ "lodash.debounce": "^4.0.8",
"performant-array-to-tree": "1.11.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
diff --git a/init.sh b/init.sh
deleted file mode 100755
index cc4295dab6..0000000000
--- a/init.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-echo "copying .env file to apps/carbon"
-cp ./.env apps/carbon/.env
-echo "copying .env file to packages/carbon-database"
-cp ./.env packages/carbon-database/.env
\ No newline at end of file
diff --git a/packages/carbon-react/package.json b/packages/carbon-react/package.json
index 68ab5cface..3633d64899 100644
--- a/packages/carbon-react/package.json
+++ b/packages/carbon-react/package.json
@@ -28,8 +28,7 @@
"react-colorful": "^5.6.1",
"react-hook-form": "^7.37.0",
"react-icons": "^4.6.0",
- "react-select": "^5.5.1",
- "react-table": "^7.8.0"
+ "react-select": "^5.5.1"
},
"devDependencies": {
"@carbon/jest": "*",
@@ -38,7 +37,6 @@
"@types/jest": "^26.0.22",
"@types/react": "^18.0.21",
"@types/react-dom": "^18.0.6",
- "@types/react-table": "7.7.12",
"eslint": "^7.32.0",
"eslint-config-carbon": "*",
"jest": "^26.6.3",
diff --git a/packages/carbon-react/src/Inputs/Select/components/menu.tsx b/packages/carbon-react/src/Inputs/Select/components/menu.tsx
index e1384d758a..56b99ab85a 100644
--- a/packages/carbon-react/src/Inputs/Select/components/menu.tsx
+++ b/packages/carbon-react/src/Inputs/Select/components/menu.tsx
@@ -1,4 +1,3 @@
-import { useColor } from "@carbon/react";
import type { IconProps, SystemStyleObject } from "@chakra-ui/react";
import {
Box,
@@ -17,6 +16,7 @@ import type {
NoticeProps,
OptionProps,
} from "react-select";
+import { useColor } from "../../../hooks";
import type { SizeProps, ThemeObject } from "../types";
const Menu = <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(
diff --git a/packages/carbon-react/tsconfig.json b/packages/carbon-react/tsconfig.json
index 583176e012..0cb23a4674 100644
--- a/packages/carbon-react/tsconfig.json
+++ b/packages/carbon-react/tsconfig.json
@@ -4,5 +4,5 @@
},
"extends": "@carbon/tsconfig/react-library.json",
"include": ["src"],
- "exclude": ["dist", "build", "node_modules"]
+ "exclude": ["**/*.d.ts", "./dist", "node_modules"]
}
diff --git a/yarn.lock b/yarn.lock
index 97398cdf4b..affe0f847c 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3012,6 +3012,18 @@
dependencies:
defer-to-connect "^2.0.0"
+"@tanstack/react-table@^8.7.3":
+ version "8.7.3"
+ resolved "https://registry.yarnpkg.com/@tanstack/react-table/-/react-table-8.7.3.tgz#287713263f48c713ce0ad2324e930b138baa64b1"
+ integrity sha512-4hUSl10UGEp3DTS0sKe8ZEr0MYKEHXKXzAolzjs+w+vjVIimFICuyIjxisY6rLOvRVNXbwF5Pjyr+1YC6ptpZw==
+ dependencies:
+ "@tanstack/table-core" "8.7.3"
+
+"@tanstack/[email protected]":
+ version "8.7.3"
+ resolved "https://registry.yarnpkg.com/@tanstack/table-core/-/table-core-8.7.3.tgz#53e180e74b366468f2c0c10d24c0d148261d8398"
+ integrity sha512-P+LKZuytLRUEKv0zMKFpYCLb9ZRiZ+kaFXh99HS6gOEX58tq41PltQ2BhTBe2UPlB8O6IQFsilKhx94/6w3ZMg==
+
"@testing-library/dom@^8.11.1":
version "8.19.0"
resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.19.0.tgz#bd3f83c217ebac16694329e413d9ad5fdcfd785f"
@@ -3504,13 +3516,6 @@
dependencies:
"@types/react" "*"
- version "7.7.12"
- resolved "https://registry.yarnpkg.com/@types/react-table/-/react-table-7.7.12.tgz#628011d3cb695b07c678704a61f2f1d5b8e567fd"
- integrity sha512-bRUent+NR/WwtDGwI/BqhZ8XnHghwHw0HUKeohzB5xN3K2qKWYE5w19e7GCuOkL1CXD9Gi1HFy7TIm2AvgWUHg==
- dependencies:
- "@types/react" "*"
-
"@types/react-transition-group@^4.4.0":
version "4.4.5"
resolved "https://registry.yarnpkg.com/@types/react-transition-group/-/react-transition-group-4.4.5.tgz#aae20dcf773c5aa275d5b9f7cdbca638abc5e416"
@@ -8534,6 +8539,11 @@ lodash.truncate@^4.4.2:
resolved "https://registry.yarnpkg.com/lodash.truncate/-/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193"
integrity sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw==
+lodash.words@^4.2.0:
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/lodash.words/-/lodash.words-4.2.0.tgz#5ecfeaf8ecf8acaa8e0c8386295f1993c9cf4036"
+ integrity sha512-mXxqd8Yx9BGPij3lZKFSdOsjOTbL4krbCCp9slEozaN4EMppA2dFmK/f8HeohodprY6W0vOdiQ5WFgPaTI75xQ==
+
[email protected], lodash@^4.17.21, lodash@^4.7.0:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
@@ -10545,11 +10555,6 @@ react-style-singleton@^2.2.1:
invariant "^2.2.4"
tslib "^2.0.0"
-react-table@^7.8.0:
- version "7.8.0"
- resolved "https://registry.yarnpkg.com/react-table/-/react-table-7.8.0.tgz#07858c01c1718c09f7f1aed7034fcfd7bda907d2"
- integrity sha512-hNaz4ygkZO4bESeFfnfOft73iBUj8K5oKi1EcSHPAibEydfsX2MyU6Z8KCr3mv3C9Kqqh71U+DhZkFvibbnPbA==
-
react-transition-group@^4.3.0:
version "4.4.5"
resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-4.4.5.tgz#e53d4e3f3344da8521489fbef8f2581d42becdd1"