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.

refactor: drawer component

Brad Barbine1aee13ed7ab
diff --git a/apps/carbon/app/components/Layout/Sidebar/GroupedContentSidebar.tsx b/apps/carbon/app/components/Layout/Sidebar/GroupedContentSidebar.tsx
index eb780d6cf2..d64e2b0460 100644
--- a/apps/carbon/app/components/Layout/Sidebar/GroupedContentSidebar.tsx
+++ b/apps/carbon/app/components/Layout/Sidebar/GroupedContentSidebar.tsx
@@ -16,7 +16,7 @@ const GroupedContentSidebar = ({ groups }: { groups: RouteGroup[] }) => {
spacing={1}
className="border-b border-border p-2"
>
- <h4 className="text-xs text-muted-foreground font-bold pl-3 py-1 uppercase">
+ <h4 className="text-xs text-muted-foreground font-bold pl-4 py-1 uppercase">
{group.name}
</h4>
{group.routes.map((route) => {
diff --git a/apps/carbon/app/components/Table/components/Pagination/Pagination.tsx b/apps/carbon/app/components/Table/components/Pagination/Pagination.tsx
index d293afd25d..3cc1c680ea 100644
--- a/apps/carbon/app/components/Table/components/Pagination/Pagination.tsx
+++ b/apps/carbon/app/components/Table/components/Pagination/Pagination.tsx
@@ -30,7 +30,7 @@ const Pagination = (props: PaginationProps) => {
return (
<HStack
- className="text-center bg-background border-t justify-between px-4 py-2 w-full z-[1]"
+ className="text-center bg-background border-t border-border justify-between px-4 py-2 w-full z-[1]"
spacing={6}
>
<Menu>
@@ -88,7 +88,7 @@ export const PaginationButtons = ({
</>
) : (
<>
- <div className="flex font-sm font-medium align-center">
+ <div className="flex text-sm font-medium align-center">
{count > 0 ? offset + 1 : 0} - {Math.min(offset + pageSize, count)}{" "}
of {count}
</div>
diff --git a/apps/carbon/app/modules/accounting/accounting.models.ts b/apps/carbon/app/modules/accounting/accounting.models.ts
index 8ec4f53b56..e087f10d1c 100644
--- a/apps/carbon/app/modules/accounting/accounting.models.ts
+++ b/apps/carbon/app/modules/accounting/accounting.models.ts
@@ -228,7 +228,9 @@ export const currencyValidator = withZod(
.max(1, { message: "Symbol can only be one character" })
.optional()
),
- exchangeRate: zfd.numeric(),
+ exchangeRate: zfd.numeric(
+ z.number().min(0, { message: "Rate is required" })
+ ),
isBaseCurrency: zfd.checkbox(),
})
);
diff --git a/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoriesTable/AccountCategoriesTable.tsx b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoriesTable/AccountCategoriesTable.tsx
index 1a884b1cf5..15a03ae280 100644
--- a/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoriesTable/AccountCategoriesTable.tsx
+++ b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoriesTable/AccountCategoriesTable.tsx
@@ -4,7 +4,7 @@ import { useNavigate } from "@remix-run/react";
import type { ColumnDef } from "@tanstack/react-table";
import { memo, useCallback, useMemo, useState } from "react";
import { BiAddToQueue } from "react-icons/bi";
-import { BsListUl, BsPencilSquare } from "react-icons/bs";
+import { BsListUl, BsPencilFill } from "react-icons/bs";
import { IoMdTrash } from "react-icons/io";
import { Table } from "~/components";
import { ConfirmDelete } from "~/components/Modals";
@@ -109,7 +109,7 @@ const AccountCategoriesTable = memo(
View Subcategories
</MenuItem>
<MenuItem
- icon={<BsPencilSquare />}
+ icon={<BsPencilFill />}
onClick={() => {
navigate(path.to.accountingCategory(row.id!));
}}
diff --git a/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoryDetail/AccountCategoryDetail.tsx b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoryDetail/AccountCategoryDetail.tsx
index aff92ff2f1..1490d4cf25 100644
--- a/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoryDetail/AccountCategoryDetail.tsx
+++ b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoryDetail/AccountCategoryDetail.tsx
@@ -1,16 +1,18 @@
-import { Button, HStack, VStack, useDisclosure } from "@carbon/react";
import {
+ ActionMenu,
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
+ DrawerDescription,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
- IconButton,
- Tag,
- TagLabel,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+ useDisclosure,
+} from "@carbon/react";
+import { MenuItem } from "@chakra-ui/react";
import { Link } from "@remix-run/react";
import { useState } from "react";
import { BsPencilSquare } from "react-icons/bs";
@@ -49,57 +51,41 @@ const AccountCategoryDetail = ({
deleteModal.onClose();
};
+ const renderContextMenu = (subcategory: AccountSubcategory) => {
+ return (
+ <>
+ <MenuItem as={Link} to={subcategory.id} icon={<BsPencilSquare />}>
+ Edit Subcategory
+ </MenuItem>
+ <MenuItem onClick={() => onDelete(subcategory)} icon={<IoMdTrash />}>
+ Delete Subcategory
+ </MenuItem>
+ </>
+ );
+ };
+
return (
<>
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <DrawerOverlay />
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
<DrawerContent>
- <DrawerCloseButton />
<DrawerHeader>
- <VStack>
- <HStack className="content-between pr-8 w-full">
- <span>{accountCategory.category}</span>
- <Tag
- borderRadius="full"
- variant="outline"
- colorScheme={
- accountCategory.incomeBalance === "Income Statement"
- ? "green"
- : "gray"
- }
- >
- <TagLabel>{accountCategory.incomeBalance}</TagLabel>
- </Tag>
- </HStack>
- <p className="text-sm font-normal text-muted-foreground">
- A list of subcategories in the {accountCategory.category}{" "}
- category.
- </p>
- </VStack>
+ <DrawerTitle>{accountCategory.category}</DrawerTitle>
+ <DrawerDescription>
+ {accountCategory.incomeBalance}
+ </DrawerDescription>
</DrawerHeader>
<DrawerBody>
<VStack>
{accountSubcategories.map((subcategory) => {
return (
- <HStack key={subcategory.id} className="w-full">
+ <HStack spacing={1} key={subcategory.id} className="w-full">
<p className="flex-grow">{subcategory.name}</p>
- <Button
- asChild
- isIcon
- aria-label="Edit"
- variant="secondary"
- >
- <Link to={subcategory.id}>
- <BsPencilSquare />
- </Link>
- </Button>
-
- <IconButton
- aria-label="Delete"
- icon={<IoMdTrash />}
- variant="outline"
- onClick={() => onDelete(subcategory)}
- />
+ <ActionMenu>{renderContextMenu(subcategory)}</ActionMenu>
</HStack>
);
})}
diff --git a/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoryForm/AccountCategoryForm.tsx b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoryForm/AccountCategoryForm.tsx
index c86428f4ef..964762200f 100644
--- a/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoryForm/AccountCategoryForm.tsx
+++ b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoryForm/AccountCategoryForm.tsx
@@ -1,13 +1,14 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
import { ValidatedForm } from "remix-validated-form";
import { Hidden, Input, Select, Submit } from "~/components/Form";
import { usePermissions } from "~/hooks";
@@ -36,24 +37,30 @@ const AccountCategoryForm = ({
: !permissions.can("create", "accounting");
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={accountCategoryValidator}
- method="post"
- action={
- isEditing
- ? path.to.accountingCategory(initialValues.id!)
- : path.to.newAccountingCategory
- }
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={accountCategoryValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.accountingCategory(initialValues.id!)
+ : path.to.newAccountingCategory
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
<DrawerHeader>
- {isEditing ? "Edit" : "New"} Account Category
+ <DrawerTitle>
+ {isEditing ? "Edit" : "New"} Account Category
+ </DrawerTitle>
</DrawerHeader>
- <DrawerBody pb={8}>
+ <DrawerBody>
<Hidden name="id" />
<VStack>
<Input name="category" label="Category" />
@@ -83,8 +90,8 @@ const AccountCategoryForm = ({
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountSubcategoryForm/AccountSubcategoryForm.tsx b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountSubcategoryForm/AccountSubcategoryForm.tsx
index e4975bd117..8d360e461e 100644
--- a/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountSubcategoryForm/AccountSubcategoryForm.tsx
+++ b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountSubcategoryForm/AccountSubcategoryForm.tsx
@@ -1,16 +1,15 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
- FormControl,
- FormLabel,
- Input as InputBase,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
+import { FormControl, FormLabel, Input as InputBase } from "@chakra-ui/react";
import { useParams } from "@remix-run/react";
import { ValidatedForm } from "remix-validated-form";
import { Hidden, Input, Submit } from "~/components/Form";
@@ -47,24 +46,30 @@ const AccountSubcategoryForm = ({
: !permissions.can("create", "accounting");
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={accountSubcategoryValidator}
- method="post"
- action={
- isEditing
- ? path.to.accountingSubcategory(initialValues.id!)
- : path.to.newAccountingSubcategory(categoryId)
- }
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
+ <Drawer
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ open
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={accountSubcategoryValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.accountingSubcategory(initialValues.id!)
+ : path.to.newAccountingSubcategory(categoryId)
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
<DrawerHeader>
- {isEditing ? "Edit" : "New"} Account Subcategory
+ <DrawerTitle>
+ {isEditing ? "Edit" : "New"} Account Subcategory
+ </DrawerTitle>
</DrawerHeader>
- <DrawerBody pb={8}>
+ <DrawerBody>
<Hidden name="id" />
<Hidden name="accountCategoryId" />
<VStack>
@@ -83,8 +88,8 @@ const AccountSubcategoryForm = ({
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountForm/ChartOfAccountForm.tsx b/apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountForm/ChartOfAccountForm.tsx
index 191c1db86d..a2ad858e40 100644
--- a/apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountForm/ChartOfAccountForm.tsx
+++ b/apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountForm/ChartOfAccountForm.tsx
@@ -1,14 +1,16 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
+ DrawerDescription,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
- Grid,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
+import { Grid } from "@chakra-ui/react";
import { useNavigate } from "@remix-run/react";
import { useState } from "react";
@@ -72,26 +74,33 @@ const ChartOfAccountForm = ({ initialValues }: ChartOfAccountFormProps) => {
};
return (
- <Drawer onClose={onClose} isOpen={true} size="full">
- <ValidatedForm
- validator={accountValidator}
- method="post"
- action={
- isEditing
- ? path.to.chartOfAccount(initialValues.id!)
- : path.to.newChartOfAccount
- }
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent size="full">
+ <ValidatedForm
+ validator={accountValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.chartOfAccount(initialValues.id!)
+ : path.to.newChartOfAccount
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
<DrawerHeader>
- {isEditing
- ? `${initialValues.number} - ${initialValues.name}`
- : "New Account"}
+ <DrawerTitle>
+ {isEditing ? `${initialValues.number}` : "New Account"}
+ </DrawerTitle>
+ {isEditing && (
+ <DrawerDescription>{initialValues.name}</DrawerDescription>
+ )}
</DrawerHeader>
- <DrawerBody pb={8}>
+ <DrawerBody>
<Hidden name="id" />
<Grid
@@ -170,8 +179,8 @@ const ChartOfAccountForm = ({ initialValues }: ChartOfAccountFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/accounting/ui/Currencies/CurrencyForm/CurrencyForm.tsx b/apps/carbon/app/modules/accounting/ui/Currencies/CurrencyForm/CurrencyForm.tsx
index 67b04bd85b..610f33e7d4 100644
--- a/apps/carbon/app/modules/accounting/ui/Currencies/CurrencyForm/CurrencyForm.tsx
+++ b/apps/carbon/app/modules/accounting/ui/Currencies/CurrencyForm/CurrencyForm.tsx
@@ -1,16 +1,16 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
import { useNavigate } from "@remix-run/react";
import { useState } from "react";
-
import { ValidatedForm } from "remix-validated-form";
import { Boolean, Hidden, Input, Number, Submit } from "~/components/Form";
import { usePermissions, useRouteData } from "~/hooks";
@@ -43,20 +43,28 @@ const CurrencyForm = ({ initialValues }: CurrencyFormProps) => {
? !permissions.can("update", "accounting")
: !permissions.can("create", "accounting");
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={currencyValidator}
- method="post"
- action={
- isEditing ? path.to.currency(initialValues.id!) : path.to.newCurrency
- }
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{isEditing ? "Edit" : "New"} Currency</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={currencyValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.currency(initialValues.id!)
+ : path.to.newCurrency
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>{isEditing ? "Edit" : "New"} Currency</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<Hidden name="id" />
<VStack spacing={4}>
<Input
@@ -69,8 +77,8 @@ const CurrencyForm = ({ initialValues }: CurrencyFormProps) => {
<Number
name="exchangeRate"
label="Exchange Rate"
- isDisabled={isBaseCurrency}
- min={0}
+ min={isBaseCurrency ? 1 : 0}
+ max={isBaseCurrency ? 1 : undefined}
helperText={exchnageRateHelperText}
/>
<Boolean name="isBaseCurrency" label="Base Currency" />
@@ -84,8 +92,8 @@ const CurrencyForm = ({ initialValues }: CurrencyFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermForm/PaymentTermForm.tsx b/apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermForm/PaymentTermForm.tsx
index f6bd723405..4a4f4caf40 100644
--- a/apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermForm/PaymentTermForm.tsx
+++ b/apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermForm/PaymentTermForm.tsx
@@ -1,13 +1,14 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
import { useNavigate } from "@remix-run/react";
import { useState } from "react";
import { ValidatedForm } from "remix-validated-form";
@@ -44,22 +45,28 @@ const PaymentTermForm = ({ initialValues }: PaymentTermFormProps) => {
);
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={paymentTermValidator}
- method="post"
- action={
- isEditing
- ? path.to.paymentTerm(initialValues.id!)
- : path.to.newPaymentTerm
- }
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{isEditing ? "Edit" : "New"} Payment Term</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={paymentTermValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.paymentTerm(initialValues.id!)
+ : path.to.newPaymentTerm
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>{isEditing ? "Edit" : "New"} Payment Term</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<Hidden name="id" />
<VStack spacing={4}>
<Input name="name" label="Name" />
@@ -102,8 +109,8 @@ const PaymentTermForm = ({ initialValues }: PaymentTermFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/documents/ui/Documents/DocumentForm/DocumentForm.tsx b/apps/carbon/app/modules/documents/ui/Documents/DocumentForm/DocumentForm.tsx
index 117bce66b7..906b109d0a 100644
--- a/apps/carbon/app/modules/documents/ui/Documents/DocumentForm/DocumentForm.tsx
+++ b/apps/carbon/app/modules/documents/ui/Documents/DocumentForm/DocumentForm.tsx
@@ -1,13 +1,14 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
import { useNavigate } from "@remix-run/react";
import { ValidatedForm } from "remix-validated-form";
import { Hidden, Input, Submit, TextArea, Users } from "~/components/Form";
@@ -29,18 +30,24 @@ const DocumentForm = ({ initialValues, ownerId }: DocumentFormProps) => {
const isDisabled = !permissions.can("update", "documents");
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={documentValidator}
- method="post"
- action={path.to.document(initialValues.id)}
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{`Edit ${initialValues.name}.${initialValues.type}`}</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={documentValidator}
+ method="post"
+ action={path.to.document(initialValues.id)}
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>{`Edit ${initialValues.name}.${initialValues.type}`}</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<Hidden name="id" />
<Hidden name="type" />
<Hidden name="size" />
@@ -71,8 +78,8 @@ const DocumentForm = ({ initialValues, ownerId }: DocumentFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/ReceiptForm.tsx b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/ReceiptForm.tsx
index 8405d3af03..ed955d2cff 100644
--- a/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/ReceiptForm.tsx
+++ b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/ReceiptForm.tsx
@@ -1,14 +1,17 @@
-import { Button, HStack, Menubar, MenubarItem, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
- Grid,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ Menubar,
+ MenubarItem,
+ VStack,
+} from "@carbon/react";
+import { Grid } from "@chakra-ui/react";
import { Outlet } from "@remix-run/react";
import { ValidatedForm } from "remix-validated-form";
import {
@@ -70,12 +73,17 @@ const ReceiptForm = ({
return (
<>
- <Drawer onClose={onClose} isOpen={true} size="full">
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{initialValues.receiptId}</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent size="full">
+ <DrawerHeader>
+ <DrawerTitle>{initialValues.receiptId}</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<VStack spacing={4}>
<Menubar className="mb-2 mt--2">
<MenubarItem isDisabled={!canPost || isPosted} onClick={onPost}>
diff --git a/apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodForm/ShippingMethodForm.tsx b/apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodForm/ShippingMethodForm.tsx
index acaad70dbc..ae4c5efd5a 100644
--- a/apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodForm/ShippingMethodForm.tsx
+++ b/apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodForm/ShippingMethodForm.tsx
@@ -1,13 +1,15 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
+
import { useNavigate } from "@remix-run/react";
import { ValidatedForm } from "remix-validated-form";
import { Account, Hidden, Input, Select, Submit } from "~/components/Form";
@@ -38,24 +40,30 @@ const ShippingMethodForm = ({ initialValues }: ShippingMethodFormProps) => {
);
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={shippingMethodValidator}
- method="post"
- action={
- isEditing
- ? path.to.shippingMethod(initialValues.id!)
- : path.to.newShippingMethod
- }
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={shippingMethodValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.shippingMethod(initialValues.id!)
+ : path.to.newShippingMethod
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
<DrawerHeader>
- {isEditing ? "Edit" : "New"} Shipping Method
+ <DrawerTitle>
+ {isEditing ? "Edit" : "New"} Shipping Method
+ </DrawerTitle>
</DrawerHeader>
- <DrawerBody pb={8}>
+ <DrawerBody>
<Hidden name="id" />
<VStack spacing={4}>
<Input name="name" label="Name" />
@@ -84,8 +92,8 @@ const ShippingMethodForm = ({ initialValues }: ShippingMethodFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm/PurchaseInvoiceLineForm.tsx b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm/PurchaseInvoiceLineForm.tsx
index 0d9008ec9f..34532b20f6 100644
--- a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm/PurchaseInvoiceLineForm.tsx
+++ b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm/PurchaseInvoiceLineForm.tsx
@@ -1,12 +1,15 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
+import {
FormControl,
FormLabel,
Input,
@@ -205,24 +208,30 @@ const PurchaseInvoiceLineForm = ({
};
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- defaultValues={initialValues}
- validator={purchaseInvoiceLineValidator}
- method="post"
- action={
- isEditing
- ? path.to.purchaseInvoiceLine(invoiceId, initialValues.id!)
- : path.to.newPurchaseInvoiceLine(invoiceId)
- }
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ defaultValues={initialValues}
+ validator={purchaseInvoiceLineValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.purchaseInvoiceLine(invoiceId, initialValues.id!)
+ : path.to.newPurchaseInvoiceLine(invoiceId)
+ }
+ className="flex flex-col h-full"
+ >
<DrawerHeader>
- {isEditing ? "Edit" : "New"} Purchase Invoice Line
+ <DrawerTitle>
+ {isEditing ? "Edit" : "New"} Purchase Invoice Line
+ </DrawerTitle>
</DrawerHeader>
- <DrawerBody pb={8}>
+ <DrawerBody>
<Hidden name="id" />
<Hidden name="invoiceId" />
<Hidden name="description" value={partData.description} />
@@ -346,8 +355,8 @@ const PurchaseInvoiceLineForm = ({
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/parts/ui/Part/PartSupplierForm/PartSupplierForm.tsx b/apps/carbon/app/modules/parts/ui/Part/PartSupplierForm/PartSupplierForm.tsx
index de136f883e..c35b7e36d3 100644
--- a/apps/carbon/app/modules/parts/ui/Part/PartSupplierForm/PartSupplierForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/Part/PartSupplierForm/PartSupplierForm.tsx
@@ -1,13 +1,14 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
import { useNavigate, useParams } from "@remix-run/react";
import { useMemo } from "react";
import { ValidatedForm } from "remix-validated-form";
@@ -57,24 +58,30 @@ const PartSupplierForm = ({ initialValues }: PartSupplierFormProps) => {
const onClose = () => navigate(-1);
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- defaultValues={initialValues}
- validator={partSupplierValidator}
- method="post"
- action={
- isEditing
- ? path.to.partSupplier(partId, initialValues.id!)
- : path.to.newPartSupplier(partId)
- }
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ defaultValues={initialValues}
+ validator={partSupplierValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.partSupplier(partId, initialValues.id!)
+ : path.to.newPartSupplier(partId)
+ }
+ className="flex flex-col h-full"
+ >
<DrawerHeader>
- {isEditing ? "Edit" : "New"} Part Supplier
+ <DrawerTitle>
+ {isEditing ? "Edit" : "New"} Part Supplier
+ </DrawerTitle>
</DrawerHeader>
- <DrawerBody pb={8}>
+ <DrawerBody>
<Hidden name="id" />
<Hidden name="partId" />
@@ -101,8 +108,8 @@ const PartSupplierForm = ({ initialValues }: PartSupplierFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupForm/PartGroupForm.tsx b/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupForm/PartGroupForm.tsx
index 7f10b6d912..58562c7a2e 100644
--- a/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupForm/PartGroupForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupForm/PartGroupForm.tsx
@@ -1,13 +1,14 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
import { useNavigate } from "@remix-run/react";
import { ValidatedForm } from "remix-validated-form";
import { Hidden, Input, Submit, TextArea } from "~/components/Form";
@@ -31,22 +32,28 @@ const PartGroupForm = ({ initialValues }: PartGroupFormProps) => {
: !permissions.can("create", "parts");
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={partGroupValidator}
- method="post"
- action={
- isEditing
- ? path.to.partGroup(initialValues.id!)
- : path.to.newPartGroup
- }
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{isEditing ? "Edit" : "New"} Part Group</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={partGroupValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.partGroup(initialValues.id!)
+ : path.to.newPartGroup
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>{isEditing ? "Edit" : "New"} Part Group</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<Hidden name="id" />
<VStack spacing={4}>
<Input name="name" label="Part Group" />
@@ -61,8 +68,8 @@ const PartGroupForm = ({ initialValues }: PartGroupFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/parts/ui/Service/ServiceSupplierForm/ServiceSupplierForm.tsx b/apps/carbon/app/modules/parts/ui/Service/ServiceSupplierForm/ServiceSupplierForm.tsx
index f1788df1d8..ed09d00b64 100644
--- a/apps/carbon/app/modules/parts/ui/Service/ServiceSupplierForm/ServiceSupplierForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/Service/ServiceSupplierForm/ServiceSupplierForm.tsx
@@ -1,13 +1,14 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
import { useNavigate, useParams } from "@remix-run/react";
import { ValidatedForm } from "remix-validated-form";
import { Hidden, Input, Submit, Supplier } from "~/components/Form";
@@ -35,24 +36,30 @@ const ServiceSupplierForm = ({ initialValues }: ServiceSupplierFormProps) => {
const onClose = () => navigate(-1);
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- defaultValues={initialValues}
- validator={serviceSupplierValidator}
- method="post"
- action={
- isEditing
- ? path.to.serviceSupplier(serviceId, initialValues.id!)
- : path.to.newServiceSupplier(serviceId)
- }
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ defaultValues={initialValues}
+ validator={serviceSupplierValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.serviceSupplier(serviceId, initialValues.id!)
+ : path.to.newServiceSupplier(serviceId)
+ }
+ className="flex flex-col h-full"
+ >
<DrawerHeader>
- {isEditing ? "Edit" : "New"} Service Supplier
+ <DrawerTitle>
+ {isEditing ? "Edit" : "New"} Service Supplier
+ </DrawerTitle>
</DrawerHeader>
- <DrawerBody pb={8}>
+ <DrawerBody>
<Hidden name="id" />
<Hidden name="serviceId" />
@@ -69,8 +76,8 @@ const ServiceSupplierForm = ({ initialValues }: ServiceSupplierFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasureForm/UnitOfMeasureForm.tsx b/apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasureForm/UnitOfMeasureForm.tsx
index acc6730e82..f0f7cb6cfd 100644
--- a/apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasureForm/UnitOfMeasureForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasureForm/UnitOfMeasureForm.tsx
@@ -1,13 +1,15 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
+
import { useNavigate } from "@remix-run/react";
import { ValidatedForm } from "remix-validated-form";
import { Hidden, Input, Submit } from "~/components/Form";
@@ -31,20 +33,26 @@ const UnitOfMeasureForm = ({ initialValues }: UnitOfMeasureFormProps) => {
: !permissions.can("create", "parts");
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={unitOfMeasureValidator}
- method="post"
- action={isEditing ? path.to.uom(initialValues.id!) : path.to.newUom}
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={unitOfMeasureValidator}
+ method="post"
+ action={isEditing ? path.to.uom(initialValues.id!) : path.to.newUom}
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
<DrawerHeader>
- {isEditing ? "Edit" : "New"} Unit of Measure
+ <DrawerTitle>
+ {isEditing ? "Edit" : "New"} Unit of Measure
+ </DrawerTitle>
</DrawerHeader>
- <DrawerBody pb={8}>
+ <DrawerBody>
<Hidden name="id" />
<VStack spacing={4}>
<Input name="name" label="Unit of Measure" />
@@ -63,8 +71,8 @@ const UnitOfMeasureForm = ({ initialValues }: UnitOfMeasureFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm/PurchaseOrderLineForm.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm/PurchaseOrderLineForm.tsx
index 8ae11d4ee8..0438c24ea3 100644
--- a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm/PurchaseOrderLineForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm/PurchaseOrderLineForm.tsx
@@ -1,12 +1,15 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
+import {
FormControl,
FormLabel,
Input,
@@ -203,24 +206,30 @@ const PurchaseOrderLineForm = ({
};
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- defaultValues={initialValues}
- validator={purchaseOrderLineValidator}
- method="post"
- action={
- isEditing
- ? path.to.purchaseOrderLine(orderId, initialValues.id!)
- : path.to.newPurchaseOrderLine(orderId)
- }
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ defaultValues={initialValues}
+ validator={purchaseOrderLineValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.purchaseOrderLine(orderId, initialValues.id!)
+ : path.to.newPurchaseOrderLine(orderId)
+ }
+ className="flex flex-col h-full"
+ >
<DrawerHeader>
- {isEditing ? "Edit" : "New"} Purchase Order Line
+ <DrawerTitle>
+ {isEditing ? "Edit" : "New"} Purchase Order Line
+ </DrawerTitle>
</DrawerHeader>
- <DrawerBody pb={8}>
+ <DrawerBody>
<Hidden name="id" />
<Hidden name="purchaseOrderId" />
<Hidden name="description" value={partData.description} />
@@ -344,8 +353,8 @@ const PurchaseOrderLineForm = ({
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierContactForm/SupplierContactForm.tsx b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierContactForm/SupplierContactForm.tsx
index 0599fdb1e6..662c81fe8f 100644
--- a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierContactForm/SupplierContactForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierContactForm/SupplierContactForm.tsx
@@ -1,13 +1,14 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
import { useNavigate, useParams } from "@remix-run/react";
import { ValidatedForm } from "remix-validated-form";
import {
@@ -42,23 +43,29 @@ const SupplierContactForm = ({ initialValues }: SupplierContactFormProps) => {
const onClose = () => navigate(path.to.supplierContacts(supplierId));
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={supplierContactValidator}
- method="post"
- action={
- isEditing
- ? path.to.supplierContact(supplierId, initialValues.id!)
- : path.to.newSupplierContact(supplierId)
- }
- defaultValues={initialValues}
- onSubmit={onClose}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{isEditing ? "Edit" : "New"} Contact</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={supplierContactValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.supplierContact(supplierId, initialValues.id!)
+ : path.to.newSupplierContact(supplierId)
+ }
+ defaultValues={initialValues}
+ onSubmit={onClose}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>{isEditing ? "Edit" : "New"} Contact</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<Hidden name="id" />
<Hidden name="contactId" />
<VStack spacing={4}>
@@ -88,8 +95,8 @@ const SupplierContactForm = ({ initialValues }: SupplierContactFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierLocationForm/SupplierLocationForm.tsx b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierLocationForm/SupplierLocationForm.tsx
index dcadb86136..b87bd4d9b9 100644
--- a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierLocationForm/SupplierLocationForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierLocationForm/SupplierLocationForm.tsx
@@ -1,13 +1,15 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
+
import { useNavigate, useParams } from "@remix-run/react";
import { ValidatedForm } from "remix-validated-form";
import { Hidden, Input, Submit } from "~/components/Form";
@@ -35,23 +37,29 @@ const SupplierLocationForm = ({ initialValues }: SupplierLocationFormProps) => {
const onClose = () => navigate(path.to.supplierLocations(supplierId));
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={supplierLocationValidator}
- method="post"
- action={
- isEditing
- ? path.to.supplierLocation(supplierId, initialValues.id!)
- : path.to.newSupplierLocation(supplierId)
- }
- defaultValues={initialValues}
- onSubmit={onClose}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{isEditing ? "Edit" : "New"} Location</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={supplierLocationValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.supplierLocation(supplierId, initialValues.id!)
+ : path.to.newSupplierLocation(supplierId)
+ }
+ defaultValues={initialValues}
+ onSubmit={onClose}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>{isEditing ? "Edit" : "New"} Location</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<Hidden name="id" />
<Hidden name="addressId" />
<VStack spacing={4}>
@@ -71,8 +79,8 @@ const SupplierLocationForm = ({ initialValues }: SupplierLocationFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypeForm/SupplierTypeForm.tsx b/apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypeForm/SupplierTypeForm.tsx
index e453e51bab..5cf004a280 100644
--- a/apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypeForm/SupplierTypeForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypeForm/SupplierTypeForm.tsx
@@ -1,13 +1,14 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
import { useNavigate } from "@remix-run/react";
import { ValidatedForm } from "remix-validated-form";
import { Color, Hidden, Input, Submit } from "~/components/Form";
@@ -31,24 +32,30 @@ const SupplierTypeForm = ({ initialValues }: SupplierTypeFormProps) => {
: !permissions.can("create", "purchasing");
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={supplierTypeValidator}
- method="post"
- action={
- isEditing
- ? path.to.supplierType(initialValues.id!)
- : path.to.newSupplierType
- }
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={supplierTypeValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.supplierType(initialValues.id!)
+ : path.to.newSupplierType
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
<DrawerHeader>
- {isEditing ? "Edit" : "New"} Supplier Type
+ <DrawerTitle>
+ {isEditing ? "Edit" : "New"} Supplier Type
+ </DrawerTitle>
</DrawerHeader>
- <DrawerBody pb={8}>
+ <DrawerBody>
<Hidden name="id" />
<VStack spacing={4}>
<Input name="name" label="Supplier Type" />
@@ -63,8 +70,8 @@ const SupplierTypeForm = ({ initialValues }: SupplierTypeFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/resources/resources.service.ts b/apps/carbon/app/modules/resources/resources.service.ts
index c1847c3fae..34f5f922e6 100644
--- a/apps/carbon/app/modules/resources/resources.service.ts
+++ b/apps/carbon/app/modules/resources/resources.service.ts
@@ -6,7 +6,7 @@ import type { TypeOfValidator } from "~/types/validators";
import type { GenericQueryFilters } from "~/utils/query";
import { setGenericQueryFilters } from "~/utils/query";
import { sanitize } from "~/utils/supabase";
-import type { locationValidator } from "./resources.models";
+import type { equipmentValidator, locationValidator } from "./resources.models";
export async function deleteAbility(
client: SupabaseClient<Database>,
@@ -1043,31 +1043,19 @@ export async function upsertEmployeeJob(
export async function upsertEquipment(
client: SupabaseClient<Database>,
equipment:
- | {
- name: string;
- description: string;
- equipmentTypeId: string;
- locationId: string;
- operatorsRequired?: number;
- setupHours?: number;
- workCellId?: string;
+ | (Omit<TypeOfValidator<typeof equipmentValidator>, "id"> & {
createdBy: string;
- }
- | {
+ })
+ | (Omit<TypeOfValidator<typeof equipmentValidator>, "id"> & {
id: string;
- name: string;
- description: string;
- equipmentTypeId: string;
- locationId: string;
- operatorsRequired?: number;
- workCellId?: string;
updatedBy: string;
- }
+ })
) {
if ("id" in equipment) {
const { id, ...update } = equipment;
return client.from("equipment").update(sanitize(update)).eq("id", id);
}
+
return client.from("equipment").insert([equipment]).select("id").single();
}
diff --git a/apps/carbon/app/modules/resources/ui/Abilities/AbilityForm/AbilityForm.tsx b/apps/carbon/app/modules/resources/ui/Abilities/AbilityForm/AbilityForm.tsx
index 848f7849ee..64d11acc0a 100644
--- a/apps/carbon/app/modules/resources/ui/Abilities/AbilityForm/AbilityForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Abilities/AbilityForm/AbilityForm.tsx
@@ -1,13 +1,15 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
+
import { useNavigate } from "@remix-run/react";
import { useState } from "react";
import { ValidatedForm } from "remix-validated-form";
@@ -42,18 +44,24 @@ const AbilityForm = ({ initialValues }: AbilityFormProps) => {
const isDisabled = !permissions.can("create", "resources");
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={abilityValidator}
- method="post"
- action={path.to.newAbility}
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>New Ability</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={abilityValidator}
+ method="post"
+ action={path.to.newAbility}
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>New Ability</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<Hidden name="id" />
<VStack spacing={4}>
<Input name="name" label="Name" />
@@ -102,8 +110,8 @@ const AbilityForm = ({ initialValues }: AbilityFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/resources/ui/Abilities/EmployeeAbilityForm/EmployeeAbilityForm.tsx b/apps/carbon/app/modules/resources/ui/Abilities/EmployeeAbilityForm/EmployeeAbilityForm.tsx
index cfd92898c0..2841790b4b 100644
--- a/apps/carbon/app/modules/resources/ui/Abilities/EmployeeAbilityForm/EmployeeAbilityForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Abilities/EmployeeAbilityForm/EmployeeAbilityForm.tsx
@@ -1,13 +1,15 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
+
import { useParams } from "@remix-run/react";
import { useState } from "react";
import { ValidatedForm } from "remix-validated-form";
@@ -58,22 +60,28 @@ const EmployeeAbilityForm = ({
if (!ability) return null;
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={employeeAbilityValidator}
- method="post"
- action={
- isEditing
- ? path.to.employeeAbility(ability.id, id!)
- : path.to.newEmployeeAbility(ability.id)
- }
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{isEditing ? "Edit" : "New"} Employee</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={employeeAbilityValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.employeeAbility(ability.id, id!)
+ : path.to.newEmployeeAbility(ability.id)
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>{isEditing ? "Edit" : "New"} Employee</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<VStack spacing={4}>
<Employee
name="employeeId"
@@ -125,8 +133,8 @@ const EmployeeAbilityForm = ({
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoryDetail/AttributeCategoryDetail.tsx b/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoryDetail/AttributeCategoryDetail.tsx
index e08c5bc5ab..92d508f64a 100644
--- a/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoryDetail/AttributeCategoryDetail.tsx
+++ b/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoryDetail/AttributeCategoryDetail.tsx
@@ -1,15 +1,18 @@
-import { Button, HStack, IconButton, useDisclosure } from "@carbon/react";
import {
+ ActionMenu,
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
+ DrawerDescription,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
- Tag,
- TagLabel,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ IconButton,
+ useDisclosure,
+} from "@carbon/react";
+import { MenuItem } from "@chakra-ui/react";
import { Link, useFetcher } from "@remix-run/react";
import { Reorder } from "framer-motion";
import { useMemo, useState } from "react";
@@ -39,18 +42,20 @@ const AttributeCategoryDetail = ({
const [params] = useUrlParams();
const sortOrderFetcher = useFetcher();
- const attributeMap = useMemo(
+ const attributeMap: Record<string, Attribute> = useMemo(
() =>
Array.isArray(attributeCategory.userAttribute)
- ? attributeCategory.userAttribute.reduce<
- Record<string, AttributeCategoryDetailType["userAttribute"]>
- >((acc, attribute) => {
- if (!attribute) return acc;
- return {
- ...acc,
- [attribute.id]: attribute,
- };
- }, {})
+ ? attributeCategory.userAttribute.reduce<Record<string, Attribute>>(
+ // @ts-ignore
+ (acc, attribute) => {
+ if (!attribute) return acc;
+ return {
+ ...acc,
+ [attribute.id]: attribute,
+ };
+ },
+ {}
+ )
: {},
[attributeCategory]
);
@@ -95,26 +100,36 @@ const AttributeCategoryDetail = ({
deleteModal.onClose();
};
+ const renderContextMenu = (attributeId: string) => {
+ return (
+ <>
+ <MenuItem as={Link} to={attributeId} icon={<BsPencilSquare />}>
+ Edit Attribute
+ </MenuItem>
+ <MenuItem
+ onClick={() => onDelete(attributeMap[attributeId])}
+ icon={<IoMdTrash />}
+ >
+ Delete Attribute
+ </MenuItem>
+ </>
+ );
+ };
+
return (
<>
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <DrawerOverlay />
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
<DrawerContent>
- <DrawerCloseButton />
<DrawerHeader>
- <HStack className="justify-between w-full pr-8">
- <span>{attributeCategory.name}</span>
- <Tag
- size="lg"
- borderRadius="full"
- variant={attributeCategory.public ? "solid" : "outline"}
- colorScheme={attributeCategory.public ? "green" : "gray"}
- >
- <TagLabel>
- {attributeCategory.public ? "Public" : "Private"}
- </TagLabel>
- </Tag>
- </HStack>
+ <DrawerTitle>{attributeCategory.name}</DrawerTitle>
+ <DrawerDescription>
+ {attributeCategory.public ? "Public" : "Private"}
+ </DrawerDescription>
</DrawerHeader>
<DrawerBody>
{Array.isArray(attributeCategory?.userAttribute) && (
@@ -122,14 +137,14 @@ const AttributeCategoryDetail = ({
axis="y"
values={sortOrder}
onReorder={onReorder}
- className="space-y-2"
+ className="space-y-2 w-full"
>
{sortOrder.map((sortId) => {
return (
<Reorder.Item
key={sortId}
value={sortId}
- className="rounded-lg"
+ className="rounded-lg w-full"
>
<HStack>
<IconButton
@@ -137,7 +152,7 @@ const AttributeCategoryDetail = ({
icon={<MdOutlineDragIndicator />}
variant="ghost"
/>
- <p className="flex-grow">
+ <p className="flex-grow text-foreground">
{
// @ts-ignore
attributeMap[sortId]?.name
@@ -157,26 +172,7 @@ const AttributeCategoryDetail = ({
"Unknown"
}
</Button>
-
- <Button
- asChild
- isIcon
- aria-label="Edit"
- variant="ghost"
- >
- <Link to={sortId.toString()}>
- <BsPencilSquare />
- </Link>
- </Button>
- <IconButton
- aria-label="Delete"
- icon={<IoMdTrash />}
- variant="ghost"
- onClick={() =>
- // @ts-ignore
- onDelete(attributeMap[sortId])
- }
- />
+ <ActionMenu>{renderContextMenu(sortId)}</ActionMenu>
</HStack>
</Reorder.Item>
);
diff --git a/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoryForm/AttributeCategoryForm.tsx b/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoryForm/AttributeCategoryForm.tsx
index 52767d9e27..ab371f5492 100644
--- a/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoryForm/AttributeCategoryForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoryForm/AttributeCategoryForm.tsx
@@ -1,13 +1,14 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
import { ValidatedForm } from "remix-validated-form";
import { Boolean, Hidden, Input, Submit } from "~/components/Form";
import { usePermissions } from "~/hooks";
@@ -31,24 +32,30 @@ const AttributeCategoryForm = ({
: !permissions.can("create", "resources");
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={attributeCategoryValidator}
- method="post"
- action={
- isEditing
- ? path.to.attributeCategory(initialValues.id!)
- : path.to.newAttributeCategory
- }
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={attributeCategoryValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.attributeCategory(initialValues.id!)
+ : path.to.newAttributeCategory
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
<DrawerHeader>
- {isEditing ? "Edit" : "New"} Attribute Category
+ <DrawerTitle>
+ {isEditing ? "Edit" : "New"} Attribute Category
+ </DrawerTitle>
</DrawerHeader>
- <DrawerBody pb={8}>
+ <DrawerBody>
<Hidden name="id" />
<VStack spacing={4}>
<Input name="name" label="Category Name" />
@@ -67,8 +74,8 @@ const AttributeCategoryForm = ({
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/resources/ui/Attributes/AttributeForm/AttributeForm.tsx b/apps/carbon/app/modules/resources/ui/Attributes/AttributeForm/AttributeForm.tsx
index 39e08b4cc2..dff7cc1b65 100644
--- a/apps/carbon/app/modules/resources/ui/Attributes/AttributeForm/AttributeForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Attributes/AttributeForm/AttributeForm.tsx
@@ -1,13 +1,15 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
+
import { useState } from "react";
import { ValidatedForm } from "remix-validated-form";
import {
@@ -68,22 +70,28 @@ const AttributeForm = ({
};
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={attributeValidator}
- method="post"
- action={
- isEditing
- ? path.to.attribute(initialValues.id!)
- : path.to.newAttribute
- }
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{isEditing ? "Edit" : "New"} Attribute</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={attributeValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.attribute(initialValues.id!)
+ : path.to.newAttribute
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>{isEditing ? "Edit" : "New"} Attribute</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<Hidden name="id" />
<VStack spacing={4}>
<Input name="name" label="Name" />
@@ -115,8 +123,8 @@ const AttributeForm = ({
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/resources/ui/Contractors/ContractorForm/ContractorForm.tsx b/apps/carbon/app/modules/resources/ui/Contractors/ContractorForm/ContractorForm.tsx
index 71ab4af5a7..9231afb51f 100644
--- a/apps/carbon/app/modules/resources/ui/Contractors/ContractorForm/ContractorForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Contractors/ContractorForm/ContractorForm.tsx
@@ -1,13 +1,15 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
+
import { useLocation, useNavigate } from "@remix-run/react";
import { useState } from "react";
import { ValidatedForm } from "remix-validated-form";
@@ -43,22 +45,28 @@ const ContractorForm = ({ initialValues }: ContractorFormProps) => {
: !permissions.can("create", "resources");
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={contractorValidator}
- method="post"
- action={
- isEditing
- ? path.to.contractor(initialValues.id!)
- : path.to.newContractor
- }
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{isEditing ? "Edit" : "New"} Contractor</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={contractorValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.contractor(initialValues.id!)
+ : path.to.newContractor
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>{isEditing ? "Edit" : "New"} Contractor</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<VStack spacing={4}>
<Supplier
name="supplierId"
@@ -89,8 +97,8 @@ const ContractorForm = ({ initialValues }: ContractorFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/resources/ui/Departments/DepartmentForm/DepartmentForm.tsx b/apps/carbon/app/modules/resources/ui/Departments/DepartmentForm/DepartmentForm.tsx
index 65d43f2c40..745ae8d8f0 100644
--- a/apps/carbon/app/modules/resources/ui/Departments/DepartmentForm/DepartmentForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Departments/DepartmentForm/DepartmentForm.tsx
@@ -1,13 +1,15 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
+
import { useNavigate } from "@remix-run/react";
import { ValidatedForm } from "remix-validated-form";
import { Color, Department, Hidden, Input, Submit } from "~/components/Form";
@@ -31,22 +33,28 @@ const DepartmentForm = ({ initialValues }: DepartmentFormProps) => {
: !permissions.can("create", "resources");
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={departmentValidator}
- method="post"
- action={
- isEditing
- ? path.to.department(initialValues.id!)
- : path.to.newDepartment
- }
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{isEditing ? "Edit" : "New"} Department</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={departmentValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.department(initialValues.id!)
+ : path.to.newDepartment
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>{isEditing ? "Edit" : "New"} Department</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<Hidden name="id" />
<VStack spacing={4}>
<Input name="name" label="Department Name" />
@@ -62,8 +70,8 @@ const DepartmentForm = ({ initialValues }: DepartmentFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentForm/EquipmentForm.tsx b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentForm/EquipmentForm.tsx
index 1cfad1b76e..3e8e116b30 100644
--- a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentForm/EquipmentForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentForm/EquipmentForm.tsx
@@ -1,16 +1,15 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
- FormControl,
- FormErrorMessage,
- FormLabel,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
+import { FormControl, FormErrorMessage, FormLabel } from "@chakra-ui/react";
import { useFetcher } from "@remix-run/react";
import { useEffect, useMemo, useState } from "react";
import { ValidatedForm, useControlField, useField } from "remix-validated-form";
@@ -83,22 +82,28 @@ const EquipmentForm = ({
);
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={equipmentValidator}
- method="post"
- action={
- isEditing
- ? path.to.equipmentUnit(initialValues.id!)
- : path.to.newEquipmentUnit
- }
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{isEditing ? "Edit" : "New"} Equipment</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={equipmentValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.equipmentUnit(initialValues.id!)
+ : path.to.newEquipmentUnit
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>{isEditing ? "Edit" : "New"} Equipment</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<Hidden name="id" />
<VStack spacing={4}>
<Input name="name" label="Name" />
@@ -139,8 +144,8 @@ const EquipmentForm = ({
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeDetail/EquipmentTypeDetail.tsx b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeDetail/EquipmentTypeDetail.tsx
index 60690135dd..97e10a9eee 100644
--- a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeDetail/EquipmentTypeDetail.tsx
+++ b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeDetail/EquipmentTypeDetail.tsx
@@ -1,20 +1,17 @@
import {
ActionMenu,
Button,
- HStack,
- VStack,
- useDisclosure,
-} from "@carbon/react";
-import {
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
- MenuItem,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+ useDisclosure,
+} from "@carbon/react";
+import { MenuItem } from "@chakra-ui/react";
import { Link } from "@remix-run/react";
import { useState } from "react";
import { BsPencilSquare } from "react-icons/bs";
@@ -70,11 +67,16 @@ const EquipmentTypeDetail = ({
return (
<>
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <DrawerOverlay />
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
<DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{equipmentType.name}</DrawerHeader>
+ <DrawerHeader>
+ <DrawerTitle>{equipmentType.name}</DrawerTitle>
+ </DrawerHeader>
<DrawerBody>
{Array.isArray(equipmentType?.equipment) && (
<VStack spacing={4}>
diff --git a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeForm/EquipmentTypeForm.tsx b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeForm/EquipmentTypeForm.tsx
index 5810201419..21f4db62cf 100644
--- a/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeForm/EquipmentTypeForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeForm/EquipmentTypeForm.tsx
@@ -1,13 +1,14 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
import { ValidatedForm } from "remix-validated-form";
import {
Ability,
@@ -38,24 +39,30 @@ const EquipmentTypeForm = ({
: !permissions.can("create", "resources");
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={equipmentTypeValidator}
- method="post"
- action={
- isEditing
- ? path.to.equipmentType(initialValues.id!)
- : path.to.newEquipmentType
- }
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={equipmentTypeValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.equipmentType(initialValues.id!)
+ : path.to.newEquipmentType
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
<DrawerHeader>
- {isEditing ? "Edit" : "New"} Equipment Type
+ <DrawerTitle>
+ {isEditing ? "Edit" : "New"} Equipment Type
+ </DrawerTitle>
</DrawerHeader>
- <DrawerBody pb={8}>
+ <DrawerBody>
<Hidden name="id" />
<VStack spacing={4}>
<Input name="name" label="Name" />
@@ -72,8 +79,8 @@ const EquipmentTypeForm = ({
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/resources/ui/Holidays/HolidayForm/HolidayForm.tsx b/apps/carbon/app/modules/resources/ui/Holidays/HolidayForm/HolidayForm.tsx
index 7b047042b8..5fc26de9a5 100644
--- a/apps/carbon/app/modules/resources/ui/Holidays/HolidayForm/HolidayForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Holidays/HolidayForm/HolidayForm.tsx
@@ -1,13 +1,14 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
import { useNavigate } from "@remix-run/react";
import { ValidatedForm } from "remix-validated-form";
import { DatePicker, Hidden, Input, Submit } from "~/components/Form";
@@ -31,20 +32,26 @@ const HolidayForm = ({ initialValues }: HolidayFormProps) => {
: !permissions.can("create", "resources");
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={holidayValidator}
- method="post"
- action={
- isEditing ? path.to.holiday(initialValues.id!) : path.to.newHoliday
- }
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{isEditing ? "Edit" : "New"} Holiday</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={holidayValidator}
+ method="post"
+ action={
+ isEditing ? path.to.holiday(initialValues.id!) : path.to.newHoliday
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>{isEditing ? "Edit" : "New"} Holiday</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<Hidden name="id" />
<VStack spacing={4}>
<Input name="name" label="Holiday Name" />
@@ -59,8 +66,8 @@ const HolidayForm = ({ initialValues }: HolidayFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/resources/ui/Locations/LocationForm/LocationForm.tsx b/apps/carbon/app/modules/resources/ui/Locations/LocationForm/LocationForm.tsx
index 31a1fbef86..ae0134d2a1 100644
--- a/apps/carbon/app/modules/resources/ui/Locations/LocationForm/LocationForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Locations/LocationForm/LocationForm.tsx
@@ -1,13 +1,14 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
import { useNavigate } from "@remix-run/react";
import { ValidatedForm } from "remix-validated-form";
import { Hidden, Input, Submit, Timezone } from "~/components/Form";
@@ -31,20 +32,28 @@ const LocationForm = ({ initialValues }: LocationFormProps) => {
: !permissions.can("create", "resources");
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={locationValidator}
- method="post"
- action={
- isEditing ? path.to.location(initialValues.id!) : path.to.newLocation
- }
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{isEditing ? "Edit" : "New"} Location</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={locationValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.location(initialValues.id!)
+ : path.to.newLocation
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>{isEditing ? "Edit" : "New"} Location</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<Hidden name="id" />
<VStack spacing={4}>
<Input name="name" label="Location Name" />
@@ -67,8 +76,8 @@ const LocationForm = ({ initialValues }: LocationFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/resources/ui/Partners/PartnerForm/PartnerForm.tsx b/apps/carbon/app/modules/resources/ui/Partners/PartnerForm/PartnerForm.tsx
index 64c8610690..e80a5a247d 100644
--- a/apps/carbon/app/modules/resources/ui/Partners/PartnerForm/PartnerForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Partners/PartnerForm/PartnerForm.tsx
@@ -1,16 +1,17 @@
-import { Button, HStack, Select, VStack, useMount } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
- FormControl,
- FormErrorMessage,
- FormLabel,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ Select,
+ VStack,
+ useMount,
+} from "@carbon/react";
+import { FormControl, FormErrorMessage, FormLabel } from "@chakra-ui/react";
import { useFetcher, useNavigate } from "@remix-run/react";
import { useEffect, useMemo } from "react";
import { ValidatedForm, useControlField, useField } from "remix-validated-form";
@@ -60,20 +61,26 @@ const PartnerForm = ({ initialValues }: PartnerFormProps) => {
);
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={partnerValidator}
- method="post"
- action={
- isEditing ? path.to.partner(initialValues.id) : path.to.newPartner
- }
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{isEditing ? "Edit" : "New"} Partner</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={partnerValidator}
+ method="post"
+ action={
+ isEditing ? path.to.partner(initialValues.id) : path.to.newPartner
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>{isEditing ? "Edit" : "New"} Partner</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<VStack spacing={4}>
<Supplier
name="supplierId"
@@ -104,8 +111,8 @@ const PartnerForm = ({ initialValues }: PartnerFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/resources/ui/Shifts/ShiftForm/ShiftForm.tsx b/apps/carbon/app/modules/resources/ui/Shifts/ShiftForm/ShiftForm.tsx
index c9bd7664f6..58096b7e83 100644
--- a/apps/carbon/app/modules/resources/ui/Shifts/ShiftForm/ShiftForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Shifts/ShiftForm/ShiftForm.tsx
@@ -1,15 +1,15 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
- FormControl,
- FormLabel,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
+import { FormControl, FormLabel } from "@chakra-ui/react";
import { useNavigate } from "@remix-run/react";
import { ValidatedForm } from "remix-validated-form";
import {
@@ -40,18 +40,26 @@ const ShiftForm = ({ initialValues }: ShiftFormProps) => {
: !permissions.can("create", "resources");
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={shiftValidator}
- method="post"
- action={isEditing ? path.to.shift(initialValues.id!) : path.to.newShift}
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{isEditing ? "Edit" : "New"} Shift</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={shiftValidator}
+ method="post"
+ action={
+ isEditing ? path.to.shift(initialValues.id!) : path.to.newShift
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>{isEditing ? "Edit" : "New"} Shift</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<Hidden name="id" />
<VStack spacing={4}>
<Input name="name" label="Shift Name" />
@@ -81,8 +89,8 @@ const ShiftForm = ({ initialValues }: ShiftFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellForm/WorkCellForm.tsx b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellForm/WorkCellForm.tsx
index c6d45aa955..e688737c14 100644
--- a/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellForm/WorkCellForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellForm/WorkCellForm.tsx
@@ -1,13 +1,15 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
+
import { ValidatedForm } from "remix-validated-form";
import {
DatePicker,
@@ -52,20 +54,28 @@ const WorkCellForm = ({
: !permissions.can("create", "resources");
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={workCellValidator}
- method="post"
- action={
- isEditing ? path.to.workCell(initialValues.id!) : path.to.newWorkCell
- }
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{isEditing ? "Edit" : "New"} Work Cell</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={workCellValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.workCell(initialValues.id!)
+ : path.to.newWorkCell
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>{isEditing ? "Edit" : "New"} Work Cell</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<Hidden name="id" />
<VStack spacing={4}>
<Input name="name" label="Name" />
@@ -88,8 +98,8 @@ const WorkCellForm = ({
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeDetail/WorkCellTypeDetail.tsx b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeDetail/WorkCellTypeDetail.tsx
index d2eff92690..1590c2fb9b 100644
--- a/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeDetail/WorkCellTypeDetail.tsx
+++ b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeDetail/WorkCellTypeDetail.tsx
@@ -1,20 +1,17 @@
import {
ActionMenu,
Button,
- HStack,
- VStack,
- useDisclosure,
-} from "@carbon/react";
-import {
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
- MenuItem,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+ useDisclosure,
+} from "@carbon/react";
+import { MenuItem } from "@chakra-ui/react";
import { Link } from "@remix-run/react";
import { useState } from "react";
import { BsPencilSquare } from "react-icons/bs";
@@ -70,11 +67,16 @@ const WorkCellTypeDetail = ({
return (
<>
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <DrawerOverlay />
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
<DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{workCellType.name}</DrawerHeader>
+ <DrawerHeader>
+ <DrawerTitle>{workCellType.name}</DrawerTitle>
+ </DrawerHeader>
<DrawerBody>
{Array.isArray(workCellType?.workCell) && (
<VStack spacing={4}>
diff --git a/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeForm/WorkCellTypeForm.tsx b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeForm/WorkCellTypeForm.tsx
index d8851c6b50..342d5b8792 100644
--- a/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeForm/WorkCellTypeForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeForm/WorkCellTypeForm.tsx
@@ -1,13 +1,14 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
import { ValidatedForm } from "remix-validated-form";
import {
Ability,
@@ -38,24 +39,30 @@ const WorkCellTypeForm = ({
: !permissions.can("create", "resources");
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={workCellTypeValidator}
- method="post"
- action={
- isEditing
- ? path.to.workCellType(initialValues.id!)
- : path.to.newWorkCellType
- }
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={workCellTypeValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.workCellType(initialValues.id!)
+ : path.to.newWorkCellType
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
<DrawerHeader>
- {isEditing ? "Edit" : "New"} Work Cell Type
+ <DrawerTitle>
+ {isEditing ? "Edit" : "New"} Work Cell Type
+ </DrawerTitle>
</DrawerHeader>
- <DrawerBody pb={8}>
+ <DrawerBody>
<Hidden name="id" />
<VStack spacing={4}>
<Input name="name" label="Name" />
@@ -72,8 +79,8 @@ const WorkCellTypeForm = ({
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/resources/ui/useResourcesSidebar.tsx b/apps/carbon/app/modules/resources/ui/useResourcesSidebar.tsx
index 3655b3c29a..4d7c4c84b6 100644
--- a/apps/carbon/app/modules/resources/ui/useResourcesSidebar.tsx
+++ b/apps/carbon/app/modules/resources/ui/useResourcesSidebar.tsx
@@ -1,3 +1,14 @@
+import {
+ BsCalendar2Check,
+ BsFillPinMapFill,
+ BsPeopleFill,
+ BsStopwatch,
+} from "react-icons/bs";
+import { FaPeopleArrows, FaPeopleCarry } from "react-icons/fa";
+import { FaListCheck } from "react-icons/fa6";
+import { GiOrganigram, GiSkills } from "react-icons/gi";
+import { MdDashboardCustomize } from "react-icons/md";
+import { TbCrane } from "react-icons/tb";
import type { RouteGroup } from "~/types";
import { path } from "~/utils/path";
@@ -8,22 +19,27 @@ const resourcesRoutes: RouteGroup[] = [
{
name: "People",
to: path.to.people,
+ icon: <BsPeopleFill />,
},
{
name: "Contractors",
to: path.to.contractors,
+ icon: <FaPeopleCarry />,
},
{
name: "Equipment",
to: path.to.equipment,
+ icon: <TbCrane />,
},
{
name: "Partners",
to: path.to.partners,
+ icon: <FaPeopleArrows />,
},
{
name: "Work Cells",
to: path.to.workCells,
+ icon: <MdDashboardCustomize />,
},
],
},
@@ -33,26 +49,32 @@ const resourcesRoutes: RouteGroup[] = [
{
name: "Abilities",
to: path.to.abilities,
+ icon: <GiSkills />,
},
{
name: "Attributes",
to: path.to.attributes,
+ icon: <FaListCheck />,
},
{
name: "Departments",
to: path.to.departments,
+ icon: <GiOrganigram />,
},
{
name: "Holidays",
to: path.to.holidays,
+ icon: <BsCalendar2Check />,
},
{
name: "Locations",
to: path.to.locations,
+ icon: <BsFillPinMapFill />,
},
{
name: "Shifts",
to: path.to.shifts,
+ icon: <BsStopwatch />,
},
],
},
diff --git a/apps/carbon/app/modules/sales/ui/Customer/CustomerContactForm/CustomerContactForm.tsx b/apps/carbon/app/modules/sales/ui/Customer/CustomerContactForm/CustomerContactForm.tsx
index 5ebdef316e..c342dd5ab5 100644
--- a/apps/carbon/app/modules/sales/ui/Customer/CustomerContactForm/CustomerContactForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Customer/CustomerContactForm/CustomerContactForm.tsx
@@ -1,13 +1,14 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
import { useNavigate, useParams } from "@remix-run/react";
import { ValidatedForm } from "remix-validated-form";
import {
@@ -42,23 +43,29 @@ const CustomerContactForm = ({ initialValues }: CustomerContactFormProps) => {
const onClose = () => navigate(path.to.customerContacts(customerId));
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={customerContactValidator}
- method="post"
- action={
- isEditing
- ? path.to.customerContact(customerId, initialValues.id!)
- : path.to.newCustomerContact(customerId)
- }
- defaultValues={initialValues}
- onSubmit={onClose}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{isEditing ? "Edit" : "New"} Contact</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={customerContactValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.customerContact(customerId, initialValues.id!)
+ : path.to.newCustomerContact(customerId)
+ }
+ defaultValues={initialValues}
+ onSubmit={onClose}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>{isEditing ? "Edit" : "New"} Contact</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<Hidden name="id" />
<Hidden name="contactId" />
<VStack spacing={4}>
@@ -88,8 +95,8 @@ const CustomerContactForm = ({ initialValues }: CustomerContactFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/sales/ui/Customer/CustomerLocationForm/CustomerLocationForm.tsx b/apps/carbon/app/modules/sales/ui/Customer/CustomerLocationForm/CustomerLocationForm.tsx
index df2b15e6ea..5682bc6ac6 100644
--- a/apps/carbon/app/modules/sales/ui/Customer/CustomerLocationForm/CustomerLocationForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Customer/CustomerLocationForm/CustomerLocationForm.tsx
@@ -1,14 +1,15 @@
-import { HStack, VStack } from "@carbon/react";
import {
Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
+
import { useNavigate, useParams } from "@remix-run/react";
import { ValidatedForm } from "remix-validated-form";
import { Hidden, Input, Submit } from "~/components/Form";
@@ -36,23 +37,29 @@ const CustomerLocationForm = ({ initialValues }: CustomerLocationFormProps) => {
const onClose = () => navigate(path.to.customerLocations(customerId));
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={customerLocationValidator}
- method="post"
- action={
- isEditing
- ? path.to.customerLocation(customerId, initialValues.id!)
- : path.to.newCustomerLocation(customerId)
- }
- defaultValues={initialValues}
- onSubmit={onClose}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{isEditing ? "Edit" : "New"} Location</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={customerLocationValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.customerLocation(customerId, initialValues.id!)
+ : path.to.newCustomerLocation(customerId)
+ }
+ defaultValues={initialValues}
+ onSubmit={onClose}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>{isEditing ? "Edit" : "New"} Location</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<Hidden name="id" />
<Hidden name="addressId" />
<VStack spacing={4}>
@@ -67,18 +74,13 @@ const CustomerLocationForm = ({ initialValues }: CustomerLocationFormProps) => {
<DrawerFooter>
<HStack>
<Submit isDisabled={isDisabled}>Save</Submit>
- <Button
- size="md"
- colorScheme="gray"
- variant="solid"
- onClick={onClose}
- >
+ <Button size="md" variant="solid" onClick={onClose}>
Cancel
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypeForm/CustomerTypeForm.tsx b/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypeForm/CustomerTypeForm.tsx
index 111d9b9b50..172ab60c6b 100644
--- a/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypeForm/CustomerTypeForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypeForm/CustomerTypeForm.tsx
@@ -1,13 +1,14 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
import { useNavigate } from "@remix-run/react";
import { ValidatedForm } from "remix-validated-form";
import { Color, Hidden, Input, Submit } from "~/components/Form";
@@ -31,24 +32,30 @@ const CustomerTypeForm = ({ initialValues }: CustomerTypeFormProps) => {
: !permissions.can("create", "sales");
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={customerTypeValidator}
- method="post"
- action={
- isEditing
- ? path.to.customerType(initialValues.id!)
- : path.to.newCustomerType
- }
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={customerTypeValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.customerType(initialValues.id!)
+ : path.to.newCustomerType
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
<DrawerHeader>
- {isEditing ? "Edit" : "New"} Customer Type
+ <DrawerTitle>
+ {isEditing ? "Edit" : "New"} Customer Type
+ </DrawerTitle>
</DrawerHeader>
- <DrawerBody pb={8}>
+ <DrawerBody>
<Hidden name="id" />
<VStack spacing={4}>
<Input name="name" label="Customer Type" />
@@ -63,8 +70,8 @@ const CustomerTypeForm = ({ initialValues }: CustomerTypeFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/settings/settings.service.ts b/apps/carbon/app/modules/settings/settings.service.ts
index c48e5a5f0d..e501753e7f 100644
--- a/apps/carbon/app/modules/settings/settings.service.ts
+++ b/apps/carbon/app/modules/settings/settings.service.ts
@@ -97,7 +97,7 @@ export async function getSequences(
query = query.ilike("name", `%${args.name}%`);
}
- query = setGenericQueryFilters(query, args);
+ query = setGenericQueryFilters(query, args, "table");
return query;
}
diff --git a/apps/carbon/app/modules/settings/ui/Sequences/SequenceForm/SequenceForm.tsx b/apps/carbon/app/modules/settings/ui/Sequences/SequenceForm/SequenceForm.tsx
index ea4d767b9c..5b30bf28fd 100644
--- a/apps/carbon/app/modules/settings/ui/Sequences/SequenceForm/SequenceForm.tsx
+++ b/apps/carbon/app/modules/settings/ui/Sequences/SequenceForm/SequenceForm.tsx
@@ -1,13 +1,15 @@
-import { Button, Heading, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ Heading,
+ HStack,
+ VStack,
+} from "@carbon/react";
import { useNavigate } from "@remix-run/react";
import { useState } from "react";
import { ValidatedForm } from "remix-validated-form";
@@ -44,18 +46,24 @@ const SequenceForm = ({ initialValues }: SequenceFormProps) => {
const isDisabled = !permissions.can("update", "settings");
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={sequenceValidator}
- method="post"
- action={path.to.tableSequence(initialValues.table)}
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{`${initialValues.name}`} Sequence</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={sequenceValidator}
+ method="post"
+ action={path.to.tableSequence(initialValues.table)}
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>{`${initialValues.name}`} Sequence</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<Hidden name="table" />
<VStack spacing={4}>
<Heading size="h2">{makePreview()}</Heading>
@@ -103,8 +111,8 @@ const SequenceForm = ({ initialValues }: SequenceFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/users/ui/EmployeeTypes/EmployeeTypeForm/EmployeeTypeForm.tsx b/apps/carbon/app/modules/users/ui/EmployeeTypes/EmployeeTypeForm/EmployeeTypeForm.tsx
index 7e90dd6973..6369a8b699 100644
--- a/apps/carbon/app/modules/users/ui/EmployeeTypes/EmployeeTypeForm/EmployeeTypeForm.tsx
+++ b/apps/carbon/app/modules/users/ui/EmployeeTypes/EmployeeTypeForm/EmployeeTypeForm.tsx
@@ -1,14 +1,15 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
- FormLabel,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
+import { FormLabel } from "@chakra-ui/react";
import { useNavigate } from "@remix-run/react";
import { useState } from "react";
import { ValidatedForm } from "remix-validated-form";
@@ -54,24 +55,30 @@ const EmployeeTypeForm = ({ initialValues }: EmployeeTypeFormProps) => {
: !userPermissions.can("create", "users");
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={employeeTypeValidator}
- method="post"
- action={
- isEditing
- ? path.to.employeeType(initialValues.id!)
- : path.to.newEmployeeType
- }
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={employeeTypeValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.employeeType(initialValues.id!)
+ : path.to.newEmployeeType
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
<DrawerHeader>
- {isEditing ? "Edit" : "New"} Employee Type
+ <DrawerTitle>
+ {isEditing ? "Edit" : "New"} Employee Type
+ </DrawerTitle>
</DrawerHeader>
- <DrawerBody pb={8}>
+ <DrawerBody>
<Hidden name="id" />
<VStack spacing={4}>
<Input name="name" label="Employee Type" />
@@ -104,8 +111,8 @@ const EmployeeTypeForm = ({ initialValues }: EmployeeTypeFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/users/ui/Employees/BulkEditPermissionsForm/BulkEditPermissionsForm.tsx b/apps/carbon/app/modules/users/ui/Employees/BulkEditPermissionsForm/BulkEditPermissionsForm.tsx
index 31945a7a5b..05c38a13f2 100644
--- a/apps/carbon/app/modules/users/ui/Employees/BulkEditPermissionsForm/BulkEditPermissionsForm.tsx
+++ b/apps/carbon/app/modules/users/ui/Employees/BulkEditPermissionsForm/BulkEditPermissionsForm.tsx
@@ -1,13 +1,16 @@
-import { Button, HStack, VStack, useMount } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
+ DrawerFooter,
DrawerHeader,
- DrawerOverlay,
- FormLabel,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+ useMount,
+} from "@carbon/react";
+import { FormLabel } from "@chakra-ui/react";
import { useFetcher } from "@remix-run/react";
import { useEffect, useState } from "react";
import { ValidatedForm } from "remix-validated-form";
@@ -66,19 +69,25 @@ const BulkEditPermissions = ({
}, [emptyPermissionsFetcher.data]);
return (
- <Drawer onClose={onClose} isOpen={isOpen} size="sm">
- <DrawerOverlay />
+ <Drawer
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ open={isOpen}
+ >
<DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>Bulk Edit Permissions</DrawerHeader>
- <DrawerBody pb={8}>
- <ValidatedForm
- validator={bulkPermissionsValidator}
- method="post"
- action={path.to.bulkEditPermissions}
- onSubmit={onClose}
- defaultValues={{ userIds }}
- >
+ <ValidatedForm
+ validator={bulkPermissionsValidator}
+ method="post"
+ action={path.to.bulkEditPermissions}
+ onSubmit={onClose}
+ defaultValues={{ userIds }}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>Bulk Edit Permissions</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<VStack spacing={4}>
<div className="border border-border p-4 w-full rounded-lg">
<Radios
@@ -116,15 +125,17 @@ const BulkEditPermissions = ({
</div>
))}
<Hidden name="data" value={JSON.stringify(permissions)} />
- <HStack className="my-4">
- <Submit>Save</Submit>
- <Button size="md" variant="solid" onClick={onClose}>
- Cancel
- </Button>
- </HStack>
</VStack>
- </ValidatedForm>
- </DrawerBody>
+ </DrawerBody>
+ <DrawerFooter>
+ <HStack>
+ <Submit>Save</Submit>
+ <Button size="md" variant="solid" onClick={onClose}>
+ Cancel
+ </Button>
+ </HStack>
+ </DrawerFooter>
+ </ValidatedForm>
</DrawerContent>
</Drawer>
);
diff --git a/apps/carbon/app/modules/users/ui/Employees/EmployeePermissionsForm/EmployeePermissionsForm.tsx b/apps/carbon/app/modules/users/ui/Employees/EmployeePermissionsForm/EmployeePermissionsForm.tsx
index 29fae5d1e5..dfd6bb11ba 100644
--- a/apps/carbon/app/modules/users/ui/Employees/EmployeePermissionsForm/EmployeePermissionsForm.tsx
+++ b/apps/carbon/app/modules/users/ui/Employees/EmployeePermissionsForm/EmployeePermissionsForm.tsx
@@ -1,14 +1,15 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
- FormLabel,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
+import { FormLabel } from "@chakra-ui/react";
import { useNavigate } from "@remix-run/react";
import { useState } from "react";
import { ValidatedForm } from "remix-validated-form";
@@ -51,18 +52,24 @@ const EmployeePermissionsForm = ({
};
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={employeeValidator}
- method="post"
- action={path.to.employeeAccount(initialValues.id)}
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{name}</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={employeeValidator}
+ method="post"
+ action={path.to.employeeAccount(initialValues.id)}
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>{name}</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<VStack spacing={4}>
<Select
name="employeeType"
@@ -94,8 +101,8 @@ const EmployeePermissionsForm = ({
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/modules/users/ui/Groups/GroupsForm/GroupsForm.tsx b/apps/carbon/app/modules/users/ui/Groups/GroupsForm/GroupsForm.tsx
index 76124ca455..a56470dfb5 100644
--- a/apps/carbon/app/modules/users/ui/Groups/GroupsForm/GroupsForm.tsx
+++ b/apps/carbon/app/modules/users/ui/Groups/GroupsForm/GroupsForm.tsx
@@ -1,13 +1,14 @@
-import { Button, HStack, VStack } from "@carbon/react";
import {
+ Button,
Drawer,
DrawerBody,
- DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
- DrawerOverlay,
-} from "@chakra-ui/react";
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
import { useNavigate } from "@remix-run/react";
import { ValidatedForm } from "remix-validated-form";
import { Hidden, Input, Submit, Users } from "~/components/Form";
@@ -32,18 +33,26 @@ const GroupForm = ({ initialValues }: GroupFormProps) => {
: !permissions.can("create", "users");
return (
- <Drawer onClose={onClose} isOpen={true} size="sm">
- <ValidatedForm
- validator={groupValidator}
- method="post"
- action={isEditing ? path.to.group(initialValues.id) : path.to.newGroup}
- defaultValues={initialValues}
- >
- <DrawerOverlay />
- <DrawerContent>
- <DrawerCloseButton />
- <DrawerHeader>{isEditing ? "Edit" : "New"} Group</DrawerHeader>
- <DrawerBody pb={8}>
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ validator={groupValidator}
+ method="post"
+ action={
+ isEditing ? path.to.group(initialValues.id) : path.to.newGroup
+ }
+ defaultValues={initialValues}
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>{isEditing ? "Edit" : "New"} Group</DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
<Hidden name="id" />
<VStack spacing={4}>
<Input name="name" label="Group Name" />
@@ -63,8 +72,8 @@ const GroupForm = ({ initialValues }: GroupFormProps) => {
</Button>
</HStack>
</DrawerFooter>
- </DrawerContent>
- </ValidatedForm>
+ </ValidatedForm>
+ </DrawerContent>
</Drawer>
);
};
diff --git a/apps/carbon/app/routes/x+/purchase-order+/$orderId.lines.new.tsx b/apps/carbon/app/routes/x+/purchase-order+/$orderId.lines.new.tsx
index c660ac9765..6a7baf6bca 100644
--- a/apps/carbon/app/routes/x+/purchase-order+/$orderId.lines.new.tsx
+++ b/apps/carbon/app/routes/x+/purchase-order+/$orderId.lines.new.tsx
@@ -59,8 +59,6 @@ export default function NewPurchaseOrderLineRoute() {
if (!orderId) throw new Error("Could not find purchase order id");
- console.log({ orderId });
-
const initialValues = {
purchaseOrderId: orderId,
purchaseOrderLineType: "Part" as PurchaseOrderLineType,
diff --git a/apps/carbon/app/routes/x+/resources+/shifts.$shiftId.tsx b/apps/carbon/app/routes/x+/resources+/shifts.$shiftId.tsx
index dbd043fb00..f702f3bfa1 100644
--- a/apps/carbon/app/routes/x+/resources+/shifts.$shiftId.tsx
+++ b/apps/carbon/app/routes/x+/resources+/shifts.$shiftId.tsx
@@ -3,8 +3,8 @@ import { json, redirect } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
import { validationError } from "remix-validated-form";
import {
- getShift,
ShiftForm,
+ getShift,
shiftValidator,
upsertShift,
} from "~/modules/resources";
@@ -55,13 +55,13 @@ export async function action({ request }: ActionFunctionArgs) {
if (createShift.error) {
return redirect(
path.to.shifts,
- await flash(request, error(createShift.error, "Failed to create shift."))
+ await flash(request, error(createShift.error, "Failed to create shift"))
);
}
return redirect(
path.to.shifts,
- await flash(request, success("Shift updated."))
+ await flash(request, success("Shift updated"))
);
}
diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.ts
index 68d14a2956..c328106802 100644
--- a/apps/carbon/app/utils/path.ts
+++ b/apps/carbon/app/utils/path.ts
@@ -106,7 +106,7 @@ export const path = {
customerShipping: (id: string) =>
generatePath(`${x}/customer/${id}/shipping`),
customerType: (id: string) =>
- generatePath(`${x}/sales/customer-types/delete/${id}`),
+ generatePath(`${x}/sales/customer-types/${id}`),
customerTypes: `${x}/sales/customer-types`,
deactivateUsers: `${x}/users/deactivate`,
deleteAbility: (id: string) =>
@@ -281,7 +281,7 @@ export const path = {
newWorkCellType: `${x}/resources/work-cells/new`,
part: (id: string) => generatePath(`${x}/part/${id}`),
partCosting: (id: string) => generatePath(`${x}/part/${id}/costing`),
- partGroup: (id: string) => generatePath(`${x}/parts/groups/delete/${id}`),
+ partGroup: (id: string) => generatePath(`${x}/parts/groups/${id}`),
partGroups: `${x}/parts/groups`,
partInventory: (id: string) => generatePath(`${x}/part/${id}/inventory`),
partInventoryLocation: (id: string, locationId: string) =>
@@ -379,7 +379,7 @@ export const path = {
generatePath(`${x}/supplier/${id}/shipping`),
supplierRoot: `${x}/supplier`,
supplierType: (id: string) =>
- generatePath(`${x}/purchasing/supplier-types/delete/${id}`),
+ generatePath(`${x}/purchasing/supplier-types/${id}`),
supplierTypes: `${x}/purchasing/supplier-types`,
tableSequence: (id: string) =>
generatePath(`${x}/settings/sequences/${id}`),
diff --git a/package-lock.json b/package-lock.json
index 32d0de02a3..ebe890ab81 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -29155,10 +29155,6 @@
"version": "0.0.0",
"license": "Apache-2.0",
"dependencies": {
- "@chakra-ui/react": "^2.8.0",
- "@emotion/react": "^11.11.1",
- "@emotion/styled": "^11.11.0",
- "@internationalized/date": "^3.3.0",
"@radix-ui/react-accessible-icon": "^1.0.3",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-alert-dialog": "^1.0.4",
@@ -29212,10 +29208,8 @@
"clsx": "^2.0.0",
"cmdk": "^0.2.0",
"dompurify": "3.0.5",
- "framer-motion": "^10.13.1",
"is-hotkey": "^0.2.0",
"react-colorful": "^5.6.1",
- "react-icons": "^4.12.0",
"react-select": "^5.5.1",
"react-window": "^1.8.9",
"tailwind-merge": "^2.2.0",
@@ -29239,6 +29233,15 @@
"react": "^18.2.0",
"tsup": "^6.2.3",
"typescript": "^5.2.2"
+ },
+ "peerDependencies": {
+ "@chakra-ui/react": "^2.8.0",
+ "@emotion/react": "^11.11.1",
+ "@emotion/styled": "^11.11.0",
+ "@internationalized/date": "^3.3.0",
+ "framer-motion": "^10.13.1",
+ "react": "^18.0.0 || ^17.0.0",
+ "react-icons": "^4.12.0"
}
},
"packages/react/node_modules/autoprefixer": {
diff --git a/packages/database/SCHEMA.md b/packages/database/SCHEMA.md
index daa5d6be32..c01294cdf3 100644
--- a/packages/database/SCHEMA.md
+++ b/packages/database/SCHEMA.md
@@ -1,13 +1,11 @@
# Carbon Database Schema
This file is generated by `scripts/generate-schema-md.ts` using the migrations in `packages/database/supabase/migrations`.
-
-
## `xid`
```sql
--- xid is a globally unique id generator functions.
+-- xid is a globally unique id generator functions.
-- they are 20 characters long and ordered
-- https://github.com/modfin/pg-xid
@@ -165,8 +163,6 @@ END;
$$;
```
-
-
## `realtime`
```sql
@@ -180,13 +176,11 @@ COMMIT;
```
-
-
## `claims`
```sql
CREATE OR REPLACE FUNCTION is_claims_admin() RETURNS "bool"
- LANGUAGE "plpgsql"
+ LANGUAGE "plpgsql"
AS $$
BEGIN
IF session_user = 'authenticator' THEN
@@ -198,14 +192,14 @@ CREATE OR REPLACE FUNCTION is_claims_admin() RETURNS "bool"
--------------------------------------------
IF extract(epoch from now()) > coalesce((current_setting('request.jwt.claims', true)::jsonb)->>'exp', '0')::numeric THEN
return false; -- jwt expired
- END IF;
+ END IF;
IF coalesce((current_setting('request.jwt.claims', true)::jsonb)->'app_metadata'->'users_update', 'false')::bool THEN
return true; -- user has user_update set to true
ELSE
return false; -- user does NOT have user_update set to true
END IF;
--------------------------------------------
- -- End of block
+ -- End of block
--------------------------------------------
ELSE -- not a user session, probably being called from a trigger or something
return true;
@@ -216,13 +210,13 @@ $$;
CREATE OR REPLACE FUNCTION get_my_claims() RETURNS "jsonb"
LANGUAGE "sql" STABLE
AS $$
- select
+ select
coalesce(nullif(current_setting('request.jwt.claims', true), '')::jsonb -> 'app_metadata', '{}'::jsonb)::jsonb
$$;
CREATE OR REPLACE FUNCTION get_my_claim(claim TEXT) RETURNS "jsonb"
LANGUAGE "sql" STABLE
AS $$
- select
+ select
coalesce(nullif(current_setting('request.jwt.claims', true), '')::jsonb -> 'app_metadata' -> claim, null)
$$;
@@ -233,7 +227,7 @@ CREATE OR REPLACE FUNCTION get_claims(uid uuid) RETURNS "jsonb"
BEGIN
select raw_app_meta_data from auth.users into retval where id = uid::uuid;
return retval;
-
+
END;
$$;
@@ -244,7 +238,7 @@ CREATE OR REPLACE FUNCTION get_claim(uid uuid, claim text) RETURNS "jsonb"
BEGIN
select coalesce(raw_app_meta_data->claim, null) from auth.users into retval where id = uid::uuid;
return retval;
-
+
END;
$$;
@@ -254,9 +248,9 @@ CREATE OR REPLACE FUNCTION set_claim(uid uuid, claim text, value jsonb) RETURNS
BEGIN
IF NOT is_claims_admin() THEN
RETURN 'error: access denied';
- ELSE
- update auth.users set raw_app_meta_data =
- raw_app_meta_data ||
+ ELSE
+ update auth.users set raw_app_meta_data =
+ raw_app_meta_data ||
json_build_object(claim, value)::jsonb where id = uid;
return 'OK';
END IF;
@@ -269,8 +263,8 @@ CREATE OR REPLACE FUNCTION delete_claim(uid uuid, claim text) RETURNS "text"
BEGIN
IF NOT is_claims_admin() THEN
RETURN 'error: access denied';
- ELSE
- update auth.users set raw_app_meta_data =
+ ELSE
+ update auth.users set raw_app_meta_data =
raw_app_meta_data - claim where id = uid;
return 'OK';
END IF;
@@ -279,8 +273,6 @@ $$;
NOTIFY pgrst, 'reload schema';
```
-
-
## `users`
```sql
@@ -311,8 +303,6 @@ CREATE POLICY "Anyone that's authenticated can view users" ON "user" FOR SELECT
```
-
-
## `employee-types`
```sql
@@ -338,8 +328,6 @@ CREATE POLICY "Only claims admin can view/modify permissions for employee types"
```
-
-
## `permissions`
```sql
@@ -379,8 +367,6 @@ CREATE POLICY "Only claims admin can view/modify permissions for employee types"
```
-
-
## `employee`
```sql
@@ -401,14 +387,12 @@ CREATE POLICY "Anyone that's authenticated can view employees" ON "employee" FOR
```
-
-
## `buckets`
```sql
INSERT INTO storage.buckets (id, name, public)
-VALUES
- ('public', 'public', true),
+VALUES
+ ('public', 'public', true),
('avatars', 'avatars', true),
('private', 'private', false);
@@ -467,8 +451,6 @@ ON storage.objects FOR INSERT WITH CHECK (
);
```
-
-
## `attributes`
```sql
@@ -500,55 +482,55 @@ CREATE TABLE "attributeDataType" (
"isNumeric" BOOLEAN NOT NULL DEFAULT FALSE,
"isText" BOOLEAN NOT NULL DEFAULT FALSE,
"isUser" BOOLEAN NOT NULL DEFAULT FALSE,
-
+
CONSTRAINT "userAttributeDataType_singleDataType"
CHECK (
(
- "isBoolean" = true AND
- "isDate" = false AND
- "isList" = false AND
- "isNumeric" = false AND
- "isText" = false AND
+ "isBoolean" = true AND
+ "isDate" = false AND
+ "isList" = false AND
+ "isNumeric" = false AND
+ "isText" = false AND
"isUser" = false
- )
+ )
OR (
- "isBoolean" = false AND
- "isDate" = true AND
- "isList" = false AND
- "isNumeric" = false AND
- "isText" = false AND
+ "isBoolean" = false AND
+ "isDate" = true AND
+ "isList" = false AND
+ "isNumeric" = false AND
+ "isText" = false AND
"isUser" = false
- )
+ )
OR (
- "isBoolean" = false AND
- "isDate" = false AND
- "isList" = true AND
- "isNumeric" = false AND
- "isText" = false AND
+ "isBoolean" = false AND
+ "isDate" = false AND
+ "isList" = true AND
+ "isNumeric" = false AND
+ "isText" = false AND
"isUser" = false
- )
+ )
OR (
- "isBoolean" = false AND
- "isDate" = false AND
- "isList" = false AND
- "isNumeric" = true AND
- "isText" = false AND
+ "isBoolean" = false AND
+ "isDate" = false AND
+ "isList" = false AND
+ "isNumeric" = true AND
+ "isText" = false AND
"isUser" = false
- )
+ )
OR (
- "isBoolean" = false AND
- "isDate" = false AND
- "isList" = false AND
- "isNumeric" = false AND
- "isText" = true AND
+ "isBoolean" = false AND
+ "isDate" = false AND
+ "isList" = false AND
+ "isNumeric" = false AND
+ "isText" = true AND
"isUser" = false
- )
+ )
OR (
- "isBoolean" = false AND
- "isDate" = false AND
- "isList" = false AND
- "isNumeric" = false AND
- "isText" = false AND
+ "isBoolean" = false AND
+ "isDate" = false AND
+ "isList" = false AND
+ "isNumeric" = false AND
+ "isText" = false AND
"isUser" = true
)
)
@@ -602,35 +584,35 @@ CREATE TABLE "userAttributeValue" (
"valueNumeric" IS NULL AND
"valueText" IS NULL AND
"valueUser" IS NULL
- )
+ )
OR (
"valueBoolean" IS NULL AND
"valueDate" IS NULL AND
"valueNumeric" IS NULL AND
"valueText" IS NOT NULL AND
"valueUser" IS NULL
- )
+ )
OR (
"valueBoolean" IS NULL AND
"valueDate" IS NOT NULL AND
"valueNumeric" IS NULL AND
"valueText" IS NULL AND
"valueUser" IS NULL
- )
+ )
OR (
"valueBoolean" IS NULL AND
"valueDate" IS NULL AND
"valueNumeric" IS NOT NULL AND
"valueText" IS NULL AND
"valueUser" IS NULL
- )
+ )
OR (
"valueBoolean" IS NULL AND
"valueDate" IS NULL AND
"valueNumeric" IS NULL AND
"valueText" IS NULL AND
"valueUser" IS NOT NULL
- )
+ )
),
CONSTRAINT "userAttributeValue_userAttributeId_fkey" FOREIGN KEY ("userAttributeId") REFERENCES "userAttribute"("id") ON DELETE CASCADE,
@@ -638,7 +620,7 @@ CREATE TABLE "userAttributeValue" (
CONSTRAINT "userAttributeValue_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE,
CONSTRAINT "userAttributeValue_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
CONSTRAINT "userAttributeValue_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id"),
- CONSTRAINT uq_userAttributeId_userId
+ CONSTRAINT uq_userAttributeId_userId
UNIQUE ( "userAttributeId", "userId")
);
@@ -647,7 +629,7 @@ CREATE POLICY "Claims admin can view/modify user attribute values" ON "userAttri
CREATE POLICY "Users can insert attributes for themselves" ON "userAttributeValue" FOR UPDATE WITH CHECK (auth.uid() = "userId"::uuid);
CREATE POLICY "Users can modify attributes for themselves" ON "userAttributeValue" FOR UPDATE WITH CHECK (auth.uid() = "userId"::uuid);
CREATE POLICY "Users can view their own attribtues" ON "userAttributeValue" FOR SELECT USING (auth.uid() = "userId"::uuid);
-CREATE POLICY "Users can view other users attributes if the category is public" ON "userAttributeValue" FOR SELECT
+CREATE POLICY "Users can view other users attributes if the category is public" ON "userAttributeValue" FOR SELECT
USING (
auth.role() = 'authenticated' AND
"userAttributeValue"."userAttributeId" IN (
@@ -658,7 +640,7 @@ CREATE POLICY "Users can view other users attributes if the category is public"
);
-- CREATE TABLE employee_personal_data (
--- "id" TEXT NOT NULL DEFAULT xid(),
+-- "id" TEXT NOT NULL DEFAULT xid(),
-- bank_account_number TEXT,
-- bank_routing_number TEXT,
-- drivers_license_number TEXT,
@@ -689,8 +671,6 @@ CREATE POLICY "Users can view other users attributes if the category is public"
-- ALTER TABLE "employee_personal_data" ENABLE ROW LEVEL SECURITY;
```
-
-
## `suppliers-and-customers`
```sql
@@ -920,8 +900,6 @@ CREATE INDEX "customerAccount_customerId_index" ON "customerAccount"("customerId
```
-
-
## `groups`
```sql
@@ -936,7 +914,7 @@ CREATE TABLE "group" (
"isSupplierOrgGroup" BOOLEAN NOT NULL DEFAULT false,
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
"updatedAt" TIMESTAMP WITH TIME ZONE,
-
+
CONSTRAINT "group_pkey" PRIMARY KEY ("id")
);
@@ -950,14 +928,14 @@ CREATE TABLE "membership" (
CONSTRAINT "membership_groupId_fkey" FOREIGN KEY ("groupId") REFERENCES "group"("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "membership_memberGroupId_fkey" FOREIGN KEY ("memberGroupId") REFERENCES "group"("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "membership_memberUserId_fkey" FOREIGN KEY ("memberUserId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE,
-
+
CONSTRAINT uq_membership
UNIQUE ( "groupId", "memberGroupId", "memberUserId" ),
-
+
CONSTRAINT membership_hasPersonOrGroup
CHECK (
- ("memberGroupId" IS NULL AND "memberUserId" IS NOT NULL)
- OR
+ ("memberGroupId" IS NULL AND "memberUserId" IS NOT NULL)
+ OR
("memberGroupId" IS NOT NULL AND "memberUserId" IS NULL)
)
);
@@ -1036,7 +1014,7 @@ CREATE TRIGGER create_employee_type_group
CREATE TRIGGER create_user_identity_group
AFTER INSERT on public.user
- FOR EACH ROW EXECUTE PROCEDURE public.create_user_identity_group();
+ FOR EACH ROW EXECUTE PROCEDURE public.create_user_identity_group();
CREATE TRIGGER add_employee_to_employee_type_group
AFTER INSERT on public.employee
@@ -1054,7 +1032,7 @@ CREATE TRIGGER update_employee_type_group
AFTER UPDATE on public."employeeType"
FOR EACH ROW EXECUTE PROCEDURE public.update_employee_type_group();
-CREATE OR REPLACE VIEW "groupMembers" AS
+CREATE OR REPLACE VIEW "groupMembers" AS
SELECT
gm.id,
g.name,
@@ -1068,17 +1046,17 @@ CREATE OR REPLACE VIEW "groupMembers" AS
gm."memberGroupId",
gm."memberUserId",
to_jsonb(u) as user
- FROM
- "membership" gm
+ FROM
+ "membership" gm
INNER JOIN "group" g ON g.id = gm."groupId"
LEFT OUTER JOIN (
SELECT * FROM "user" WHERE active = TRUE
) u ON u.id = gm."memberUserId";
-
-CREATE RECURSIVE VIEW groups_recursive
+
+CREATE RECURSIVE VIEW groups_recursive
(
- "groupId",
+ "groupId",
"name",
"parentId",
"isIdentityGroup",
@@ -1088,12 +1066,12 @@ CREATE RECURSIVE VIEW groups_recursive
"isSupplierOrgGroup",
"isSupplierTypeGroup",
"user"
-) AS
- SELECT
- "groupId",
- "name",
- NULL AS "parentId",
- "isIdentityGroup",
+) AS
+ SELECT
+ "groupId",
+ "name",
+ NULL AS "parentId",
+ "isIdentityGroup",
"isEmployeeTypeGroup",
"isCustomerOrgGroup",
"isCustomerTypeGroup",
@@ -1101,39 +1079,39 @@ CREATE RECURSIVE VIEW groups_recursive
"isSupplierTypeGroup",
"user"
FROM "groupMembers"
- UNION ALL
- SELECT
- g2."groupId",
- g2.name,
- g1."groupId" AS "parentId",
- g1."isIdentityGroup",
- g2."isEmployeeTypeGroup",
+ UNION ALL
+ SELECT
+ g2."groupId",
+ g2.name,
+ g1."groupId" AS "parentId",
+ g1."isIdentityGroup",
+ g2."isEmployeeTypeGroup",
g2."isCustomerOrgGroup",
g2."isCustomerTypeGroup",
g2."isSupplierOrgGroup",
g2."isSupplierTypeGroup",
g2."user"
- FROM "groupMembers" g1
+ FROM "groupMembers" g1
INNER JOIN "groupMembers" g2 ON g1."memberGroupId" = g2."groupId";
CREATE OR REPLACE VIEW "groups" AS
- SELECT
- "groupId" as "id",
+ SELECT
+ "groupId" as "id",
"isEmployeeTypeGroup",
"isCustomerOrgGroup",
"isCustomerTypeGroup",
"isSupplierOrgGroup",
"isSupplierTypeGroup",
- "name",
- "parentId",
+ "name",
+ "parentId",
coalesce(jsonb_agg("user") filter (where "user" is not null), '[]') as users
- FROM groups_recursive
+ FROM groups_recursive
WHERE "isIdentityGroup" = false
- GROUP BY
- "groupId",
- "name",
- "parentId",
- "isEmployeeTypeGroup",
+ GROUP BY
+ "groupId",
+ "name",
+ "parentId",
+ "isEmployeeTypeGroup",
"isCustomerOrgGroup",
"isCustomerTypeGroup",
"isSupplierOrgGroup",
@@ -1144,7 +1122,7 @@ CREATE OR REPLACE VIEW "groups" AS
CREATE OR REPLACE FUNCTION groups_query(
_name TEXT DEFAULT '',
_uid TEXT DEFAULT NULL
-)
+)
RETURNS TABLE (
"id" TEXT,
"name" TEXT,
@@ -1160,12 +1138,12 @@ AS $$
BEGIN
RETURN QUERY
WITH group_ids AS (
- SELECT g."id"
+ SELECT g."id"
FROM "group" g
WHERE g."isIdentityGroup" = false
- AND g."name" ILIKE '%' || _name || '%'
+ AND g."name" ILIKE '%' || _name || '%'
)
- SELECT
+ SELECT
g."id",
g."name",
g."parentId",
@@ -1185,7 +1163,7 @@ CREATE OR REPLACE FUNCTION groups_for_user(uid text) RETURNS TEXT[]
LANGUAGE "plpgsql" SECURITY DEFINER SET search_path = public
AS $$
DECLARE retval TEXT[];
- BEGIN
+ BEGIN
WITH RECURSIVE "groupsForUser" AS (
SELECT "groupId", "memberGroupId", "memberUserId" FROM "membership"
WHERE "memberUserId" = uid::text
@@ -1201,7 +1179,7 @@ CREATE OR REPLACE FUNCTION users_for_groups(groups text[]) RETURNS "jsonb"
LANGUAGE "plpgsql" SECURITY DEFINER SET search_path = public
AS $$
DECLARE retval jsonb;
- BEGIN
+ BEGIN
WITH RECURSIVE "usersForGroups" AS (
SELECT "groupId", "memberGroupId", "memberUserId" FROM "membership"
WHERE "groupId" = ANY(groups)
@@ -1398,8 +1376,6 @@ NOTIFY pgrst, 'reload schema';
```
-
-
## `search`
```sql
@@ -1421,7 +1397,7 @@ ADD COLUMN
fts tsvector GENERATED always as (to_tsvector('english', name || ' ' || description)) STORED;
CREATE INDEX index_search_uuid ON public.search (uuid);
-CREATE INDEX index_search_fts ON public.search USING GIN (fts);
+CREATE INDEX index_search_fts ON public.search USING GIN (fts);
CREATE FUNCTION public.create_employee_search_result()
RETURNS TRIGGER AS $$
@@ -1525,8 +1501,8 @@ CREATE POLICY "Employees with sales_view can search for customers and sales orde
-- CREATE POLICY "Customers with sales_view can search for their own sales orders" ON "search"
-- FOR SELECT
-- USING (
--- coalesce(get_my_claim('sales_view')::boolean, false) = true
--- AND entity = 'Sales Order'
+-- coalesce(get_my_claim('sales_view')::boolean, false) = true
+-- AND entity = 'Sales Order'
-- AND (get_my_claim('role'::text)) = '"customer"'::jsonb
-- AND uuid IN (
-- SELECT id FROM "salesOrder" WHERE "customerId" IN (
@@ -1568,8 +1544,6 @@ CREATE POLICY "Employees with jobs_view can search for jobs" ON "search"
-- TODO: customers should be able to search for their jobs
```
-
-
## `abac`
```sql
@@ -1580,7 +1554,7 @@ ALTER TABLE "contact" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with purchasing_view can view contacts that are suppliers" ON "contact"
FOR SELECT
USING (
- coalesce(get_my_claim('purchasing_view')::boolean, false) = true
+ coalesce(get_my_claim('purchasing_view')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
AND id IN (
SELECT "contactId" FROM "supplierContact"
@@ -1590,7 +1564,7 @@ CREATE POLICY "Employees with purchasing_view can view contacts that are supplie
CREATE POLICY "Employees with sales_view can view contacts that are customer" ON "contact"
FOR SELECT
USING (
- coalesce(get_my_claim('sales_view')::boolean, false) = true
+ coalesce(get_my_claim('sales_view')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
AND id IN (
SELECT "contactId" FROM "customerContact"
@@ -1600,8 +1574,8 @@ CREATE POLICY "Employees with sales_view can view contacts that are customer" ON
CREATE POLICY "Suppliers with purchasing_view can view contacts from their organization" ON "contact"
FOR SELECT
USING (
- coalesce(get_my_claim('purchasing_view')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
+ coalesce(get_my_claim('purchasing_view')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND (
id IN (
SELECT "contactId" FROM "supplierContact" WHERE "supplierId" IN (
@@ -1614,8 +1588,8 @@ CREATE POLICY "Suppliers with purchasing_view can view contacts from their organ
CREATE POLICY "Customers with sales_view can view contacts from their organization" ON "contact"
FOR SELECT
USING (
- coalesce(get_my_claim('sales_view')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"customer"'::jsonb
+ coalesce(get_my_claim('sales_view')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"customer"'::jsonb
AND (
id IN (
SELECT "contactId" FROM "customerContact" WHERE "customerId" IN (
@@ -1638,8 +1612,8 @@ CREATE POLICY "Many employees can create contact" ON "contact"
CREATE POLICY "Suppliers with purchasing_update can create contacts from their organization" ON "contact"
FOR INSERT
WITH CHECK (
- coalesce(get_my_claim('purchasing_update')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
+ coalesce(get_my_claim('purchasing_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND (
id IN (
SELECT "contactId" FROM "supplierContact" WHERE "supplierId" IN (
@@ -1652,8 +1626,8 @@ CREATE POLICY "Suppliers with purchasing_update can create contacts from their o
CREATE POLICY "Customers with sales_update can create contacts from their organization" ON "contact"
FOR INSERT
WITH CHECK (
- coalesce(get_my_claim('sales_update')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"customer"'::jsonb
+ coalesce(get_my_claim('sales_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"customer"'::jsonb
AND (
id IN (
SELECT "contactId" FROM "customerContact" WHERE "customerId" IN (
@@ -1666,7 +1640,7 @@ CREATE POLICY "Customers with sales_update can create contacts from their organi
CREATE POLICY "Employees with purchasing_update can update supplier contacts" ON "contact"
FOR UPDATE
USING (
- coalesce(get_my_claim('purchasing_update')::boolean, false) = true
+ coalesce(get_my_claim('purchasing_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
AND id IN (
SELECT "contactId" FROM "supplierContact"
@@ -1676,8 +1650,8 @@ CREATE POLICY "Employees with purchasing_update can update supplier contacts" ON
CREATE POLICY "Suppliers with purchasing_update can update contacts from their organization" ON "contact"
FOR UPDATE
USING (
- coalesce(get_my_claim('purchasing_update')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
+ coalesce(get_my_claim('purchasing_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND (
id IN (
SELECT "contactId" FROM "supplierContact" WHERE "supplierId" IN (
@@ -1690,7 +1664,7 @@ CREATE POLICY "Suppliers with purchasing_update can update contacts from their o
CREATE POLICY "Employees with sales_update can update customer contacts" ON "contact"
FOR UPDATE
USING (
- coalesce(get_my_claim('purchasing_update')::boolean, false) = true
+ coalesce(get_my_claim('purchasing_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
AND id IN (
SELECT "contactId" FROM "customerContact"
@@ -1700,8 +1674,8 @@ CREATE POLICY "Employees with sales_update can update customer contacts" ON "con
CREATE POLICY "Customers with sales_update can update contacts from their organization" ON "contact"
FOR UPDATE
USING (
- coalesce(get_my_claim('sales_update')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"customer"'::jsonb
+ coalesce(get_my_claim('sales_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"customer"'::jsonb
AND (
id IN (
SELECT "contactId" FROM "customerContact" WHERE "customerId" IN (
@@ -1714,7 +1688,7 @@ CREATE POLICY "Customers with sales_update can update contacts from their organi
CREATE POLICY "Employees with purchasing_delete can delete supplier contacts" ON "contact"
FOR DELETE
USING (
- coalesce(get_my_claim('purchasing_delete')::boolean, false) = true
+ coalesce(get_my_claim('purchasing_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
AND id IN (
SELECT "contactId" FROM "supplierContact"
@@ -1724,8 +1698,8 @@ CREATE POLICY "Employees with purchasing_delete can delete supplier contacts" ON
CREATE POLICY "Suppliers with purchasing_delete can delete contacts from their organization" ON "contact"
FOR DELETE
USING (
- coalesce(get_my_claim('purchasing_delete')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
+ coalesce(get_my_claim('purchasing_delete')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND (
id IN (
SELECT "contactId" FROM "supplierContact" WHERE "supplierId" IN (
@@ -1738,7 +1712,7 @@ CREATE POLICY "Suppliers with purchasing_delete can delete contacts from their o
CREATE POLICY "Employees with sales_delete can delete customer contacts" ON "contact"
FOR DELETE
USING (
- coalesce(get_my_claim('sales_delete')::boolean, false) = true
+ coalesce(get_my_claim('sales_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
AND id IN (
SELECT "contactId" FROM "customerContact"
@@ -1748,8 +1722,8 @@ CREATE POLICY "Employees with sales_delete can delete customer contacts" ON "con
CREATE POLICY "Customers with sales_delete can delete contacts from their organization" ON "contact"
FOR DELETE
USING (
- coalesce(get_my_claim('sales_delete')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"customer"'::jsonb
+ coalesce(get_my_claim('sales_delete')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"customer"'::jsonb
AND (
id IN (
SELECT "contactId" FROM "customerContact" WHERE "customerId" IN (
@@ -1790,8 +1764,8 @@ CREATE POLICY "Employees with sales_view can view customer" ON "customer"
CREATE POLICY "Customers with sales_view can their own organization" ON "customer"
FOR SELECT
USING (
- coalesce(get_my_claim('sales_view')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"customer"'::jsonb
+ coalesce(get_my_claim('sales_view')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"customer"'::jsonb
AND id IN (
SELECT "customerId" FROM "customerAccount" WHERE id::uuid = auth.uid()
)
@@ -1808,8 +1782,8 @@ CREATE POLICY "Employees with sales_update can update customers" ON "customer"
CREATE POLICY "Customers with sales_update can their own organization" ON "customer"
FOR UPDATE
USING (
- coalesce(get_my_claim('sales_update')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"customer"'::jsonb
+ coalesce(get_my_claim('sales_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"customer"'::jsonb
AND id IN (
SELECT "customerId" FROM "customerAccount" WHERE id::uuid = auth.uid()
)
@@ -1830,8 +1804,8 @@ CREATE POLICY "Employees with sales_view can view customer contact" ON "customer
CREATE POLICY "Customers with sales_view can their own customer contacts" ON "customerContact"
FOR SELECT
USING (
- coalesce(get_my_claim('sales_view')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"customer"'::jsonb
+ coalesce(get_my_claim('sales_view')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"customer"'::jsonb
AND "customerId" IN (
SELECT "customerId" FROM "customerAccount" WHERE id::uuid = auth.uid()
)
@@ -1843,8 +1817,8 @@ CREATE POLICY "Employees with sales_create can create customer contacts" ON "cus
CREATE POLICY "Customers with sales_create can create customer contacts" ON "customerContact"
FOR INSERT
- WITH CHECK (coalesce(get_my_claim('sales_create')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"customer"'::jsonb
+ WITH CHECK (coalesce(get_my_claim('sales_create')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"customer"'::jsonb
AND "customerId" IN (
SELECT "customerId" FROM "customerAccount" WHERE id::uuid = auth.uid()
)
@@ -1856,8 +1830,8 @@ CREATE POLICY "Employees with sales_update can update customer contacts" ON "cus
CREATE POLICY "Customers with sales_update can update their customer contacts" ON "customerContact"
FOR UPDATE
- USING (coalesce(get_my_claim('sales_update')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"customer"'::jsonb
+ USING (coalesce(get_my_claim('sales_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"customer"'::jsonb
AND "customerId" IN (
SELECT "customerId" FROM "customerAccount" WHERE id::uuid = auth.uid()
)
@@ -1898,8 +1872,8 @@ CREATE POLICY "Employees with purchasing_view can view supplier" ON "supplier"
CREATE POLICY "Suppliers with purchasing_view can their own organization" ON "supplier"
FOR SELECT
USING (
- coalesce(get_my_claim('purchasing_view')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
+ coalesce(get_my_claim('purchasing_view')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND id IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
)
@@ -1916,8 +1890,8 @@ CREATE POLICY "Employees with purchasing_update can update suppliers" ON "suppli
CREATE POLICY "Suppliers with purchasing_update can their own organization" ON "supplier"
FOR UPDATE
USING (
- coalesce(get_my_claim('purchasing_update')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
+ coalesce(get_my_claim('purchasing_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND id IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
)
@@ -1938,8 +1912,8 @@ CREATE POLICY "Employees with purchasing_view can view supplier contact" ON "sup
CREATE POLICY "Suppliers with purchasing_view can their own supplier contacts" ON "supplierContact"
FOR SELECT
USING (
- coalesce(get_my_claim('purchasing_view')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
+ coalesce(get_my_claim('purchasing_view')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
)
@@ -1951,8 +1925,8 @@ CREATE POLICY "Employees with purchasing_create can create supplier contacts" ON
CREATE POLICY "Suppliers with purchasing_create can create supplier contacts" ON "supplierContact"
FOR INSERT
- WITH CHECK (coalesce(get_my_claim('purchasing_create')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
+ WITH CHECK (coalesce(get_my_claim('purchasing_create')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
)
@@ -1964,8 +1938,8 @@ CREATE POLICY "Employees with purchasing_update can update supplier contacts" ON
CREATE POLICY "Suppliers with purchasing_update can update their supplier contacts" ON "supplierContact"
FOR UPDATE
- USING (coalesce(get_my_claim('purchasing_update')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
+ USING (coalesce(get_my_claim('purchasing_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
)
@@ -1978,8 +1952,6 @@ CREATE POLICY "Employees with purchasing_delete can delete supplier contacts" ON
```
-
-
## `notes`
```sql
@@ -2009,7 +1981,7 @@ CREATE POLICY "Employees can view notes" ON "note"
CREATE POLICY "Employees can insert notes" ON "note"
FOR INSERT
- WITH CHECK (
+ WITH CHECK (
(get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -2029,8 +2001,6 @@ CREATE POLICY "Employees can delete their own notes" ON "note"
```
-
-
## `abilities`
```sql
@@ -2055,28 +2025,28 @@ ALTER TABLE "ability" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with resources_view can view abilities" ON "ability"
FOR SELECT
USING (
- coalesce(get_my_claim('resources_view')::boolean, false) = true
+ coalesce(get_my_claim('resources_view')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_create can insert abilities" ON "ability"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('resources_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('resources_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_update can update abilities" ON "ability"
FOR UPDATE
USING (
- coalesce(get_my_claim('resources_update')::boolean, false) = true
+ coalesce(get_my_claim('resources_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_delete can delete abilities" ON "ability"
FOR DELETE
USING (
- coalesce(get_my_claim('resources_delete')::boolean, false) = true
+ coalesce(get_my_claim('resources_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -2101,35 +2071,33 @@ ALTER TABLE "employeeAbility" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with resources_view can view employeeAbilities" ON "employeeAbility"
FOR SELECT
USING (
- coalesce(get_my_claim('resources_view')::boolean, false) = true
+ coalesce(get_my_claim('resources_view')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_create can insert employeeAbilities" ON "employeeAbility"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('resources_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('resources_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_update can update employeeAbilities" ON "employeeAbility"
FOR UPDATE
USING (
- coalesce(get_my_claim('resources_update')::boolean, false) = true
+ coalesce(get_my_claim('resources_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_delete can delete employeeAbilities" ON "employeeAbility"
FOR DELETE
USING (
- coalesce(get_my_claim('resources_delete')::boolean, false) = true
+ coalesce(get_my_claim('resources_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
```
-
-
## `shifts`
```sql
@@ -2158,28 +2126,28 @@ ALTER TABLE "location" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees can view locations" ON "location"
FOR SELECT
USING (
- auth.role() = 'authenticated'
+ auth.role() = 'authenticated'
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_create can insert locations" ON "location"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('resources_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('resources_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_update can update locations" ON "location"
FOR UPDATE
USING (
- coalesce(get_my_claim('resources_update')::boolean, false) = true
+ coalesce(get_my_claim('resources_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_delete can delete locations" ON "location"
FOR DELETE
USING (
- coalesce(get_my_claim('resources_delete')::boolean, false) = true
+ coalesce(get_my_claim('resources_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -2198,7 +2166,7 @@ CREATE TABLE "shift" (
"friday" BOOLEAN NOT NULL DEFAULT false,
"saturday" BOOLEAN NOT NULL DEFAULT false,
"active" BOOLEAN NOT NULL DEFAULT true,
-
+
CONSTRAINT "shifts_pkey" PRIMARY KEY ("id"),
CONSTRAINT "shifts_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location"("id") ON DELETE CASCADE ON UPDATE CASCADE
);
@@ -2208,28 +2176,28 @@ ALTER TABLE "shift" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees can view shifts" ON "shift"
FOR SELECT
USING (
- auth.role() = 'authenticated'
+ auth.role() = 'authenticated'
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_create can insert shifts" ON "shift"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('resources_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('resources_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_update can update shifts" ON "shift"
FOR UPDATE
USING (
- coalesce(get_my_claim('resources_update')::boolean, false) = true
+ coalesce(get_my_claim('resources_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_delete can delete shifts" ON "shift"
FOR DELETE
USING (
- coalesce(get_my_claim('resources_delete')::boolean, false) = true
+ coalesce(get_my_claim('resources_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -2251,28 +2219,28 @@ ALTER TABLE "employeeShift" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees can view employee shifts" ON "employeeShift"
FOR SELECT
USING (
- auth.role() = 'authenticated'
+ auth.role() = 'authenticated'
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_create can insert employee shifts" ON "employeeShift"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('resources_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('resources_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_update can update employee shifts" ON "employeeShift"
FOR UPDATE
USING (
- coalesce(get_my_claim('resources_update')::boolean, false) = true
+ coalesce(get_my_claim('resources_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_delete can delete employee shifts" ON "employeeShift"
FOR DELETE
USING (
- coalesce(get_my_claim('resources_delete')::boolean, false) = true
+ coalesce(get_my_claim('resources_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -2295,41 +2263,39 @@ CREATE TABLE "employeeJob" (
CREATE POLICY "Employees can view employee jobs" ON "employeeJob"
FOR SELECT
USING (
- auth.role() = 'authenticated'
+ auth.role() = 'authenticated'
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_create can insert employee jobs" ON "employeeJob"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('resources_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('resources_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_update can update employee jobs" ON "employeeJob"
FOR UPDATE
USING (
- coalesce(get_my_claim('resources_update')::boolean, false) = true
+ coalesce(get_my_claim('resources_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_delete can delete employee jobs" ON "employeeJob"
FOR DELETE
USING (
- coalesce(get_my_claim('resources_delete')::boolean, false) = true
+ coalesce(get_my_claim('resources_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
```
-
-
## `equipment`
```sql
CREATE TYPE factor AS ENUM (
'Hours/Piece',
- 'Hours/100 Pieces',
+ 'Hours/100 Pieces',
'Hours/1000 Pieces',
'Minutes/Piece',
'Minutes/100 Pieces',
@@ -2361,28 +2327,28 @@ ALTER TABLE "department" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees can view departments" ON "department"
FOR SELECT
USING (
- auth.role() = 'authenticated'
+ auth.role() = 'authenticated'
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_create can insert departments" ON "department"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('resources_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('resources_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_update can update departments" ON "department"
FOR UPDATE
USING (
- coalesce(get_my_claim('resources_update')::boolean, false) = true
+ coalesce(get_my_claim('resources_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_delete can delete departments" ON "department"
FOR DELETE
USING (
- coalesce(get_my_claim('resources_delete')::boolean, false) = true
+ coalesce(get_my_claim('resources_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -2410,28 +2376,28 @@ ALTER TABLE "workCellType" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees can view work cell types" ON "workCellType"
FOR SELECT
USING (
- auth.role() = 'authenticated'
+ auth.role() = 'authenticated'
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_create can insert work cell types" ON "workCellType"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('resources_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('resources_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_update can update work cell types" ON "workCellType"
FOR UPDATE
USING (
- coalesce(get_my_claim('resources_update')::boolean, false) = true
+ coalesce(get_my_claim('resources_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_delete can delete work cell types" ON "workCellType"
FOR DELETE
USING (
- coalesce(get_my_claim('resources_delete')::boolean, false) = true
+ coalesce(get_my_claim('resources_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -2462,28 +2428,28 @@ ALTER TABLE "workCell" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees can view work cells" ON "workCell"
FOR SELECT
USING (
- auth.role() = 'authenticated'
+ auth.role() = 'authenticated'
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_create can insert work cells" ON "workCell"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('resources_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('resources_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_update can update work cells" ON "workCell"
FOR UPDATE
USING (
- coalesce(get_my_claim('resources_update')::boolean, false) = true
+ coalesce(get_my_claim('resources_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_delete can delete work cells" ON "workCell"
FOR DELETE
USING (
- coalesce(get_my_claim('resources_delete')::boolean, false) = true
+ coalesce(get_my_claim('resources_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -2510,28 +2476,28 @@ ALTER TABLE "crew" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees can view crews" ON "crew"
FOR SELECT
USING (
- auth.role() = 'authenticated'
+ auth.role() = 'authenticated'
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_create can insert crews" ON "crew"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('resources_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('resources_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_update can update crews" ON "crew"
FOR UPDATE
USING (
- coalesce(get_my_claim('resources_update')::boolean, false) = true
+ coalesce(get_my_claim('resources_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_delete can delete crews" ON "crew"
FOR DELETE
USING (
- coalesce(get_my_claim('resources_delete')::boolean, false) = true
+ coalesce(get_my_claim('resources_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -2551,29 +2517,29 @@ ALTER TABLE "crewAbility" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with resources_view can view crew abilities" ON "crewAbility"
FOR SELECT
USING (
- auth.role() = 'authenticated'
+ auth.role() = 'authenticated'
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
AND (get_my_claim('resources_view')::boolean) = true
);
CREATE POLICY "Employees with resources_create can insert crew abilities" ON "crewAbility"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('resources_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('resources_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_update can update crew abilities" ON "crewAbility"
FOR UPDATE
USING (
- coalesce(get_my_claim('resources_update')::boolean, false) = true
+ coalesce(get_my_claim('resources_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_delete can delete crew abilities" ON "crewAbility"
FOR DELETE
USING (
- coalesce(get_my_claim('resources_delete')::boolean, false) = true
+ coalesce(get_my_claim('resources_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -2601,28 +2567,28 @@ ALTER TABLE "equipmentType" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees can view equipment types" ON "equipmentType"
FOR SELECT
USING (
- auth.role() = 'authenticated'
+ auth.role() = 'authenticated'
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_create can insert equipment types" ON "equipmentType"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('resources_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('resources_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_update can update equipment types" ON "equipmentType"
FOR UPDATE
USING (
- coalesce(get_my_claim('resources_update')::boolean, false) = true
+ coalesce(get_my_claim('resources_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_delete can delete equipment types" ON "equipmentType"
FOR DELETE
USING (
- coalesce(get_my_claim('resources_delete')::boolean, false) = true
+ coalesce(get_my_claim('resources_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -2655,28 +2621,28 @@ ALTER TABLE "equipment" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees can view equipment" ON "equipment"
FOR SELECT
USING (
- auth.role() = 'authenticated'
+ auth.role() = 'authenticated'
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_create can insert equipment" ON "equipment"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('resources_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('resources_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_update can update equipment" ON "equipment"
FOR UPDATE
USING (
- coalesce(get_my_claim('resources_update')::boolean, false) = true
+ coalesce(get_my_claim('resources_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_delete can delete equipment" ON "equipment"
FOR DELETE
USING (
- coalesce(get_my_claim('resources_delete')::boolean, false) = true
+ coalesce(get_my_claim('resources_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -2685,7 +2651,7 @@ RETURNS TRIGGER AS $$
DECLARE
equipment_type TEXT;
BEGIN
- equipment_type := (SELECT u."name" FROM public."equipmentType" et WHERE et.id = new."equipmentTypeId");
+ equipment_type := (SELECT et."name" FROM public."equipmentType" et WHERE et.id = new."equipmentTypeId");
INSERT INTO public.search(name, description, entity, uuid, link)
VALUES (new.name, COALESCE(new.description, '') || ' ' || equipment_type, 'Resource', new.id, '/x/resources/equipment/list/' || new."equipmentTypeId" || '/' || new.id);
RETURN new;
@@ -2702,7 +2668,7 @@ DECLARE
equipment_type TEXT;
BEGIN
IF (old.name <> new.name OR old.description <> new.description OR old."equipmentTypeId" <> new."equipmentTypeId") THEN
- equipment_type := (SELECT u."name" FROM public."equipmentType" et WHERE et.id = new."equipmentTypeId");
+ equipment_type := (SELECT et."name" FROM public."equipmentType" et WHERE et.id = new."equipmentTypeId");
UPDATE public.search SET name = new.name, description = COALESCE(new.description, '') || ' ' || equipment_type
WHERE entity = 'Resource' AND uuid = new.id;
END IF;
@@ -2718,8 +2684,6 @@ CREATE TRIGGER update_equipment_search_result
```
-
-
## `holidays`
```sql
@@ -2746,34 +2710,32 @@ ALTER TABLE "holiday" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees can view holidays" ON "holiday"
FOR SELECT
USING (
- auth.role() = 'authenticated'
+ auth.role() = 'authenticated'
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_create can insert holidays" ON "holiday"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('resources_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('resources_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_update can update holidays" ON "holiday"
FOR UPDATE
USING (
- coalesce(get_my_claim('resources_update')::boolean, false) = true
+ coalesce(get_my_claim('resources_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_delete can delete holidays" ON "holiday"
FOR DELETE
USING (
- coalesce(get_my_claim('resources_delete')::boolean, false) = true
+ coalesce(get_my_claim('resources_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
```
-
-
## `partners`
```sql
@@ -2805,21 +2767,21 @@ CREATE TABLE "partnerAbility" (
);
CREATE OR REPLACE VIEW "partners" AS
- SELECT
- p.id AS "supplierLocationId",
- p."active",
- p."hoursPerWeek",
- s.id AS "supplierId",
- s.name AS "supplierName",
+ SELECT
+ p.id AS "supplierLocationId",
+ p."active",
+ p."hoursPerWeek",
+ s.id AS "supplierId",
+ s.name AS "supplierName",
a.city,
a.state,
array_agg(pa."abilityId") AS "abilityIds"
- FROM "partner" p
- INNER JOIN "supplierLocation" sl
+ FROM "partner" p
+ INNER JOIN "supplierLocation" sl
ON sl.id = p.id
INNER JOIN "supplier" s
ON s.id = sl."supplierId"
- INNER JOIN "address" a
+ INNER JOIN "address" a
ON a.id = sl."addressId"
INNER JOIN "partnerAbility" pa
ON pa."partnerId" = p.id
@@ -2828,8 +2790,6 @@ CREATE OR REPLACE VIEW "partners" AS
;
```
-
-
## `contractors`
```sql
@@ -2853,28 +2813,28 @@ ALTER TABLE "contractor" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with resources_view can view contractors" ON "contractor"
FOR SELECT
USING (
- coalesce(get_my_claim('resources_view')::boolean, false) = true
+ coalesce(get_my_claim('resources_view')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_create can insert contractors" ON "contractor"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('resources_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('resources_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_update can update contractors" ON "contractor"
FOR UPDATE
USING (
- coalesce(get_my_claim('resources_update')::boolean, false) = true
+ coalesce(get_my_claim('resources_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_delete can delete contractors" ON "contractor"
FOR DELETE
USING (
- coalesce(get_my_claim('resources_delete')::boolean, false) = true
+ coalesce(get_my_claim('resources_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -2896,49 +2856,49 @@ ALTER TABLE "contractorAbility" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with resources_view can view contractorAbilities" ON "contractorAbility"
FOR SELECT
USING (
- coalesce(get_my_claim('resources_view')::boolean, false) = true
+ coalesce(get_my_claim('resources_view')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_create can insert contractorAbilities" ON "contractorAbility"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('resources_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('resources_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_update can update contractorAbilities" ON "contractorAbility"
FOR UPDATE
USING (
- coalesce(get_my_claim('resources_update')::boolean, false) = true
+ coalesce(get_my_claim('resources_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with resources_delete can delete contractorAbilities" ON "contractorAbility"
FOR DELETE
USING (
- coalesce(get_my_claim('resources_delete')::boolean, false) = true
+ coalesce(get_my_claim('resources_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE OR REPLACE VIEW "contractors" AS
- SELECT
- p.id AS "supplierContactId",
- p."active",
- p."hoursPerWeek",
- s.id AS "supplierId",
- s.name AS "supplierName",
+ SELECT
+ p.id AS "supplierContactId",
+ p."active",
+ p."hoursPerWeek",
+ s.id AS "supplierId",
+ s.name AS "supplierName",
c."firstName",
c."lastName",
c."email",
array_agg(pa."abilityId") AS "abilityIds"
- FROM "contractor" p
- INNER JOIN "supplierContact" sc
+ FROM "contractor" p
+ INNER JOIN "supplierContact" sc
ON sc.id = p.id
INNER JOIN "supplier" s
ON s.id = sc."supplierId"
- INNER JOIN "contact" c
+ INNER JOIN "contact" c
ON c.id = sc."contactId"
LEFT JOIN "contractorAbility" pa
ON pa."contractorId" = p.id
@@ -2947,8 +2907,6 @@ CREATE OR REPLACE VIEW "contractors" AS
;
```
-
-
## `accounts`
```sql
@@ -2979,27 +2937,27 @@ ALTER TABLE "currency" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Authenticated users can view currencies" ON "currency"
FOR SELECT
USING (
- auth.role() = 'authenticated'
+ auth.role() = 'authenticated'
);
CREATE POLICY "Employees with accounting_create can insert currencies" ON "currency"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('accounting_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('accounting_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with accounting_update can update currencies" ON "currency"
FOR UPDATE
USING (
- coalesce(get_my_claim('accounting_update')::boolean, false) = true
+ coalesce(get_my_claim('accounting_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with accounting_delete can delete currencies" ON "currency"
FOR DELETE
USING (
- coalesce(get_my_claim('accounting_delete')::boolean, false) = true
+ coalesce(get_my_claim('accounting_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -3066,29 +3024,29 @@ ALTER TABLE "accountCategory" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with accounting_view can view account categories" ON "accountCategory"
FOR SELECT
USING (
- coalesce(get_my_claim('accounting_view')::boolean, false) = true
+ coalesce(get_my_claim('accounting_view')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
-
+
CREATE POLICY "Employees with accounting_create can insert account categories" ON "accountCategory"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('accounting_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('accounting_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with accounting_update can update account categories" ON "accountCategory"
FOR UPDATE
USING (
- coalesce(get_my_claim('accounting_update')::boolean, false) = true
+ coalesce(get_my_claim('accounting_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with accounting_delete can delete account categories" ON "accountCategory"
FOR DELETE
USING (
- coalesce(get_my_claim('accounting_delete')::boolean, false) = true
+ coalesce(get_my_claim('accounting_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -3122,29 +3080,29 @@ ALTER TABLE "accountSubcategory" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with accounting_view can view account subcategories" ON "accountSubcategory"
FOR SELECT
USING (
- coalesce(get_my_claim('accounting_view')::boolean, false) = true
+ coalesce(get_my_claim('accounting_view')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
-
+
CREATE POLICY "Employees with accounting_create can insert account subcategories" ON "accountSubcategory"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('accounting_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('accounting_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with accounting_update can update account subcategories" ON "accountSubcategory"
FOR UPDATE
USING (
- coalesce(get_my_claim('accounting_update')::boolean, false) = true
+ coalesce(get_my_claim('accounting_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with accounting_delete can delete account subcategories" ON "accountSubcategory"
FOR DELETE
USING (
- coalesce(get_my_claim('accounting_delete')::boolean, false) = true
+ coalesce(get_my_claim('accounting_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -3194,26 +3152,26 @@ CREATE POLICY "Certain employees can view accounts" ON "account"
)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
-
+
CREATE POLICY "Employees with accounting_create can insert accounts" ON "account"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('accounting_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('accounting_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with accounting_update can update accounts" ON "account"
FOR UPDATE
USING (
- coalesce(get_my_claim('accounting_update')::boolean, false) = true
+ coalesce(get_my_claim('accounting_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with accounting_delete can delete accounts" ON "account"
FOR DELETE
USING (
- coalesce(get_my_claim('accounting_delete')::boolean, false) = true
+ coalesce(get_my_claim('accounting_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -3232,7 +3190,7 @@ CREATE OR REPLACE VIEW "accountCategories" AS
;
CREATE OR REPLACE VIEW "accounts" AS
- SELECT
+ SELECT
"id",
"number",
"name",
@@ -3254,8 +3212,6 @@ CREATE OR REPLACE VIEW "accounts" AS
;
```
-
-
## `parts`
```sql
@@ -3280,29 +3236,29 @@ ALTER TABLE "partGroup" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with parts can view part groups" ON "partGroup"
FOR SELECT
USING (
- coalesce(get_my_claim('parts_view')::boolean, false) = true
+ coalesce(get_my_claim('parts_view')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
-
+
CREATE POLICY "Employees with parts_create can insert part groups" ON "partGroup"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('parts_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('parts_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with parts_update can update part groups" ON "partGroup"
FOR UPDATE
USING (
- coalesce(get_my_claim('parts_update')::boolean, false) = true
+ coalesce(get_my_claim('parts_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with parts_delete can delete part groups" ON "partGroup"
FOR DELETE
USING (
- coalesce(get_my_claim('parts_delete')::boolean, false) = true
+ coalesce(get_my_claim('parts_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -3363,26 +3319,26 @@ CREATE POLICY "Authenticated users can view units of measure" ON "unitOfMeasure"
USING (
auth.role() = 'authenticated'
);
-
+
CREATE POLICY "Employees with parts_create can insert units of measure" ON "unitOfMeasure"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('parts_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('parts_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with parts_update can update units of measure" ON "unitOfMeasure"
FOR UPDATE
USING (
- coalesce(get_my_claim('parts_update')::boolean, false) = true
+ coalesce(get_my_claim('parts_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with parts_delete can delete units of measure" ON "unitOfMeasure"
FOR DELETE
USING (
- coalesce(get_my_claim('parts_delete')::boolean, false) = true
+ coalesce(get_my_claim('parts_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -3433,22 +3389,22 @@ CREATE POLICY "Employees can view parts" ON "part"
CREATE POLICY "Employees with parts_create can insert parts" ON "part"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('parts_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('parts_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with parts_update can update parts" ON "part"
FOR UPDATE
USING (
- coalesce(get_my_claim('parts_update')::boolean, false) = true
+ coalesce(get_my_claim('parts_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with parts_delete can delete parts" ON "part"
FOR DELETE
USING (
- coalesce(get_my_claim('parts_delete')::boolean, false) = true
+ coalesce(get_my_claim('parts_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -3477,7 +3433,7 @@ BEGIN
INSERT INTO public."partUnitSalePrice"("partId", "currencyCode", "createdBy")
-- TODO: get default currency
VALUES (new.id, 'USD', new."createdBy");
-
+
RETURN new;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;
@@ -3525,14 +3481,14 @@ ALTER TABLE "partCost" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with part_view can view part costs" ON "partCost"
FOR SELECT
USING (
- coalesce(get_my_claim('parts_view')::boolean,false)
+ coalesce(get_my_claim('parts_view')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with parts_update can update part costs" ON "partCost"
FOR UPDATE
USING (
- coalesce(get_my_claim('parts_update')::boolean, false) = true
+ coalesce(get_my_claim('parts_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -3563,14 +3519,14 @@ ALTER TABLE "partUnitSalePrice" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with part_view can view part sale prices" ON "partUnitSalePrice"
FOR SELECT
USING (
- coalesce(get_my_claim('parts_view')::boolean,false)
+ coalesce(get_my_claim('parts_view')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with parts_update can update part sale prices" ON "partUnitSalePrice"
FOR UPDATE
USING (
- coalesce(get_my_claim('parts_update')::boolean, false) = true
+ coalesce(get_my_claim('parts_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -3613,28 +3569,28 @@ CREATE POLICY "Employees with part/purchasing_view can view part suppliers" ON "
CREATE POLICY "Employees with parts_update can update part suppliers" ON "partSupplier"
FOR UPDATE
USING (
- coalesce(get_my_claim('parts_update')::boolean, false) = true
+ coalesce(get_my_claim('parts_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with parts_create can create part suppliers" ON "partSupplier"
FOR INSERT
WITH CHECK (
- coalesce(get_my_claim('parts_create')::boolean, false) = true
+ coalesce(get_my_claim('parts_create')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with parts_delete can delete part suppliers" ON "partSupplier"
FOR DELETE
USING (
- coalesce(get_my_claim('parts_delete')::boolean, false) = true
+ coalesce(get_my_claim('parts_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Suppliers with parts_view can view their own part suppliers" ON "partSupplier"
FOR SELECT
USING (
- coalesce(get_my_claim('parts_view')::boolean,false)
+ coalesce(get_my_claim('parts_view')::boolean,false)
AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
@@ -3644,7 +3600,7 @@ CREATE POLICY "Suppliers with parts_view can view their own part suppliers" ON "
CREATE POLICY "Suppliers with parts_update can update their own part suppliers" ON "partSupplier"
FOR UPDATE
USING (
- coalesce(get_my_claim('parts_update')::boolean,false)
+ coalesce(get_my_claim('parts_update')::boolean,false)
AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
@@ -3669,7 +3625,7 @@ CREATE TABLE "partReplenishment" (
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
"updatedBy" TEXT,
"updatedAt" TIMESTAMP WITH TIME ZONE,
-
+
CONSTRAINT "partReplenishment_partId_fkey" FOREIGN KEY ("partId") REFERENCES "part"("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "partReplenishment_preferredSupplierId_fkey" FOREIGN KEY ("preferredSupplierId") REFERENCES "supplier"("id") ON DELETE SET NULL,
CONSTRAINT "partReplenishment_purchaseUnitOfMeasureCode_fkey" FOREIGN KEY ("purchasingUnitOfMeasureCode") REFERENCES "unitOfMeasure"("code") ON DELETE SET NULL ON UPDATE CASCADE,
@@ -3685,14 +3641,14 @@ ALTER TABLE "partReplenishment" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with part_view can view part costs" ON "partReplenishment"
FOR SELECT
USING (
- coalesce(get_my_claim('parts_view')::boolean,false)
+ coalesce(get_my_claim('parts_view')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with parts_update can update part costs" ON "partReplenishment"
FOR UPDATE
USING (
- coalesce(get_my_claim('parts_update')::boolean, false) = true
+ coalesce(get_my_claim('parts_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -3700,8 +3656,8 @@ CREATE POLICY "Employees with parts_update can update part costs" ON "partReplen
CREATE POLICY "Suppliers with parts can view parts they created or supply" ON "part"
FOR SELECT
USING (
- coalesce(get_my_claim('parts_view')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
+ coalesce(get_my_claim('parts_view')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND (
"createdBy" = auth.uid()::text
OR (
@@ -3709,22 +3665,22 @@ CREATE POLICY "Suppliers with parts can view parts they created or supply" ON "p
SELECT "partId" FROM "partSupplier" WHERE "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
)
- )
- )
+ )
+ )
)
);
CREATE POLICY "Supliers with parts_create can insert parts" ON "part"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('parts_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('parts_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
);
CREATE POLICY "Suppliers with parts_update can update parts that they created or supply" ON "part"
FOR UPDATE
USING (
- coalesce(get_my_claim('parts_update')::boolean, false) = true
+ coalesce(get_my_claim('parts_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
AND (
"createdBy" = auth.uid()::text
@@ -3733,15 +3689,15 @@ CREATE POLICY "Suppliers with parts_update can update parts that they created or
SELECT "partId" FROM "partSupplier" WHERE "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
)
- )
- )
+ )
+ )
)
);
CREATE POLICY "Suppliers with parts_delete can delete parts that they created or supply" ON "part"
FOR DELETE
USING (
- coalesce(get_my_claim('parts_delete')::boolean, false) = true
+ coalesce(get_my_claim('parts_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
AND (
"createdBy" = auth.uid()::text
@@ -3750,64 +3706,64 @@ CREATE POLICY "Suppliers with parts_delete can delete parts that they created or
SELECT "partId" FROM "partSupplier" WHERE "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
)
- )
- )
- )
+ )
+ )
+ )
);
CREATE POLICY "Suppliers with parts can view part costs they supply" ON "partCost"
FOR SELECT
USING (
- coalesce(get_my_claim('parts_view')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
+ coalesce(get_my_claim('parts_view')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND (
"partId" IN (
SELECT "partId" FROM "partSupplier" WHERE "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
)
- )
+ )
)
);
CREATE POLICY "Suppliers with parts_update can update parts costs that they supply" ON "partCost"
FOR UPDATE
USING (
- coalesce(get_my_claim('parts_update')::boolean, false) = true
+ coalesce(get_my_claim('parts_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
AND (
"partId" IN (
SELECT "partId" FROM "partSupplier" WHERE "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
)
- )
+ )
)
);
CREATE POLICY "Suppliers with parts can view part replenishments they supply" ON "partReplenishment"
FOR SELECT
USING (
- coalesce(get_my_claim('parts_view')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
+ coalesce(get_my_claim('parts_view')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND (
"partId" IN (
SELECT "partId" FROM "partSupplier" WHERE "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
)
- )
+ )
)
);
CREATE POLICY "Suppliers with parts_update can update parts replenishments that they supply" ON "partReplenishment"
FOR UPDATE
USING (
- coalesce(get_my_claim('parts_update')::boolean, false) = true
+ coalesce(get_my_claim('parts_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
AND (
"partId" IN (
SELECT "partId" FROM "partSupplier" WHERE "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
)
- )
+ )
)
);
@@ -3860,26 +3816,26 @@ CREATE POLICY "Authenticated users can view shelves" ON "shelf"
USING (
auth.role() = 'authenticated'
);
-
+
CREATE POLICY "Employees with parts_create can insert shelves" ON "shelf"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('parts_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('parts_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with parts_update can update shelves" ON "shelf"
FOR UPDATE
USING (
- coalesce(get_my_claim('parts_update')::boolean, false) = true
+ coalesce(get_my_claim('parts_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with parts_delete can delete shelves" ON "shelf"
FOR DELETE
USING (
- coalesce(get_my_claim('parts_delete')::boolean, false) = true
+ coalesce(get_my_claim('parts_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -3919,7 +3875,7 @@ ALTER TABLE "partPlanning" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with parts can view part planning" ON "partPlanning"
FOR SELECT
USING (
- coalesce(get_my_claim('parts_view')::boolean,false)
+ coalesce(get_my_claim('parts_view')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -3927,14 +3883,14 @@ CREATE POLICY "Employees with parts can view part planning" ON "partPlanning"
CREATE POLICY "Employees with parts can insert part planning" ON "partPlanning"
FOR INSERT
WITH CHECK (
- coalesce(get_my_claim('parts_view')::boolean,false)
+ coalesce(get_my_claim('parts_view')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with parts_update can update part planning" ON "partPlanning"
FOR UPDATE
USING (
- coalesce(get_my_claim('parts_update')::boolean, false) = true
+ coalesce(get_my_claim('parts_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -3964,7 +3920,7 @@ ALTER TABLE "partInventory" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with part_view can view part planning" ON "partInventory"
FOR SELECT
USING (
- coalesce(get_my_claim('parts_view')::boolean,false)
+ coalesce(get_my_claim('parts_view')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -3972,14 +3928,14 @@ CREATE POLICY "Employees with part_view can view part planning" ON "partInventor
CREATE POLICY "Employees with part_view can insert part planning" ON "partInventory"
FOR INSERT
WITH CHECK (
- coalesce(get_my_claim('parts_view')::boolean,false)
+ coalesce(get_my_claim('parts_view')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with parts_update can update part planning" ON "partInventory"
FOR UPDATE
USING (
- coalesce(get_my_claim('parts_update')::boolean, false) = true
+ coalesce(get_my_claim('parts_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -3989,8 +3945,6 @@ CREATE POLICY "Employees with parts_update can update part planning" ON "partInv
```
-
-
## `services`
```sql
@@ -4031,22 +3985,22 @@ CREATE POLICY "Employees can view services" ON "service"
CREATE POLICY "Employees with parts_create can insert services" ON "service"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('parts_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('parts_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with parts_update can update services" ON "service"
FOR UPDATE
USING (
- coalesce(get_my_claim('parts_update')::boolean, false) = true
+ coalesce(get_my_claim('parts_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with parts_delete can delete services" ON "service"
FOR DELETE
USING (
- coalesce(get_my_claim('parts_delete')::boolean, false) = true
+ coalesce(get_my_claim('parts_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -4087,28 +4041,28 @@ CREATE POLICY "Employees with part/purchasing_view can view service suppliers" O
CREATE POLICY "Employees with parts_update can update service suppliers" ON "serviceSupplier"
FOR UPDATE
USING (
- coalesce(get_my_claim('parts_update')::boolean, false) = true
+ coalesce(get_my_claim('parts_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with parts_create can create service suppliers" ON "serviceSupplier"
FOR INSERT
WITH CHECK (
- coalesce(get_my_claim('parts_create')::boolean, false) = true
+ coalesce(get_my_claim('parts_create')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with parts_delete can delete service suppliers" ON "serviceSupplier"
FOR DELETE
USING (
- coalesce(get_my_claim('parts_delete')::boolean, false) = true
+ coalesce(get_my_claim('parts_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Suppliers with parts_view can view their own part suppliers" ON "serviceSupplier"
FOR SELECT
USING (
- coalesce(get_my_claim('parts_view')::boolean,false)
+ coalesce(get_my_claim('parts_view')::boolean,false)
AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
@@ -4118,7 +4072,7 @@ CREATE POLICY "Suppliers with parts_view can view their own part suppliers" ON "
CREATE POLICY "Suppliers with parts_update can update their own part suppliers" ON "serviceSupplier"
FOR UPDATE
USING (
- coalesce(get_my_claim('parts_update')::boolean,false)
+ coalesce(get_my_claim('parts_update')::boolean,false)
AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
@@ -4148,8 +4102,6 @@ CREATE OR REPLACE VIEW "services" WITH(SECURITY_INVOKER=true) AS
s.active;
```
-
-
## `documents`
```sql
@@ -4169,7 +4121,7 @@ CREATE TABLE "document" (
"updatedAt" TIMESTAMP WITH TIME ZONE,
CONSTRAINT "document_pkey" PRIMARY KEY ("id"),
-
+
CONSTRAINT "document_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id") ON DELETE CASCADE,
CONSTRAINT "document_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id") ON DELETE CASCADE
);
@@ -4178,31 +4130,31 @@ CREATE INDEX "document_visibility_idx" ON "document" USING GIN ("readGroups", "w
ALTER TABLE "document" ENABLE ROW LEVEL SECURITY;
-CREATE POLICY "Users with documents can view documents where they are in the readGroups" ON "document"
+CREATE POLICY "Users with documents can view documents where they are in the readGroups" ON "document"
FOR SELECT USING (
- coalesce(get_my_claim('documents_view')::boolean, false) = true
+ coalesce(get_my_claim('documents_view')::boolean, false) = true
AND (groups_for_user(auth.uid()::text) && "readGroups") = true
);
-CREATE POLICY "Users with documents_create can create documents where they are in the writeGroups" ON "document"
+CREATE POLICY "Users with documents_create can create documents where they are in the writeGroups" ON "document"
FOR INSERT WITH CHECK (
- coalesce(get_my_claim('documents_create')::boolean, false) = true
+ coalesce(get_my_claim('documents_create')::boolean, false) = true
AND (groups_for_user(auth.uid()::text) && "writeGroups") = true
);
CREATE POLICY "Users with documents_update can update documents where they are in the writeGroups" ON "document"
FOR UPDATE USING (
- coalesce(get_my_claim('documents_update')::boolean, false) = true
+ coalesce(get_my_claim('documents_update')::boolean, false) = true
AND (groups_for_user(auth.uid()::text) && "writeGroups") = true
);
CREATE POLICY "Users with documents_delete can delete documents where they are in the writeGroups" ON "document"
FOR DELETE USING (
- coalesce(get_my_claim('documents_delete')::boolean, false) = true
+ coalesce(get_my_claim('documents_delete')::boolean, false) = true
AND (groups_for_user(auth.uid()::text) && "writeGroups") = true
);
-CREATE POLICY "Private buckets view requires ownership or document.readGroups" ON storage.objects
+CREATE POLICY "Private buckets view requires ownership or document.readGroups" ON storage.objects
FOR SELECT USING (
bucket_id = 'private'
AND (auth.role() = 'authenticated')
@@ -4215,7 +4167,7 @@ FOR SELECT USING (
)
);
-CREATE POLICY "Private buckets insert requires ownership or document.writeGroups" ON storage.objects
+CREATE POLICY "Private buckets insert requires ownership or document.writeGroups" ON storage.objects
FOR INSERT WITH CHECK (
bucket_id = 'private'
AND (auth.role() = 'authenticated')
@@ -4228,7 +4180,7 @@ FOR INSERT WITH CHECK (
)
);
-CREATE POLICY "Private buckets update requires ownership or document.writeGroups" ON storage.objects
+CREATE POLICY "Private buckets update requires ownership or document.writeGroups" ON storage.objects
FOR UPDATE USING (
bucket_id = 'private'
AND (auth.role() = 'authenticated')
@@ -4241,7 +4193,7 @@ FOR UPDATE USING (
)
);
-CREATE POLICY "Private buckets delete requires ownership or document.writeGroups" ON storage.objects
+CREATE POLICY "Private buckets delete requires ownership or document.writeGroups" ON storage.objects
FOR DELETE USING (
bucket_id = 'private'
AND (auth.role() = 'authenticated')
@@ -4292,12 +4244,12 @@ CREATE INDEX "documentFavorites_documentId_idx" ON "documentFavorite" ("document
ALTER TABLE "documentFavorite" ENABLE ROW LEVEL SECURITY;
-CREATE POLICY "Users can view their own document favorites" ON "documentFavorite"
+CREATE POLICY "Users can view their own document favorites" ON "documentFavorite"
FOR SELECT USING (
auth.uid()::text = "userId"
);
-CREATE POLICY "Users can create their own document favorites" ON "documentFavorite"
+CREATE POLICY "Users can create their own document favorites" ON "documentFavorite"
FOR INSERT WITH CHECK (
auth.uid()::text = "userId"
);
@@ -4305,7 +4257,7 @@ CREATE POLICY "Users can create their own document favorites" ON "documentFavori
CREATE POLICY "Users can delete their own document favorites" ON "documentFavorite"
FOR DELETE USING (
auth.uid()::text = "userId"
- );
+ );
CREATE TABLE "documentLabel" (
"documentId" TEXT NOT NULL,
@@ -4323,12 +4275,12 @@ CREATE INDEX "documentLabels_label_idx" ON "documentLabel" ("label");
ALTER TABLE "documentLabel" ENABLE ROW LEVEL SECURITY;
-CREATE POLICY "Users can view their own labels" ON "documentLabel"
+CREATE POLICY "Users can view their own labels" ON "documentLabel"
FOR SELECT USING (
auth.uid()::text = "userId"
);
-CREATE POLICY "Users can create their own labels" ON "documentLabel"
+CREATE POLICY "Users can create their own labels" ON "documentLabel"
FOR INSERT WITH CHECK (
auth.uid()::text = "userId"
);
@@ -4336,7 +4288,7 @@ CREATE POLICY "Users can create their own labels" ON "documentLabel"
CREATE POLICY "Users can delete their own labels" ON "documentLabel"
FOR DELETE USING (
auth.uid()::text = "userId"
- );
+ );
CREATE FUNCTION public.upload_document_transaction()
RETURNS TRIGGER AS $$
@@ -4372,7 +4324,7 @@ CREATE OR REPLACE VIEW "documentLabels" AS
"userId"
FROM "documentLabel";
-CREATE OR REPLACE VIEW "documents" AS
+CREATE OR REPLACE VIEW "documents" AS
SELECT
d.id,
d.path,
@@ -4400,8 +4352,6 @@ CREATE OR REPLACE VIEW "documents" AS
```
-
-
## `purchasing`
```sql
@@ -4444,29 +4394,29 @@ CREATE POLICY "Certain employees can view payment terms" ON "paymentTerm"
)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
-
+
CREATE POLICY "Employees with accounting_create can insert payment terms" ON "paymentTerm"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('accounting_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('accounting_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with accounting_update can update payment terms" ON "paymentTerm"
FOR UPDATE
USING (
- coalesce(get_my_claim('accounting_update')::boolean, false) = true
+ coalesce(get_my_claim('accounting_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with accounting_delete can delete payment terms" ON "paymentTerm"
FOR DELETE
USING (
- coalesce(get_my_claim('accounting_delete')::boolean, false) = true
+ coalesce(get_my_claim('accounting_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
-
+
CREATE TYPE "shippingCarrier" AS ENUM (
'UPS',
@@ -4510,26 +4460,26 @@ CREATE POLICY "Certain employees can view shipping methods" ON "shippingMethod"
)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
-
+
CREATE POLICY "Employees with inventory_create can insert shipping methods" ON "shippingMethod"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('inventory_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('inventory_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with inventory_update can update shipping methods" ON "shippingMethod"
FOR UPDATE
USING (
- coalesce(get_my_claim('inventory_update')::boolean, false) = true
+ coalesce(get_my_claim('inventory_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with inventory_delete can delete shipping methods" ON "shippingMethod"
FOR DELETE
USING (
- coalesce(get_my_claim('inventory_delete')::boolean, false) = true
+ coalesce(get_my_claim('inventory_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -4550,7 +4500,7 @@ CREATE TABLE "shippingTerm" (
CREATE TYPE "purchaseOrderType" AS ENUM (
- 'Purchase',
+ 'Purchase',
'Return'
);
@@ -4655,35 +4605,35 @@ CREATE TABLE "purchaseOrderLine" (
"accountNumber" IS NULL AND
"assetId" IS NULL AND
"description" IS NOT NULL
- )
+ )
OR (
"purchaseOrderLineType" = 'G/L Account' AND
"partId" IS NULL AND
"serviceId" IS NULL AND
"accountNumber" IS NOT NULL AND
- "assetId" IS NULL
- )
+ "assetId" IS NULL
+ )
OR (
"purchaseOrderLineType" = 'Part' AND
"partId" IS NOT NULL AND
"serviceId" IS NULL AND
"accountNumber" IS NULL AND
- "assetId" IS NULL
- )
+ "assetId" IS NULL
+ )
OR (
"purchaseOrderLineType" = 'Service' AND
"partId" IS NULL AND
"serviceId" IS NOT NULL AND
"accountNumber" IS NULL AND
- "assetId" IS NULL
- )
+ "assetId" IS NULL
+ )
OR (
"purchaseOrderLineType" = 'Fixed Asset' AND
"partId" IS NULL AND
"serviceId" IS NULL AND
"accountNumber" IS NULL AND
- "assetId" IS NOT NULL
- )
+ "assetId" IS NOT NULL
+ )
),
CONSTRAINT "purchaseOrderLine_pkey" PRIMARY KEY ("id"),
@@ -4786,12 +4736,12 @@ CREATE INDEX "purchaseOrderFavorites_purchaseOrderId_idx" ON "purchaseOrderFavor
ALTER TABLE "purchaseOrderFavorite" ENABLE ROW LEVEL SECURITY;
-CREATE POLICY "Users can view their own purchase order favorites" ON "purchaseOrderFavorite"
+CREATE POLICY "Users can view their own purchase order favorites" ON "purchaseOrderFavorite"
FOR SELECT USING (
auth.uid()::text = "userId"
);
-CREATE POLICY "Users can create their own purchase order favorites" ON "purchaseOrderFavorite"
+CREATE POLICY "Users can create their own purchase order favorites" ON "purchaseOrderFavorite"
FOR INSERT WITH CHECK (
auth.uid()::text = "userId"
);
@@ -4799,7 +4749,7 @@ CREATE POLICY "Users can create their own purchase order favorites" ON "purchase
CREATE POLICY "Users can delete their own purchase order favorites" ON "purchaseOrderFavorite"
FOR DELETE USING (
auth.uid()::text = "userId"
- );
+ );
CREATE OR REPLACE VIEW "purchaseOrders" AS
SELECT
@@ -4839,18 +4789,16 @@ CREATE OR REPLACE VIEW "purchaseOrderSuppliers" AS
s."name"
FROM "supplier" s
INNER JOIN "purchaseOrder" p ON p."supplierId" = s."id";
-
-
-```
+```
## `sequences`
```sql
CREATE TABLE "sequence" (
"id" TEXT GENERATED ALWAYS AS (
- CASE WHEN prefix IS NULL AND suffix IS NULL THEN
+ CASE WHEN prefix IS NULL AND suffix IS NULL THEN
repeat('0', "size")
WHEN prefix IS NULL THEN
repeat('0', "size") || suffix
@@ -4881,19 +4829,17 @@ CREATE TABLE "sequence" (
```
-
-
## `purchasing-files`
```sql
INSERT INTO storage.buckets (id, name, public)
-VALUES
+VALUES
('purchasing-internal', 'purchasing-internal', false),
('purchasing-external', 'purchasing-external', false);
-- Internal purchasing documents
-CREATE POLICY "Internal purchasing documents view requires purchasing_view" ON storage.objects
+CREATE POLICY "Internal purchasing documents view requires purchasing_view" ON storage.objects
FOR SELECT USING (
bucket_id = 'purchasing-internal'
AND (auth.role() = 'authenticated')
@@ -4901,7 +4847,7 @@ FOR SELECT USING (
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
-CREATE POLICY "Internal purchasing documents insert requires purchasing_create" ON storage.objects
+CREATE POLICY "Internal purchasing documents insert requires purchasing_create" ON storage.objects
FOR INSERT WITH CHECK (
bucket_id = 'purchasing-internal'
AND (auth.role() = 'authenticated')
@@ -4909,7 +4855,7 @@ FOR INSERT WITH CHECK (
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
-CREATE POLICY "Internal purchasing documents update requires purchasing_update" ON storage.objects
+CREATE POLICY "Internal purchasing documents update requires purchasing_update" ON storage.objects
FOR UPDATE USING (
bucket_id = 'purchasing-internal'
AND (auth.role() = 'authenticated')
@@ -4917,7 +4863,7 @@ FOR UPDATE USING (
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
-CREATE POLICY "Internal purchasing documents delete requires purchasing_delete" ON storage.objects
+CREATE POLICY "Internal purchasing documents delete requires purchasing_delete" ON storage.objects
FOR DELETE USING (
bucket_id = 'purchasing-internal'
AND (auth.role() = 'authenticated')
@@ -4927,7 +4873,7 @@ FOR DELETE USING (
-- External purchasing documents
-CREATE POLICY "External purchasing documents view requires purchasing_view" ON storage.objects
+CREATE POLICY "External purchasing documents view requires purchasing_view" ON storage.objects
FOR SELECT USING (
bucket_id = 'purchasing-external'
AND (auth.role() = 'authenticated')
@@ -4940,7 +4886,7 @@ FOR SELECT USING (
)
);
-CREATE POLICY "External purchasing documents insert requires purchasing_view" ON storage.objects
+CREATE POLICY "External purchasing documents insert requires purchasing_view" ON storage.objects
FOR INSERT WITH CHECK (
bucket_id = 'purchasing-external'
AND (auth.role() = 'authenticated')
@@ -4953,7 +4899,7 @@ FOR INSERT WITH CHECK (
)
);
-CREATE POLICY "External purchasing documents update requires purchasing_update" ON storage.objects
+CREATE POLICY "External purchasing documents update requires purchasing_update" ON storage.objects
FOR UPDATE USING (
bucket_id = 'purchasing-external'
AND (auth.role() = 'authenticated')
@@ -4966,7 +4912,7 @@ FOR UPDATE USING (
)
);
-CREATE POLICY "External purchasing documents delete requires purchasing_delete" ON storage.objects
+CREATE POLICY "External purchasing documents delete requires purchasing_delete" ON storage.objects
FOR DELETE USING (
bucket_id = 'purchasing-external'
AND (auth.role() = 'authenticated')
@@ -4980,8 +4926,6 @@ FOR DELETE USING (
);
```
-
-
## `purchasing-rls`
```sql
@@ -4999,8 +4943,8 @@ CREATE POLICY "Employees with purchasing_view, inventory_view, or invoicing_view
CREATE POLICY "Suppliers with purchasing_view can their own purchase orders" ON "purchaseOrder"
FOR SELECT
USING (
- coalesce(get_my_claim('purchasing_view')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
+ coalesce(get_my_claim('purchasing_view')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
)
@@ -5018,8 +4962,8 @@ CREATE POLICY "Employees with purchasing_update can update purchase orders" ON "
CREATE POLICY "Suppliers with purchasing_update can their own purchase orders" ON "purchaseOrder"
FOR UPDATE
USING (
- coalesce(get_my_claim('purchasing_update')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
+ coalesce(get_my_claim('purchasing_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND "supplierId" IN (
SELECT "supplierId" FROM "supplierAccount" WHERE id::uuid = auth.uid()
)
@@ -5063,9 +5007,9 @@ CREATE TRIGGER update_purchase_order_search_result
CREATE POLICY "Suppliers with purchasing_view can search for their own purchase orders" ON "search"
FOR SELECT
USING (
- coalesce(get_my_claim('purchasing_view')::boolean, false) = true
+ coalesce(get_my_claim('purchasing_view')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
- AND entity = 'Purchase Order'
+ AND entity = 'Purchase Order'
AND uuid IN (
SELECT id FROM "purchaseOrder" WHERE "supplierId" IN (
SELECT "supplierId" FROM "purchaseOrder" WHERE "supplierId" IN (
@@ -5094,8 +5038,8 @@ CREATE POLICY "Employees with purchasing_view can view purchase order lines" ON
CREATE POLICY "Suppliers with purchasing_view can their own purchase order lines" ON "purchaseOrderLine"
FOR SELECT
USING (
- coalesce(get_my_claim('purchasing_view')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
+ coalesce(get_my_claim('purchasing_view')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND "purchaseOrderId" IN (
SELECT id FROM "purchaseOrder" WHERE "supplierId" IN (
SELECT "supplierId" FROM "purchaseOrder" WHERE "supplierId" IN (
@@ -5112,8 +5056,8 @@ CREATE POLICY "Employees with purchasing_create can create purchase order lines"
CREATE POLICY "Suppliers with purchasing_create can create lines on their own purchase order" ON "purchaseOrderLine"
FOR INSERT
WITH CHECK (
- coalesce(get_my_claim('purchasing_create')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
+ coalesce(get_my_claim('purchasing_create')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND "purchaseOrderId" IN (
SELECT id FROM "purchaseOrder" WHERE "supplierId" IN (
SELECT "supplierId" FROM "purchaseOrder" WHERE "supplierId" IN (
@@ -5130,8 +5074,8 @@ CREATE POLICY "Employees with purchasing_update can update purchase order lines"
CREATE POLICY "Suppliers with purchasing_update can their own purchase order lines" ON "purchaseOrderLine"
FOR UPDATE
USING (
- coalesce(get_my_claim('purchasing_update')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
+ coalesce(get_my_claim('purchasing_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND "purchaseOrderId" IN (
SELECT id FROM "purchaseOrder" WHERE "supplierId" IN (
SELECT "supplierId" FROM "purchaseOrder" WHERE "supplierId" IN (
@@ -5148,8 +5092,8 @@ CREATE POLICY "Employees with purchasing_delete can delete purchase order lines"
CREATE POLICY "Suppliers with purchasing_delete can delete lines on their own purchase order" ON "purchaseOrderLine"
FOR DELETE
USING (
- coalesce(get_my_claim('purchasing_delete')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
+ coalesce(get_my_claim('purchasing_delete')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND "purchaseOrderId" IN (
SELECT id FROM "purchaseOrder" WHERE "supplierId" IN (
SELECT "supplierId" FROM "purchaseOrder" WHERE "supplierId" IN (
@@ -5171,8 +5115,8 @@ CREATE POLICY "Employees with purchasing_view can view purchase order deliveries
CREATE POLICY "Suppliers with purchasing_view can their own purchase order deliveries" ON "purchaseOrderDelivery"
FOR SELECT
USING (
- coalesce(get_my_claim('purchasing_view')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
+ coalesce(get_my_claim('purchasing_view')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND id IN (
SELECT id FROM "purchaseOrder" WHERE "supplierId" IN (
SELECT "supplierId" FROM "purchaseOrder" WHERE "supplierId" IN (
@@ -5193,8 +5137,8 @@ CREATE POLICY "Employees with purchasing_update can update purchase order delive
CREATE POLICY "Suppliers with purchasing_update can their own purchase order deliveries" ON "purchaseOrderDelivery"
FOR UPDATE
USING (
- coalesce(get_my_claim('purchasing_update')::boolean, false) = true
- AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
+ coalesce(get_my_claim('purchasing_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"supplier"'::jsonb
AND id IN (
SELECT id FROM "purchaseOrder" WHERE "supplierId" IN (
SELECT "supplierId" FROM "purchaseOrder" WHERE "supplierId" IN (
@@ -5231,13 +5175,11 @@ CREATE POLICY "Employees with purchasing_delete can delete purchase order paymen
```
-
-
## `supplier-view`
```sql
-CREATE OR REPLACE VIEW "suppliers" AS
- SELECT
+CREATE OR REPLACE VIEW "suppliers" AS
+ SELECT
s.id,
s.name,
s."supplierTypeId",
@@ -5250,22 +5192,22 @@ CREATE OR REPLACE VIEW "suppliers" AS
LEFT JOIN "supplierType" st ON st.id = s."supplierTypeId"
LEFT JOIN "supplierStatus" ss ON ss.id = s."supplierStatusId"
LEFT JOIN (
- SELECT
+ SELECT
"supplierId",
COUNT(*) AS "count"
FROM "purchaseOrder"
GROUP BY "supplierId"
) po ON po."supplierId" = s.id
LEFT JOIN (
- SELECT
+ SELECT
"supplierId",
COUNT(*) AS "count"
FROM "partSupplier"
GROUP BY "supplierId"
) p ON p."supplierId" = s.id;
- CREATE OR REPLACE VIEW "customers" AS
- SELECT
+ CREATE OR REPLACE VIEW "customers" AS
+ SELECT
c.id,
c.name,
c."customerTypeId",
@@ -5278,7 +5220,7 @@ CREATE OR REPLACE VIEW "suppliers" AS
LEFT JOIN "customerStatus" cs ON cs.id = c."customerStatusId";
-- LEFT JOIN (
- -- SELECT
+ -- SELECT
-- "customerId",
-- COUNT(*) AS "count"
-- FROM "salesOrder"
@@ -5287,12 +5229,10 @@ CREATE OR REPLACE VIEW "suppliers" AS
```
-
-
## `parts-view`
```sql
-CREATE OR REPLACE VIEW "parts" AS
+CREATE OR REPLACE VIEW "parts" AS
SELECT
p.id,
p.name,
@@ -5314,11 +5254,9 @@ CREATE OR REPLACE VIEW "parts" AS
pg.name,
p."replenishmentSystem",
p.active;
-
-
-```
+```
## `view-rls`
@@ -5336,8 +5274,6 @@ ALTER VIEW "parts" SET (security_invoker = on);
```
-
-
## `warehouses`
```sql
@@ -5409,23 +5345,21 @@ ALTER VIEW "parts" SET (security_invoker = on);
```
-
-
## `ledgers`
```sql
CREATE TYPE "month" AS ENUM (
- 'January',
- 'February',
- 'March',
- 'April',
- 'May',
- 'June',
- 'July',
- 'August',
- 'September',
- 'October',
- 'November',
+ 'January',
+ 'February',
+ 'March',
+ 'April',
+ 'May',
+ 'June',
+ 'July',
+ 'August',
+ 'September',
+ 'October',
+ 'November',
'December'
);
@@ -5442,7 +5376,7 @@ CREATE TABLE "fiscalYearSettings" (
);
CREATE TYPE "accountingPeriodStatus" AS ENUM (
- 'Inactive',
+ 'Inactive',
'Active'
);
@@ -5483,15 +5417,15 @@ ALTER TABLE "journal" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with accounting_view can view journals" ON "journal"
FOR SELECT
USING (
- coalesce(get_my_claim('accounting_view')::boolean, false) = true
+ coalesce(get_my_claim('accounting_view')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
-
+
CREATE POLICY "Employees with accounting_create can insert journals" ON "journal"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('accounting_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('accounting_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -5511,7 +5445,7 @@ CREATE TABLE "journalLine" (
"description" TEXT,
"amount" NUMERIC(19, 4) NOT NULL,
"quantity" NUMERIC(12, 4) NOT NULL DEFAULT 1,
- "documentType" "journalLineDocumentType",
+ "documentType" "journalLineDocumentType",
"documentId" TEXT,
"externalDocumentId" TEXT,
"journalLineReference" TEXT NOT NULL,
@@ -5530,15 +5464,15 @@ ALTER TABLE "journalLine" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with accounting_view can view journal lines" ON "journalLine"
FOR SELECT
USING (
- coalesce(get_my_claim('accounting_view')::boolean, false) = true
+ coalesce(get_my_claim('accounting_view')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
-
+
CREATE POLICY "Employees with accounting_create can insert journal lines" ON "journalLine"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('accounting_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('accounting_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -5692,7 +5626,7 @@ CREATE TABLE "supplierLedger" (
CREATE OR REPLACE FUNCTION "journalLinesByAccountNumber" (
from_date DATE DEFAULT (now() - INTERVAL '100 year'),
to_date DATE DEFAULT now()
-)
+)
RETURNS TABLE (
"number" TEXT,
"balance" NUMERIC(19, 4),
@@ -5702,7 +5636,7 @@ RETURNS TABLE (
AS $$
BEGIN
RETURN QUERY
- SELECT
+ SELECT
a."number",
SUM(jl."amount") AS "balance",
SUM(CASE WHEN j."postingDate" <= to_date THEN jl."amount" ELSE 0 END) AS "balanceAtDate",
@@ -5716,13 +5650,11 @@ $$;
-
-
-```
+```
## `receipts`
@@ -5781,28 +5713,28 @@ ALTER TABLE "receipt" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with inventory_view can view receipts" ON "receipt"
FOR SELECT
- USING (coalesce(get_my_claim('inventory_view')::boolean, false) = true
+ USING (coalesce(get_my_claim('inventory_view')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb);
-
+
CREATE POLICY "Employees with inventory_create can insert receipts" ON "receipt"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('inventory_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('inventory_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with inventory_update can update receipts" ON "receipt"
FOR UPDATE
USING (
- coalesce(get_my_claim('inventory_update')::boolean, false) = true
+ coalesce(get_my_claim('inventory_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with inventory_delete can delete receipts" ON "receipt"
FOR DELETE
USING (
- coalesce(get_my_claim('inventory_delete')::boolean, false) = true
+ coalesce(get_my_claim('inventory_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -5843,29 +5775,29 @@ ALTER TABLE "receiptLine" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with inventory_view can view receipt lines" ON "receiptLine"
FOR SELECT
USING (
- coalesce(get_my_claim('inventory_view')::boolean, false) = true
+ coalesce(get_my_claim('inventory_view')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
-
+
CREATE POLICY "Employees with inventory_create can insert receipt lines" ON "receiptLine"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('inventory_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('inventory_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with inventory_update can update receipt lines" ON "receiptLine"
FOR UPDATE
USING (
- coalesce(get_my_claim('inventory_update')::boolean, false) = true
+ coalesce(get_my_claim('inventory_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with inventory_delete can delete receipt lines" ON "receiptLine"
FOR DELETE
USING (
- coalesce(get_my_claim('inventory_delete')::boolean, false) = true
+ coalesce(get_my_claim('inventory_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -5875,8 +5807,6 @@ CREATE POLICY "Employees with inventory_delete can delete receipt lines" ON "rec
```
-
-
## `defaults`
```sql
@@ -5888,8 +5818,6 @@ CREATE OR REPLACE VIEW "userDefaults" AS
LEFT JOIN "employeeJob" ej ON ej.id = u.id;
```
-
-
## `posting-groups`
```sql
@@ -6009,14 +5937,14 @@ ALTER TABLE "accountDefault" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with accounting_view can view account defaults" ON "accountDefault"
FOR SELECT
USING (
- coalesce(get_my_claim('accounting_view')::boolean,false)
+ coalesce(get_my_claim('accounting_view')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with accounting_update can update account defaults" ON "accountDefault"
FOR UPDATE
USING (
- coalesce(get_my_claim('accounting_update')::boolean, false) = true
+ coalesce(get_my_claim('accounting_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -6070,14 +5998,14 @@ ALTER TABLE "postingGroupInventory" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with accounting_view can view inventory posting groups" ON "postingGroupInventory"
FOR SELECT
USING (
- coalesce(get_my_claim('accounting_view')::boolean,false)
+ coalesce(get_my_claim('accounting_view')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with accounting_update can update inventory posting groups" ON "postingGroupInventory"
FOR UPDATE
USING (
- coalesce(get_my_claim('accounting_update')::boolean, false) = true
+ coalesce(get_my_claim('accounting_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -6114,14 +6042,14 @@ ALTER TABLE "postingGroupPurchasing" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with accounting_view can view purchasing posting groups" ON "postingGroupPurchasing"
FOR SELECT
USING (
- coalesce(get_my_claim('accounting_view')::boolean,false)
+ coalesce(get_my_claim('accounting_view')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with accounting_update can update purchasing posting groups" ON "postingGroupPurchasing"
FOR UPDATE
USING (
- coalesce(get_my_claim('accounting_update')::boolean, false) = true
+ coalesce(get_my_claim('accounting_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -6155,14 +6083,14 @@ CREATE INDEX "postingGroupSales_partGroupId_customerTypeId_idx" ON "postingGroup
CREATE POLICY "Employees with accounting_view can view sales posting groups" ON "postingGroupSales"
FOR SELECT
USING (
- coalesce(get_my_claim('accounting_view')::boolean,false)
+ coalesce(get_my_claim('accounting_view')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with accounting_update can update sales posting groups" ON "postingGroupSales"
FOR UPDATE
USING (
- coalesce(get_my_claim('accounting_update')::boolean, false) = true
+ coalesce(get_my_claim('accounting_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -6324,7 +6252,7 @@ BEGIN
INSERT INTO "postingGroupPurchasing" (
"partGroupId",
"supplierTypeId",
- "payablesAccount",
+ "payablesAccount",
"purchaseAccount",
"purchaseDiscountAccount",
"purchaseCreditAccount",
@@ -6587,13 +6515,11 @@ CREATE TRIGGER create_posting_groups_for_supplier_type
```
-
-
## `uninvoiced-receipts`
```sql
-CREATE OR REPLACE VIEW "receiptsPostedNotInvoiced" AS
- SELECT
+CREATE OR REPLACE VIEW "receiptsPostedNotInvoiced" AS
+ SELECT
r."id",
r."receiptId",
r."sourceDocument",
@@ -6615,7 +6541,7 @@ CREATE OR REPLACE VIEW "receiptsPostedNotInvoiced" AS
AND r."sourceDocument" != 'Inbound Transfer'
AND r."sourceDocument" != 'Outbound Transfer'
- GROUP BY
+ GROUP BY
r."id",
r."receiptId",
r."sourceDocument",
@@ -6626,7 +6552,7 @@ CREATE OR REPLACE VIEW "receiptsPostedNotInvoiced" AS
s."name";
;
-CREATE OR REPLACE VIEW "totalReceiptsPostedNotInvoiced" AS
+CREATE OR REPLACE VIEW "totalReceiptsPostedNotInvoiced" AS
SELECT SUM(l."receivedQuantity" * l."unitPrice") AS "total"
FROM "receipt" r
INNER JOIN "receiptLine" l
@@ -6639,58 +6565,54 @@ CREATE OR REPLACE VIEW "totalReceiptsPostedNotInvoiced" AS
AND r."sourceDocument" != 'Outbound Transfer';
```
-
-
## `quantity-on-hand`
```sql
-CREATE OR REPLACE VIEW "partQuantities" AS
- SELECT
- p."id" AS "partId",
+CREATE OR REPLACE VIEW "partQuantities" AS
+ SELECT
+ p."id" AS "partId",
loc."id" AS "locationId",
COALESCE(SUM(pl."quantity"), 0) AS "quantityOnHand",
COALESCE(pol."quantityToReceive", 0) AS "quantityOnPurchaseOrder",
0 AS "quantityOnSalesOrder",
0 AS "quantityOnProdOrder",
0 AS "quantityAvailable"
- FROM "part" p
+ FROM "part" p
CROSS JOIN "location" loc
LEFT JOIN "partLedger" pl
ON pl."partId" = p."id" AND pl."locationId" = loc."id"
LEFT JOIN (
- SELECT
+ SELECT
pol."partId",
pol."locationId",
COALESCE(SUM(GREATEST(pol."quantityToReceive", 0)), 0) AS "quantityToReceive"
- FROM "purchaseOrderLine" pol
- INNER JOIN "purchaseOrder" po
+ FROM "purchaseOrderLine" pol
+ INNER JOIN "purchaseOrder" po
ON pol."purchaseOrderId" = po."id"
- WHERE po."status" != 'Draft'
+ WHERE po."status" != 'Draft'
AND po."status" != 'Rejected'
AND po."status" != 'Closed'
- GROUP BY
+ GROUP BY
pol."partId",
pol."locationId"
) pol ON pol."partId" = p."id" AND pol."locationId" = loc."id"
- GROUP BY
- p."id",
+ GROUP BY
+ p."id",
loc."id",
pol."quantityToReceive"
```
-
-
## `accounts-payable`
```sql
CREATE TYPE "purchaseInvoiceStatus" AS ENUM (
- 'Draft',
+ 'Draft',
'Pending',
'Submitted',
'Return',
'Debit Note Issued',
- 'Paid',
- 'Partially Paid',
+ 'Paid',
+ 'Partially Paid',
'Overdue',
'Voided'
);
@@ -6745,28 +6667,28 @@ ALTER TABLE "purchaseInvoice" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with invoicing_view can view AP invoices" ON "purchaseInvoice"
FOR SELECT
USING (
- coalesce(get_my_claim('invoicing_view')::boolean,false)
+ coalesce(get_my_claim('invoicing_view')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with invoicing_create can insert AP invoices" ON "purchaseInvoice"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('invoicing_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('invoicing_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with invoicing_update can update AP invoices" ON "purchaseInvoice"
FOR UPDATE
USING (
- coalesce(get_my_claim('invoicing_update')::boolean, false) = true
+ coalesce(get_my_claim('invoicing_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with invoicing_delete can delete AP invoices" ON "purchaseInvoice"
FOR DELETE
USING (
- coalesce(get_my_claim('invoicing_delete')::boolean, false) = true
+ coalesce(get_my_claim('invoicing_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -6787,7 +6709,7 @@ ALTER TABLE "purchaseInvoiceStatusHistory" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with invoicing_view can view AP invoices status history" ON "purchaseInvoiceStatusHistory"
FOR SELECT
USING (
- coalesce(get_my_claim('invoicing_view')::boolean,false)
+ coalesce(get_my_claim('invoicing_view')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -6833,35 +6755,35 @@ CREATE TABLE "purchaseInvoiceLine" (
"accountNumber" IS NULL AND
"assetId" IS NULL AND
"description" IS NOT NULL
- )
+ )
OR (
"invoiceLineType" = 'G/L Account' AND
"partId" IS NULL AND
"serviceId" IS NULL AND
"accountNumber" IS NOT NULL AND
- "assetId" IS NULL
- )
+ "assetId" IS NULL
+ )
OR (
"invoiceLineType" = 'Part' AND
"partId" IS NOT NULL AND
"serviceId" IS NULL AND
"accountNumber" IS NULL AND
- "assetId" IS NULL
- )
+ "assetId" IS NULL
+ )
OR (
"invoiceLineType" = 'Service' AND
"partId" IS NULL AND
"serviceId" IS NOT NULL AND
"accountNumber" IS NULL AND
- "assetId" IS NULL
- )
+ "assetId" IS NULL
+ )
OR (
"invoiceLineType" = 'Fixed Asset' AND
"partId" IS NULL AND
"serviceId" IS NULL AND
"accountNumber" IS NULL AND
- "assetId" IS NOT NULL
- )
+ "assetId" IS NOT NULL
+ )
),
CONSTRAINT "purchaseInvoiceLines_pkey" PRIMARY KEY ("id"),
@@ -6885,28 +6807,28 @@ ALTER TABLE "purchaseInvoiceLine" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with invoicing_view can view AP invoice lines" ON "purchaseInvoiceLine"
FOR SELECT
USING (
- coalesce(get_my_claim('invoicing_view')::boolean,false)
+ coalesce(get_my_claim('invoicing_view')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with invoicing_create can insert AP invoice lines" ON "purchaseInvoiceLine"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('invoicing_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('invoicing_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with invoicing_update can update AP invoice lines" ON "purchaseInvoiceLine"
FOR UPDATE
USING (
- coalesce(get_my_claim('invoicing_update')::boolean, false) = true
+ coalesce(get_my_claim('invoicing_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with invoicing_delete can delete AP invoice lines" ON "purchaseInvoiceLine"
FOR DELETE
USING (
- coalesce(get_my_claim('invoicing_delete')::boolean, false) = true
+ coalesce(get_my_claim('invoicing_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -6931,7 +6853,7 @@ ALTER TABLE "purchaseInvoicePriceChange" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with invoicing_view can view AP invoice price changes" ON "purchaseInvoicePriceChange"
FOR SELECT
USING (
- coalesce(get_my_claim('invoicing_view')::boolean,false)
+ coalesce(get_my_claim('invoicing_view')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -6991,14 +6913,14 @@ ALTER TABLE "purchasePayment" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with invoicing_view can view AP payments" ON "purchasePayment"
FOR SELECT
USING (
- coalesce(get_my_claim('invoicing_view')::boolean,false)
+ coalesce(get_my_claim('invoicing_view')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with invoicing_create can insert AP payments" ON "purchasePayment"
FOR INSERT
- WITH CHECK (
- coalesce(get_my_claim('invoicing_create')::boolean,false)
+ WITH CHECK (
+ coalesce(get_my_claim('invoicing_create')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -7006,7 +6928,7 @@ CREATE POLICY "Employees with invoicing_update can update AP payments" ON "purch
FOR UPDATE
USING (
"paymentDate" IS NULL
- AND coalesce(get_my_claim('invoicing_update')::boolean, false) = true
+ AND coalesce(get_my_claim('invoicing_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -7014,7 +6936,7 @@ CREATE POLICY "Employees with invoicing_delete can delete AP payments" ON "purch
FOR DELETE
USING (
"paymentDate" IS NULL
- AND coalesce(get_my_claim('invoicing_delete')::boolean, false) = true
+ AND coalesce(get_my_claim('invoicing_delete')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
@@ -7033,13 +6955,13 @@ ALTER TABLE "purchaseInvoicePaymentRelation" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with invoicing_view can view AP invoice/payment relations" ON "purchaseInvoicePaymentRelation"
FOR SELECT
USING (
- coalesce(get_my_claim('invoicing_view')::boolean,false)
+ coalesce(get_my_claim('invoicing_view')::boolean,false)
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
-CREATE OR REPLACE VIEW "purchaseInvoices" AS
- SELECT
+CREATE OR REPLACE VIEW "purchaseInvoices" AS
+ SELECT
pi."id",
pi."invoiceId",
pi."supplierId",
@@ -7085,8 +7007,6 @@ CREATE OR REPLACE VIEW "purchaseInvoices" AS
ALTER VIEW "purchaseInvoices" SET (security_invoker = on);
```
-
-
## `supplier-details`
```sql
@@ -7101,7 +7021,7 @@ CREATE TABLE "supplierPayment" (
"currencyCode" TEXT,
"updatedAt" TIMESTAMP WITH TIME ZONE,
"updatedBy" TEXT,
-
+
CONSTRAINT "supplierPayment_pkey" PRIMARY KEY ("supplierId"),
CONSTRAINT "supplierPayment_supplierId_fkey" FOREIGN KEY ("supplierId") REFERENCES "supplier"("id") ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT "supplierPayment_invoiceSupplierId_fkey" FOREIGN KEY ("invoiceSupplierId") REFERENCES "supplier"("id") ON UPDATE CASCADE ON DELETE SET NULL,
@@ -7169,8 +7089,6 @@ CREATE TRIGGER create_supplier_entries
FOR EACH ROW EXECUTE PROCEDURE public.create_supplier_entries();
```
-
-
## `customer-details`
```sql
@@ -7184,7 +7102,7 @@ CREATE TABLE "customerPayment" (
"currencyCode" TEXT,
"updatedAt" TIMESTAMP WITH TIME ZONE,
"updatedBy" TEXT,
-
+
CONSTRAINT "customerPayment_pkey" PRIMARY KEY ("customerId"),
CONSTRAINT "customerPayment_customerId_fkey" FOREIGN KEY ("customerId") REFERENCES "customer"("id") ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT "customerPayment_invoiceCustomerId_fkey" FOREIGN KEY ("invoiceCustomerId") REFERENCES "customer"("id") ON UPDATE CASCADE ON DELETE SET NULL,
@@ -7252,8 +7170,6 @@ CREATE TRIGGER create_customer_entries
FOR EACH ROW EXECUTE PROCEDURE public.create_customer_entries();
```
-
-
## `company`
```sql
@@ -7273,7 +7189,7 @@ CREATE TABLE "company" (
"email" TEXT,
"website" TEXT,
"updatedBy" TEXT,
-
+
CONSTRAINT "company_pkey" PRIMARY KEY ("id"),
-- this is a hack to make sure that this table only ever has one row
CONSTRAINT "accountDefault_id_check" CHECK ("id" = TRUE),
@@ -7286,31 +7202,29 @@ ALTER TABLE "company" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Authenticated users can view company" ON "company"
FOR SELECT
USING (
- auth.role() = 'authenticated'
+ auth.role() = 'authenticated'
);
CREATE POLICY "Employees with settings_create can create company" ON "company"
FOR INSERT
WITH CHECK (
- coalesce(get_my_claim('settings_create')::boolean, false) = true
+ coalesce(get_my_claim('settings_create')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
CREATE POLICY "Employees with settings_update can update company" ON "company"
FOR UPDATE
USING (
- coalesce(get_my_claim('settings_update')::boolean, false) = true
+ coalesce(get_my_claim('settings_update')::boolean, false) = true
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
```
-
-
## `purchase-order-document`
```sql
CREATE OR REPLACE VIEW "purchaseOrderLines" WITH(SECURITY_INVOKER=true) AS
- SELECT
+ SELECT
pol.*,
po."supplierId" ,
p.name AS "partName",
@@ -7320,19 +7234,19 @@ CREATE OR REPLACE VIEW "purchaseOrderLines" WITH(SECURITY_INVOKER=true) AS
s.description AS "serviceDescription",
ss."supplierServiceId"
FROM "purchaseOrderLine" pol
- INNER JOIN "purchaseOrder" po
+ INNER JOIN "purchaseOrder" po
ON po.id = pol."purchaseOrderId"
LEFT OUTER JOIN "part" p
ON p.id = pol."partId"
- LEFT OUTER JOIN "partSupplier" ps
+ LEFT OUTER JOIN "partSupplier" ps
ON p.id = ps."partId" AND po."supplierId" = ps."supplierId"
LEFT OUTER JOIN "service" s
ON s.id = pol."serviceId"
- LEFT OUTER JOIN "serviceSupplier" ss
+ LEFT OUTER JOIN "serviceSupplier" ss
ON s.id = ss."serviceId" AND po."supplierId" = ss."supplierId";
CREATE OR REPLACE VIEW "purchaseOrderLocations" WITH(SECURITY_INVOKER=true) AS
- SELECT
+ SELECT
po.id,
s.name AS "supplierName",
sa."addressLine1" AS "supplierAddressLine1",
@@ -7356,15 +7270,15 @@ CREATE OR REPLACE VIEW "purchaseOrderLocations" WITH(SECURITY_INVOKER=true) AS
ca."state" AS "customerState",
ca."postalCode" AS "customerPostalCode",
ca."countryCode" AS "customerCountryCode"
- FROM "purchaseOrder" po
- LEFT OUTER JOIN "supplier" s
+ FROM "purchaseOrder" po
+ LEFT OUTER JOIN "supplier" s
ON s.id = po."supplierId"
LEFT OUTER JOIN "supplierLocation" sl
ON sl.id = po."supplierLocationId"
LEFT OUTER JOIN "address" sa
ON sa.id = sl."addressId"
- INNER JOIN "purchaseOrderDelivery" pod
- ON pod.id = po.id
+ INNER JOIN "purchaseOrderDelivery" pod
+ ON pod.id = po.id
LEFT OUTER JOIN "location" dl
ON dl.id = pod."locationId"
LEFT OUTER JOIN "customer" c
@@ -7373,8 +7287,7 @@ CREATE OR REPLACE VIEW "purchaseOrderLocations" WITH(SECURITY_INVOKER=true) AS
ON cl.id = pod."customerLocationId"
LEFT OUTER JOIN "address" ca
ON ca.id = cl."addressId";
-
-
-```
+
+```
diff --git a/packages/database/supabase/migrations/20230302030217_equipment.sql b/packages/database/supabase/migrations/20230302030217_equipment.sql
index 26291301f9..d47bcbd400 100644
--- a/packages/database/supabase/migrations/20230302030217_equipment.sql
+++ b/packages/database/supabase/migrations/20230302030217_equipment.sql
@@ -308,7 +308,7 @@ CREATE TABLE "equipment" (
"locationId" TEXT NOT NULL,
"workCellId" TEXT,
"active" BOOLEAN NOT NULL DEFAULT true,
- "activeDate" DATE,
+ "activeDate" DATE DEFAULT CURRENT_DATE,
"createdBy" TEXT NOT NULL,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedBy" TEXT,
@@ -357,7 +357,7 @@ RETURNS TRIGGER AS $$
DECLARE
equipment_type TEXT;
BEGIN
- equipment_type := (SELECT u."name" FROM public."equipmentType" et WHERE et.id = new."equipmentTypeId");
+ equipment_type := (SELECT et."name" FROM public."equipmentType" et WHERE et.id = new."equipmentTypeId");
INSERT INTO public.search(name, description, entity, uuid, link)
VALUES (new.name, COALESCE(new.description, '') || ' ' || equipment_type, 'Resource', new.id, '/x/resources/equipment/list/' || new."equipmentTypeId" || '/' || new.id);
RETURN new;
@@ -374,7 +374,7 @@ DECLARE
equipment_type TEXT;
BEGIN
IF (old.name <> new.name OR old.description <> new.description OR old."equipmentTypeId" <> new."equipmentTypeId") THEN
- equipment_type := (SELECT u."name" FROM public."equipmentType" et WHERE et.id = new."equipmentTypeId");
+ equipment_type := (SELECT et."name" FROM public."equipmentType" et WHERE et.id = new."equipmentTypeId");
UPDATE public.search SET name = new.name, description = COALESCE(new.description, '') || ' ' || equipment_type
WHERE entity = 'Resource' AND uuid = new.id;
END IF;
diff --git a/packages/react/package.json b/packages/react/package.json
index ea45b1deb7..7c317c8418 100644
--- a/packages/react/package.json
+++ b/packages/react/package.json
@@ -21,10 +21,6 @@
"preset": "@carbon/jest/node"
},
"dependencies": {
- "@chakra-ui/react": "^2.8.0",
- "@emotion/react": "^11.11.1",
- "@emotion/styled": "^11.11.0",
- "@internationalized/date": "^3.3.0",
"@radix-ui/react-accessible-icon": "^1.0.3",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-alert-dialog": "^1.0.4",
@@ -78,10 +74,8 @@
"clsx": "^2.0.0",
"cmdk": "^0.2.0",
"dompurify": "3.0.5",
- "framer-motion": "^10.13.1",
"is-hotkey": "^0.2.0",
"react-colorful": "^5.6.1",
- "react-icons": "^4.12.0",
"react-select": "^5.5.1",
"react-window": "^1.8.9",
"tailwind-merge": "^2.2.0",
@@ -105,5 +99,14 @@
"react": "^18.2.0",
"tsup": "^6.2.3",
"typescript": "^5.2.2"
+ },
+ "peerDependencies": {
+ "@chakra-ui/react": "^2.8.0",
+ "@emotion/react": "^11.11.1",
+ "@emotion/styled": "^11.11.0",
+ "@internationalized/date": "^3.3.0",
+ "framer-motion": "^10.13.1",
+ "react": "^18.0.0 || ^17.0.0",
+ "react-icons": "^4.12.0"
}
}
diff --git a/packages/react/src/DataTable/DataTable.tsx b/packages/react/src/DataTable/DataTable.tsx
index 998012bf2a..ca418d8c05 100644
--- a/packages/react/src/DataTable/DataTable.tsx
+++ b/packages/react/src/DataTable/DataTable.tsx
@@ -1,4 +1,3 @@
-import { VStack } from "@carbon/react";
import { Grid, Table, Tbody, Td, Th, Thead, Tr } from "@chakra-ui/react";
import type {
ColumnDef,
@@ -17,6 +16,7 @@ import {
useReactTable,
} from "@tanstack/react-table";
import { useState } from "react";
+import { VStack } from "~/VStack";
import { DataTablePagination } from "./DataTablePagination";
diff --git a/packages/react/src/DataTable/DataTablePagination.tsx b/packages/react/src/DataTable/DataTablePagination.tsx
index 2c51232d97..441b51857c 100644
--- a/packages/react/src/DataTable/DataTablePagination.tsx
+++ b/packages/react/src/DataTable/DataTablePagination.tsx
@@ -20,7 +20,7 @@ export function DataTablePagination<TData>({
return (
<HStack
- className="text-center bg-background border-t justify-between px-4 py-2 w-full z-[1]"
+ className="text-center bg-background border-t border-border justify-between px-4 py-2 w-full z-[1]"
spacing={6}
>
<Menu>
diff --git a/packages/react/src/Drawer.tsx b/packages/react/src/Drawer.tsx
new file mode 100644
index 0000000000..3bf87bcc33
--- /dev/null
+++ b/packages/react/src/Drawer.tsx
@@ -0,0 +1,270 @@
+"use client";
+
+import * as DialogPrimitive from "@radix-ui/react-dialog";
+import { cva, type VariantProps } from "class-variance-authority";
+import type {
+ ComponentPropsWithoutRef,
+ ElementRef,
+ HTMLAttributes,
+} from "react";
+import { forwardRef } from "react";
+
+import { MdClose } from "react-icons/md";
+
+import { cn } from "~/utils/cn";
+
+const Drawer = DialogPrimitive.Root;
+
+const DrawerTrigger = DialogPrimitive.Trigger;
+
+const DrawerCloseButton = DialogPrimitive.Close;
+
+const portalVariants = cva("fixed inset-0 z-50 flex", {
+ variants: {
+ position: {
+ top: "items-start",
+ bottom: "items-end",
+ left: "justify-start",
+ right: "justify-end",
+ },
+ },
+ defaultVariants: { position: "right" },
+});
+
+interface DrawerPortalProps
+ extends DialogPrimitive.DialogPortalProps,
+ VariantProps<typeof portalVariants> {}
+
+const DrawerPortal = ({ position, children, ...props }: DrawerPortalProps) => (
+ <DialogPrimitive.Portal {...props}>
+ <div className={portalVariants({ position })}>{children}</div>
+ </DialogPrimitive.Portal>
+);
+DrawerPortal.displayName = DialogPrimitive.Portal.displayName;
+
+const DrawerOverlay = forwardRef<
+ ElementRef<typeof DialogPrimitive.Overlay>,
+ ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
+>(({ className, children, ...props }, ref) => (
+ <DialogPrimitive.Overlay
+ className={cn(
+ "fixed inset-0 z-50 bg-black/10 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
+ className
+ )}
+ {...props}
+ ref={ref}
+ />
+));
+DrawerOverlay.displayName = DialogPrimitive.Overlay.displayName;
+
+const DrawerBody = ({
+ className,
+ ...props
+}: HTMLAttributes<HTMLDivElement>) => (
+ <div
+ className={cn(
+ "flex flex-col flex-1 items-start justify-start overflow-y-auto w-full px-6 py-4",
+ className
+ )}
+ {...props}
+ />
+);
+DrawerBody.displayName = "DrawerBody";
+
+const sheetVariants = cva(
+ "fixed flex flex-col z-50 scale-100 bg-background opacity-100 shadow-lg border border-border overflow-y-auto transition-all duration-100",
+ {
+ variants: {
+ position: {
+ top: "animate-in slide-in-from-top w-full duration-300",
+ bottom: "animate-in slide-in-from-bottom w-full duration-300",
+ left: "animate-in slide-in-from-left h-full duration-300",
+ right: "animate-in slide-in-from-right h-full duration-300",
+ },
+ size: {
+ content: "",
+ sm: "",
+ md: "",
+ lg: "",
+ xl: "",
+ full: "",
+ },
+ },
+ compoundVariants: [
+ {
+ position: ["top", "bottom"],
+ size: "content",
+ class: "max-h-screen",
+ },
+ {
+ position: ["top", "bottom"],
+ size: "md",
+ class: "h-1/3",
+ },
+ {
+ position: ["top", "bottom"],
+ size: "sm",
+ class: "h-1/4",
+ },
+ {
+ position: ["top", "bottom"],
+ size: "lg",
+ class: "h-1/2",
+ },
+ {
+ position: ["top", "bottom"],
+ size: "xl",
+ class: "h-5/6",
+ },
+ {
+ position: ["top", "bottom"],
+ size: "full",
+ class: "h-screen",
+ },
+ {
+ position: ["right", "left"],
+ size: "content",
+ class: "max-w-screen",
+ },
+ {
+ position: ["right", "left"],
+ size: "md",
+ class: "w-1/3",
+ },
+ {
+ position: ["right", "left"],
+ size: "sm",
+ class: "w-1/4",
+ },
+ {
+ position: ["right", "left"],
+ size: "lg",
+ class: "w-1/2",
+ },
+ {
+ position: ["right", "left"],
+ size: "xl",
+ class: "w-5/6",
+ },
+ {
+ position: ["right", "left"],
+ size: "full",
+ class: "w-screen",
+ },
+ ],
+ defaultVariants: {
+ position: "right",
+ size: "md",
+ },
+ }
+);
+
+export interface DialogContentProps
+ extends ComponentPropsWithoutRef<typeof DialogPrimitive.Content>,
+ VariantProps<typeof sheetVariants> {
+ overlay?: boolean;
+ container?: HTMLElement;
+}
+
+const DrawerContent = forwardRef<
+ ElementRef<typeof DialogPrimitive.Content>,
+ DialogContentProps
+>(
+ (
+ {
+ position,
+ size,
+ overlay = true,
+ container,
+ className,
+ children,
+ ...props
+ },
+ ref
+ ) => (
+ <DrawerPortal position={position} container={container}>
+ {overlay && <DrawerOverlay />}
+ <DialogPrimitive.Content
+ ref={ref}
+ className={cn(sheetVariants({ position, size }), className)}
+ {...props}
+ >
+ {children}
+ <DialogPrimitive.Close className="absolute right-4 top-4 rounded-full opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary">
+ <MdClose className="h-6 w-6" />
+ <span className="sr-only">Close</span>
+ </DialogPrimitive.Close>
+ </DialogPrimitive.Content>
+ </DrawerPortal>
+ )
+);
+DrawerContent.displayName = DialogPrimitive.Content.displayName;
+
+const DrawerHeader = ({
+ className,
+ ...props
+}: HTMLAttributes<HTMLDivElement>) => (
+ <div
+ className={cn(
+ "flex flex-col flex-0 space-y-1 text-left px-6 py-4 border-b border-border",
+ className
+ )}
+ {...props}
+ />
+);
+DrawerHeader.displayName = "DrawerHeader";
+
+const DrawerFooter = ({
+ className,
+ ...props
+}: HTMLAttributes<HTMLDivElement>) => (
+ <div
+ className={cn(
+ "flex flex-0 sm:flex-row border-t border-border flex-col-reverse px-6 py-4 sm:justify-end sm:space-x-2",
+ className
+ )}
+ {...props}
+ />
+);
+DrawerFooter.displayName = "DrawerFooter";
+
+const DrawerTitle = forwardRef<
+ ElementRef<typeof DialogPrimitive.Title>,
+ ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
+>(({ className, children, ...props }, ref) => (
+ <DialogPrimitive.Title
+ ref={ref}
+ className={cn(
+ "text-xl font-semibold leading-none tracking-tight text-foreground line-clamp-1",
+ className
+ )}
+ {...props}
+ >
+ {children}
+ </DialogPrimitive.Title>
+));
+DrawerTitle.displayName = DialogPrimitive.Title.displayName;
+
+const DrawerDescription = forwardRef<
+ ElementRef<typeof DialogPrimitive.Description>,
+ ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
+>(({ className, ...props }, ref) => (
+ <DialogPrimitive.Description
+ ref={ref}
+ className={cn("text-sm text-muted-foreground", className)}
+ {...props}
+ />
+));
+DrawerDescription.displayName = DialogPrimitive.Description.displayName;
+
+export {
+ Drawer,
+ DrawerBody,
+ DrawerCloseButton,
+ DrawerContent,
+ DrawerDescription,
+ DrawerFooter,
+ DrawerHeader,
+ DrawerTitle,
+ DrawerTrigger,
+};
diff --git a/packages/react/src/File.tsx b/packages/react/src/File.tsx
index 604827df3f..edbd913811 100644
--- a/packages/react/src/File.tsx
+++ b/packages/react/src/File.tsx
@@ -1,7 +1,7 @@
-import { Button } from "@carbon/react";
import { Input, InputGroup } from "@chakra-ui/react";
import type { ChangeEvent, ComponentPropsWithoutRef } from "react";
import { useRef } from "react";
+import { Button } from "~/Button";
type FileProps = ComponentPropsWithoutRef<"div"> & {
accept?: string;
diff --git a/packages/react/src/Theme/fonts.ts b/packages/react/src/Theme/fonts.ts
index 095e8fefaf..d48c530d6c 100644
--- a/packages/react/src/Theme/fonts.ts
+++ b/packages/react/src/Theme/fonts.ts
@@ -1,4 +1,4 @@
export const fonts = {
- heading: `'SF Pro Display', Inter var,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,'Noto Sans',sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol','Noto Color Emoji'`,
- body: `'SF Pro Display',ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,'Noto Sans',sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol','Noto Color Emoji'`,
+ heading: `'Inter', Inter var,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,'Noto Sans',sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol','Noto Color Emoji'`,
+ body: `'Inter',ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,'Noto Sans',sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol','Noto Color Emoji'`,
};
diff --git a/packages/react/src/Tooltip.tsx b/packages/react/src/Tooltip.tsx
index e4a5aaa705..b9def5b8c0 100644
--- a/packages/react/src/Tooltip.tsx
+++ b/packages/react/src/Tooltip.tsx
@@ -1,3 +1,5 @@
+"use client";
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
import type { ComponentPropsWithoutRef, ElementRef } from "react";
import { forwardRef } from "react";
diff --git a/packages/react/src/index.tsx b/packages/react/src/index.tsx
index f7d8a4e7dc..3956696935 100644
--- a/packages/react/src/index.tsx
+++ b/packages/react/src/index.tsx
@@ -21,6 +21,17 @@ import {
TimePicker,
} from "./Date";
import { Dot } from "./Dot";
+import {
+ Drawer,
+ DrawerBody,
+ DrawerCloseButton,
+ DrawerContent,
+ DrawerDescription,
+ DrawerFooter,
+ DrawerHeader,
+ DrawerTitle,
+ DrawerTrigger,
+} from "./Drawer";
import { Editor, useEditor } from "./Editor";
import { File } from "./File";
import { HStack } from "./HStack";
@@ -81,6 +92,15 @@ export {
DateRangePicker,
DateTimePicker,
Dot,
+ Drawer,
+ DrawerBody,
+ DrawerCloseButton,
+ DrawerContent,
+ DrawerDescription,
+ DrawerFooter,
+ DrawerHeader,
+ DrawerTitle,
+ DrawerTrigger,
Editor,
File,
HStack,