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.

🪖 user attributes (#5)

Brad Barbinaeca0f68ceb3
diff --git a/apps/carbon/app/components/Avatar/index.ts b/apps/carbon/app/components/Avatar/index.ts
index fe46201a20..f19101759f 100644
--- a/apps/carbon/app/components/Avatar/index.ts
+++ b/apps/carbon/app/components/Avatar/index.ts
@@ -1,3 +1,3 @@
import { Avatar } from "./Avatar";
-export { Avatar };
+export default Avatar;
diff --git a/apps/carbon/app/components/Data/Empty/Empty.tsx b/apps/carbon/app/components/Data/Empty/Empty.tsx
deleted file mode 100644
index f73077e799..0000000000
--- a/apps/carbon/app/components/Data/Empty/Empty.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import { Flex, Icon, Text, VStack } from "@chakra-ui/react";
-import type { ReactNode } from "react";
-import { GiSadCrab } from "react-icons/gi";
-
-export type EmptyProps = {
- text?: string;
- icon?: ReactNode;
- children?: ReactNode;
-};
-
-export function Empty({ icon, text, children }: EmptyProps) {
- const i = icon ?? GiSadCrab;
- return (
- <VStack align="center" justify="center" h="100%">
- <Flex p={3} align="center" justify="baseline" color="gray.700">
- <Icon as={i as any} boxSize="80px" />
- </Flex>
- <Text>{text}</Text>
- {children}
- </VStack>
- );
-}
-
-export default Empty;
diff --git a/apps/carbon/app/components/Data/Empty/index.ts b/apps/carbon/app/components/Data/Empty/index.ts
deleted file mode 100644
index 4617f34484..0000000000
--- a/apps/carbon/app/components/Data/Empty/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import Empty from "./Empty";
-
-export default Empty;
-export type { EmptyProps } from "./Empty";
diff --git a/apps/carbon/app/components/Data/index.ts b/apps/carbon/app/components/Data/index.ts
deleted file mode 100644
index 96da6f23c5..0000000000
--- a/apps/carbon/app/components/Data/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import Empty from "./Empty";
-import Table from "./Table";
-
-export { Empty, Table };
diff --git a/apps/carbon/app/components/Form/Array.tsx b/apps/carbon/app/components/Form/Array.tsx
new file mode 100644
index 0000000000..50980be627
--- /dev/null
+++ b/apps/carbon/app/components/Form/Array.tsx
@@ -0,0 +1,87 @@
+import type { InputProps } from "@chakra-ui/react";
+import { Button } from "@chakra-ui/react";
+import { VStack } from "@chakra-ui/react";
+import { IconButton } from "@chakra-ui/react";
+import { HStack } from "@chakra-ui/react";
+import {
+ FormControl,
+ FormErrorMessage,
+ FormLabel,
+ Input as ChakraInput,
+} from "@chakra-ui/react";
+import { forwardRef } from "react";
+import { IoMdAdd, IoMdClose } from "react-icons/io";
+import { useField, useFieldArray } from "remix-validated-form";
+
+type FormArrayProps = InputProps & {
+ name: string;
+ label?: string;
+ isRequired?: boolean;
+};
+
+const Array = forwardRef<HTMLInputElement, FormArrayProps>(
+ ({ name, label, isRequired, ...rest }, ref) => {
+ const [items, { push, remove }, error] = useFieldArray<string>(name);
+
+ return (
+ <FormControl isInvalid={!!error} isRequired={isRequired}>
+ {label && <FormLabel htmlFor={`${name}`}>{label}</FormLabel>}
+ <VStack alignItems="start" spacing={2} w="full" mb={4}>
+ {items.map((item, index) => (
+ <ArrayInput
+ key={`${item}-${index}`}
+ id={`${name}[${index}]`}
+ name={`${name}[${index}]`}
+ ref={index === 0 ? ref : undefined}
+ onRemove={() => remove(index)}
+ {...rest}
+ />
+ ))}
+ <Button leftIcon={<IoMdAdd />} onClick={() => push("")}>
+ New Option
+ </Button>
+ </VStack>
+ {error && <FormErrorMessage>{error}</FormErrorMessage>}
+ </FormControl>
+ );
+ }
+);
+
+Array.displayName = "Array";
+
+type ArrayInputProps = InputProps & {
+ name: string;
+ onRemove: () => void;
+};
+
+const ArrayInput = forwardRef<HTMLInputElement, ArrayInputProps>(
+ ({ name, onRemove, ...rest }, ref) => {
+ const { getInputProps, error } = useField(name);
+
+ return (
+ <FormControl isInvalid={!!error} isRequired>
+ <HStack w="full" alignContent="space-between">
+ <ChakraInput
+ ref={ref}
+ {...getInputProps({
+ id: name,
+ ...rest,
+ })}
+ />
+ <IconButton
+ aria-label="Remove item"
+ icon={<IoMdClose />}
+ onClick={onRemove}
+ variant="ghost"
+ />
+ </HStack>
+
+ {error && <FormErrorMessage>{error}</FormErrorMessage>}
+ </FormControl>
+ );
+ }
+);
+
+ArrayInput.displayName = "ArrayInput";
+
+export default Array;
diff --git a/apps/carbon/app/components/Form/Boolean.tsx b/apps/carbon/app/components/Form/Boolean.tsx
new file mode 100644
index 0000000000..0695393d70
--- /dev/null
+++ b/apps/carbon/app/components/Form/Boolean.tsx
@@ -0,0 +1,107 @@
+import type { SwitchProps, SystemStyleObject } from "@chakra-ui/react";
+import { VisuallyHidden } from "@chakra-ui/react";
+import { HStack } from "@chakra-ui/react";
+import {
+ FormControl,
+ FormErrorMessage,
+ FormLabel,
+ Text,
+ chakra,
+ omitThemingProps,
+ useCheckbox,
+ useMultiStyleConfig,
+} from "@chakra-ui/react";
+import { forwardRef, useMemo } from "react";
+import { useControlField, useField } from "remix-validated-form";
+
+type FormBooleanProps = SwitchProps & {
+ name: string;
+ label?: string;
+ description?: string;
+};
+
+const Boolean = forwardRef<HTMLInputElement, FormBooleanProps>(
+ ({ name, label, description, ...props }, ref) => {
+ const { getInputProps, error } = useField(name);
+ const [value, setValue] = useControlField<boolean>(name);
+
+ const styles = useMultiStyleConfig("Switch", {
+ colorScheme: "green",
+ ...props,
+ });
+ const { ...ownProps } = omitThemingProps(props);
+
+ const { getCheckboxProps, getRootProps, getLabelProps } = useCheckbox({
+ ...ownProps,
+ isChecked: value,
+ });
+
+ const containerStyles: SystemStyleObject = useMemo(
+ () => ({
+ display: "inline-block",
+ position: "relative",
+ verticalAlign: "middle",
+ lineHeight: 0,
+ ...styles.container,
+ }),
+ [styles.container]
+ );
+
+ const trackStyles: SystemStyleObject = useMemo(
+ () => ({
+ display: "inline-flex",
+ flexShrink: 0,
+ justifyContent: "flex-start",
+ boxSizing: "content-box",
+ cursor: "pointer",
+ ...styles.track,
+ }),
+ [styles.track]
+ );
+
+ return (
+ <FormControl isInvalid={!!error} pt={2}>
+ {label && <FormLabel htmlFor={name}>{label}</FormLabel>}
+ <HStack w="full">
+ <chakra.label
+ {...getRootProps()}
+ className="chakra-switch"
+ __css={containerStyles}
+ >
+ <VisuallyHidden>
+ <input
+ ref={ref}
+ type="checkbox"
+ {...getInputProps({
+ type: "checkbox",
+ id: name,
+ })}
+ onChange={(e) => setValue(e.target.checked)}
+ />
+ </VisuallyHidden>
+ <HStack>
+ <chakra.span
+ {...getCheckboxProps()}
+ className="chakra-switch__track"
+ __css={trackStyles}
+ >
+ <chakra.span
+ __css={styles.thumb}
+ className="chakra-switch__thumb"
+ data-checked={value ? "" : undefined}
+ />
+ </chakra.span>
+ {description && <Text {...getLabelProps()}>{description}</Text>}
+ </HStack>
+ </chakra.label>
+ </HStack>
+
+ {error && <FormErrorMessage>{error}</FormErrorMessage>}
+ </FormControl>
+ );
+ }
+);
+
+Boolean.displayName = "Boolean";
+
+export default Boolean;
diff --git a/apps/carbon/app/components/Form/DatePicker.tsx b/apps/carbon/app/components/Form/DatePicker.tsx
new file mode 100644
index 0000000000..2bf3b50ffb
--- /dev/null
+++ b/apps/carbon/app/components/Form/DatePicker.tsx
@@ -0,0 +1,35 @@
+import { DatePicker as CarbonDatePicker } from "@carbon/react";
+import type { CalendarDate } from "@internationalized/date";
+import { parseDate } from "@internationalized/date";
+import { FormControl, FormErrorMessage, FormLabel } from "@chakra-ui/react";
+import { useState } from "react";
+import { useField } from "remix-validated-form";
+
+type DatePickerProps = { name: string; label?: string };
+
+const DatePicker = ({ name, label }: DatePickerProps) => {
+ const { error, defaultValue, validate } = useField(name);
+ const [date, setDate] = useState<CalendarDate | undefined>(
+ defaultValue ? parseDate(defaultValue) : undefined
+ );
+
+ const onChange = (date: CalendarDate) => {
+ setDate(date);
+ validate();
+ };
+
+ return (
+ <FormControl isInvalid={!!error}>
+ {label && <FormLabel htmlFor={name}>{label}</FormLabel>}
+ <input type="hidden" name={name} value={date?.toString()} />
+ <CarbonDatePicker
+ value={date}
+ //@ts-ignore
+ onChange={onChange}
+ />
+ {error && <FormErrorMessage>{error}</FormErrorMessage>}
+ </FormControl>
+ );
+};
+
+export default DatePicker;
diff --git a/apps/carbon/app/components/Form/Hidden.tsx b/apps/carbon/app/components/Form/Hidden.tsx
index 573fdd1700..4b35073d25 100644
--- a/apps/carbon/app/components/Form/Hidden.tsx
+++ b/apps/carbon/app/components/Form/Hidden.tsx
@@ -9,7 +9,7 @@ import { useField } from "remix-validated-form";
type FormHiddenProps = InputProps & {
name: string;
- value?: string;
+ value?: string | number;
};
const Hidden = forwardRef<HTMLInputElement, FormHiddenProps>(
diff --git a/apps/carbon/app/components/Form/Number.tsx b/apps/carbon/app/components/Form/Number.tsx
new file mode 100644
index 0000000000..213fd95d1e
--- /dev/null
+++ b/apps/carbon/app/components/Form/Number.tsx
@@ -0,0 +1,48 @@
+import type { NumberInputProps } from "@chakra-ui/react";
+import {
+ FormControl,
+ FormErrorMessage,
+ FormLabel,
+ NumberDecrementStepper,
+ NumberIncrementStepper,
+ NumberInput,
+ NumberInputField,
+ NumberInputStepper,
+} from "@chakra-ui/react";
+import { forwardRef } from "react";
+import { useField } from "remix-validated-form";
+
+type FormNumberProps = NumberInputProps & {
+ name: string;
+ label?: string;
+ isRequired?: boolean;
+};
+
+const Number = forwardRef<HTMLInputElement, FormNumberProps>(
+ ({ name, label, isRequired, ...rest }, ref) => {
+ const { getInputProps, error } = useField(name);
+
+ return (
+ <FormControl isInvalid={!!error} isRequired={isRequired}>
+ {label && <FormLabel htmlFor={name}>{label}</FormLabel>}
+ <NumberInput
+ {...getInputProps({
+ id: name,
+ ...rest,
+ })}
+ >
+ <NumberInputField ref={ref} />
+ <NumberInputStepper>
+ <NumberIncrementStepper />
+ <NumberDecrementStepper />
+ </NumberInputStepper>
+ </NumberInput>
+ {error && <FormErrorMessage>{error}</FormErrorMessage>}
+ </FormControl>
+ );
+ }
+);
+
+Number.displayName = "Number";
+
+export default Number;
diff --git a/apps/carbon/app/components/Form/Password.tsx b/apps/carbon/app/components/Form/Password.tsx
index ac4273a748..b15cca78ad 100644
--- a/apps/carbon/app/components/Form/Password.tsx
+++ b/apps/carbon/app/components/Form/Password.tsx
@@ -1,5 +1,5 @@
import type { InputProps } from "@chakra-ui/react";
-import { Button } from "@chakra-ui/react";
+import { IconButton } from "@chakra-ui/react";
import {
FormControl,
FormErrorMessage,
@@ -9,6 +9,7 @@ import {
InputRightElement,
} from "@chakra-ui/react";
import { forwardRef, useState } from "react";
+import { BiHide, BiShowAlt } from "react-icons/bi";
import { useField } from "remix-validated-form";
type FormPasswordProps = InputProps & {
@@ -34,14 +35,16 @@ const Password = forwardRef<HTMLInputElement, FormPasswordProps>(
ref={ref}
type={passwordVisible ? "text" : "password"}
/>
- <InputRightElement width="4.5rem">
- <Button
+ <InputRightElement width="2.75rem">
+ <IconButton
+ aria-label={passwordVisible ? "Show password" : "Hide password"}
+ icon={passwordVisible ? <BiShowAlt /> : <BiHide />}
h="1.75rem"
size="sm"
+ variant="outline"
+ tabIndex={-1}
onClick={() => setPasswordVisible(!passwordVisible)}
- >
- {passwordVisible ? "Hide" : "Show"}
- </Button>
+ />
</InputRightElement>
</InputGroup>
{error && <FormErrorMessage>{error}</FormErrorMessage>}
diff --git a/apps/carbon/app/components/Form/Radios.tsx b/apps/carbon/app/components/Form/Radios.tsx
index ad6214f99a..4087954014 100644
--- a/apps/carbon/app/components/Form/Radios.tsx
+++ b/apps/carbon/app/components/Form/Radios.tsx
@@ -33,7 +33,6 @@ const Radios = ({
id: name,
})}
name={name}
- colorScheme="blackAlpha"
>
<Stack spacing={2} alignItems="start" direction={direction}>
{options.map(({ label, value }) => (
diff --git a/apps/carbon/app/components/Form/Select.tsx b/apps/carbon/app/components/Form/Select.tsx
index bffe2c9da7..c133224933 100644
--- a/apps/carbon/app/components/Form/Select.tsx
+++ b/apps/carbon/app/components/Form/Select.tsx
@@ -1,22 +1,34 @@
import { Select as CarbonSelect } from "@carbon/react";
-import { FormControl, FormErrorMessage, FormLabel } from "@chakra-ui/react";
+import {
+ FormControl,
+ FormErrorMessage,
+ FormHelperText,
+ FormLabel,
+} from "@chakra-ui/react";
import { useMemo } from "react";
import { useField } from "remix-validated-form";
type SelectProps = {
name: string;
- label: string;
- isLoading?: boolean;
+ label?: string;
options: { value: string | number; label: string }[];
+ helperText?: string;
+ isReadOnly?: boolean;
+ isLoading?: boolean;
placeholder?: string;
+ onChange?: (newValue: { value: string | number; label: string }) => void;
};
const Select = ({
name,
label,
- isLoading,
options,
+ helperText,
+ isLoading,
+ isReadOnly,
placeholder,
+ onChange,
+ ...props
}: SelectProps) => {
const { getInputProps, error, defaultValue } = useField(name);
const initialValue = useMemo(
@@ -33,12 +45,20 @@ const Select = ({
// @ts-ignore
id: name,
})}
+ {...props}
defaultValue={initialValue}
+ isReadOnly={isReadOnly}
isLoading={isLoading}
options={options}
placeholder={placeholder}
+ // @ts-ignore
+ onChange={onChange ?? undefined}
/>
- {error && <FormErrorMessage>{error}</FormErrorMessage>}
+ {error ? (
+ <FormErrorMessage>{error}</FormErrorMessage>
+ ) : (
+ helperText && <FormHelperText>{helperText}</FormHelperText>
+ )}
</FormControl>
) : null;
};
diff --git a/apps/carbon/app/components/Form/Submit.tsx b/apps/carbon/app/components/Form/Submit.tsx
index 6d17cac686..4b867a63e8 100644
--- a/apps/carbon/app/components/Form/Submit.tsx
+++ b/apps/carbon/app/components/Form/Submit.tsx
@@ -4,12 +4,14 @@ import type { PropsWithChildren } from "react";
import { useIsSubmitting } from "remix-validated-form";
export const Submit = ({
+ formId,
children,
...props
-}: PropsWithChildren<ButtonProps & { text?: string }>) => {
+}: PropsWithChildren<ButtonProps & { formId?: string; text?: string }>) => {
const isSubmitting = useIsSubmitting();
return (
<Button
+ form={formId}
type="submit"
size="md"
colorScheme="brand"
diff --git a/apps/carbon/app/components/Form/User.tsx b/apps/carbon/app/components/Form/User.tsx
new file mode 100644
index 0000000000..e1af50c3dc
--- /dev/null
+++ b/apps/carbon/app/components/Form/User.tsx
@@ -0,0 +1,42 @@
+import { FormControl, FormErrorMessage, FormLabel } from "@chakra-ui/react";
+import { useState } from "react";
+import { useField } from "remix-validated-form";
+import { UserSelect } from "../Selectors";
+import type {
+ SelectionItemInterface,
+ UserSelectProps,
+} from "../Selectors/UserSelect/types";
+
+type UserProps = { name: string; label?: string } & UserSelectProps;
+
+const User = ({ name, label, ...props }: UserProps) => {
+ const { error, defaultValue, validate } = useField(name);
+ const [selection, setSelection] = useState<string>(defaultValue);
+
+ const handleChange = (items: SelectionItemInterface[]) => {
+ if (items.length > 0) {
+ const item = items[0];
+ setSelection(item.id);
+ } else {
+ setSelection("");
+ }
+ validate();
+ };
+
+ return (
+ <FormControl isInvalid={!!error}>
+ {label && <FormLabel htmlFor={name}>{label}</FormLabel>}
+ <input type="hidden" name={name} value={selection} />
+ <UserSelect
+ {...props}
+ usersOnly
+ isMulti={false}
+ value={selection}
+ onChange={handleChange}
+ />
+ {error && <FormErrorMessage>{error}</FormErrorMessage>}
+ </FormControl>
+ );
+};
+
+export default User;
diff --git a/apps/carbon/app/components/Form/Users.tsx b/apps/carbon/app/components/Form/Users.tsx
index b192076df2..2d721218f6 100644
--- a/apps/carbon/app/components/Form/Users.tsx
+++ b/apps/carbon/app/components/Form/Users.tsx
@@ -7,7 +7,7 @@ import type {
UserSelectProps,
} from "../Selectors/UserSelect/types";
-type UsersProps = { name: string; label: string } & UserSelectProps;
+type UsersProps = { name: string; label?: string } & UserSelectProps;
const Users = ({ name, label, ...props }: UsersProps) => {
const { error, defaultValue, validate } = useField(name);
diff --git a/apps/carbon/app/components/Form/index.ts b/apps/carbon/app/components/Form/index.ts
index 2e6a386534..5cd7d2e035 100644
--- a/apps/carbon/app/components/Form/index.ts
+++ b/apps/carbon/app/components/Form/index.ts
@@ -1,21 +1,31 @@
+import Array from "./Array";
+import Boolean from "./Boolean";
import Color from "./Color";
+import DatePicker from "./DatePicker";
import Input from "./Input";
import Hidden from "./Hidden";
+import Number from "./Number";
import Password from "./Password";
import Radios from "./Radios";
import Select from "./Select";
import Submit from "./Submit";
import TextArea from "./Textarea";
+import User from "./User";
import Users from "./Users";
export {
+ Array,
+ Boolean,
Color,
+ DatePicker,
Input,
Hidden,
+ Number,
Password,
Radios,
Select,
Submit,
TextArea,
+ User,
Users,
};
diff --git a/apps/carbon/app/components/Layout/SectionTitle/SectionTitle.tsx b/apps/carbon/app/components/Layout/SectionTitle/SectionTitle.tsx
new file mode 100644
index 0000000000..29bcd76731
--- /dev/null
+++ b/apps/carbon/app/components/Layout/SectionTitle/SectionTitle.tsx
@@ -0,0 +1,22 @@
+import type { StackProps } from "@chakra-ui/react";
+import { Heading, Text, VStack } from "@chakra-ui/react";
+
+type SectionTitleProps = StackProps & {
+ title: string;
+ subtitle?: string;
+};
+
+const SectionTitle = ({ title, subtitle, ...props }: SectionTitleProps) => {
+ return (
+ <VStack spacing={2} alignItems="start" w="full" my={4} {...props}>
+ <Heading size="md">{title}</Heading>
+ {subtitle && (
+ <Text fontSize={14} color="gray.500">
+ {subtitle}
+ </Text>
+ )}
+ </VStack>
+ );
+};
+
+export default SectionTitle;
diff --git a/apps/carbon/app/components/Layout/SectionTitle/index.ts b/apps/carbon/app/components/Layout/SectionTitle/index.ts
new file mode 100644
index 0000000000..12113ff6f7
--- /dev/null
+++ b/apps/carbon/app/components/Layout/SectionTitle/index.ts
@@ -0,0 +1,3 @@
+import SectionTitle from "./SectionTitle";
+
+export default SectionTitle;
diff --git a/apps/carbon/app/components/Layout/Topbar/AvatarMenu.tsx b/apps/carbon/app/components/Layout/Topbar/AvatarMenu.tsx
index 04ffbe143a..f3a5828a6c 100644
--- a/apps/carbon/app/components/Layout/Topbar/AvatarMenu.tsx
+++ b/apps/carbon/app/components/Layout/Topbar/AvatarMenu.tsx
@@ -5,7 +5,7 @@ import {
MenuItem,
MenuList,
} from "@chakra-ui/react";
-import { Avatar } from "~/components/Avatar";
+import { Avatar } from "~/components";
import { Form, Link } from "@remix-run/react";
import { BiLogOut } from "react-icons/bi";
import { CgProfile } from "react-icons/cg";
@@ -13,19 +13,21 @@ import { useUser } from "~/hooks";
const AvatarMenu = () => {
const user = useUser();
+ const name = `${user.firstName} ${user.lastName}`;
return (
<Menu>
<MenuButton
+ arial-label="User Menu"
as={Avatar}
path={user.avatarUrl}
+ title={name}
role="button"
- name=""
size="sm"
cursor="pointer"
/>
<MenuList fontSize="sm" boxShadow="xl" minW={48}>
- <MenuItem>Signed in as {`${user.firstName} ${user.lastName}`}</MenuItem>
+ <MenuItem>Signed in as {name}</MenuItem>
<MenuDivider />
<MenuItem as={Link} to="/app/account/profile" icon={<CgProfile />}>
My Profile
diff --git a/apps/carbon/app/components/Layout/Topbar/Topbar.tsx b/apps/carbon/app/components/Layout/Topbar/Topbar.tsx
index abf429d12e..43517138a3 100644
--- a/apps/carbon/app/components/Layout/Topbar/Topbar.tsx
+++ b/apps/carbon/app/components/Layout/Topbar/Topbar.tsx
@@ -1,5 +1,5 @@
import { useColor } from "@carbon/react";
-import { Button, GridItem, HStack } from "@chakra-ui/react";
+import { Button, Flex, GridItem, HStack, Kbd } from "@chakra-ui/react";
import { BiHelpCircle } from "react-icons/bi";
import { FaSearch } from "react-icons/fa";
import AvatarMenu from "./AvatarMenu";
@@ -31,7 +31,7 @@ const Topbar = () => {
<Button
colorScheme="gray"
leftIcon={<FaSearch />}
- variant="solid"
+ variant="outline"
border={1}
borderColor={borderColor}
borderStyle="solid"
@@ -39,7 +39,10 @@ const Topbar = () => {
w={200}
mt={2}
>
- Search
+ <HStack w="full">
+ <Flex flexGrow={1}>Search</Flex>
+ <Kbd size="lg">/</Kbd>
+ </HStack>
</Button>
<HStack py={2} pr={4} justifyContent="end">
<Button
diff --git a/apps/carbon/app/components/Layout/Topbar/useBreadcrumbs.tsx b/apps/carbon/app/components/Layout/Topbar/useBreadcrumbs.tsx
index ed07ea6010..cf52c3f4cf 100644
--- a/apps/carbon/app/components/Layout/Topbar/useBreadcrumbs.tsx
+++ b/apps/carbon/app/components/Layout/Topbar/useBreadcrumbs.tsx
@@ -54,6 +54,11 @@ export default function useBreadcrumbs(): Route[] {
name: "Users",
to: match.pathname,
});
+ case "routes/app.users.attributes":
+ return acc.concat({
+ name: "Attributes",
+ to: match.pathname,
+ });
case "routes/app.users.employees":
return acc.concat({
name: "Employees",
diff --git a/apps/carbon/app/components/Layout/index.ts b/apps/carbon/app/components/Layout/index.ts
index 447c41c1e2..b3ebba6025 100644
--- a/apps/carbon/app/components/Layout/index.ts
+++ b/apps/carbon/app/components/Layout/index.ts
@@ -1,5 +1,6 @@
import { IconSidebar, ContentSidebar } from "./Sidebar";
import PageTitle from "./PageTitle";
+import SectionTitle from "./SectionTitle";
import Topbar from "./Topbar";
-export { ContentSidebar, IconSidebar, PageTitle, Topbar };
+export { ContentSidebar, IconSidebar, PageTitle, SectionTitle, Topbar };
diff --git a/apps/carbon/app/components/Selectors/UserSelect/components/Input.tsx b/apps/carbon/app/components/Selectors/UserSelect/components/Input.tsx
index 4394d8dd2f..4cba0568ca 100644
--- a/apps/carbon/app/components/Selectors/UserSelect/components/Input.tsx
+++ b/apps/carbon/app/components/Selectors/UserSelect/components/Input.tsx
@@ -62,7 +62,7 @@ const SelectInput = () => {
<InputRightElement w="auto">
<HStack spacing={1} mr={2}>
{loading && <Spinner size="sm" />}
- {!loading && inputValue.length > 0 && (
+ {!loading && !disabled && inputValue.length > 0 && (
<IconButton
aria-label="Clear search query"
icon={<MdOutlineClear />}
diff --git a/apps/carbon/app/components/Selectors/UserSelect/components/SelectionList.tsx b/apps/carbon/app/components/Selectors/UserSelect/components/SelectionList.tsx
index 98e27c27d2..0f62c475bc 100644
--- a/apps/carbon/app/components/Selectors/UserSelect/components/SelectionList.tsx
+++ b/apps/carbon/app/components/Selectors/UserSelect/components/SelectionList.tsx
@@ -11,7 +11,7 @@ import {
} from "@chakra-ui/react";
import { useMemo } from "react";
import { MdPlaylistAdd, MdOutlineClear } from "react-icons/md";
-import { Avatar } from "~/components/Avatar";
+import { Avatar } from "~/components";
import useUserSelectContext from "../provider";
import { isGroup } from "../useUserSelect";
diff --git a/apps/carbon/app/components/Selectors/UserSelect/components/TreeSelect.tsx b/apps/carbon/app/components/Selectors/UserSelect/components/TreeSelect.tsx
index d6ffcf736f..ed0f556ee8 100644
--- a/apps/carbon/app/components/Selectors/UserSelect/components/TreeSelect.tsx
+++ b/apps/carbon/app/components/Selectors/UserSelect/components/TreeSelect.tsx
@@ -2,7 +2,6 @@ import { Loading } from "@carbon/react";
import type { IconProps } from "@chakra-ui/react";
import { Box, Icon, List, ListItem, MenuIcon, Text } from "@chakra-ui/react";
import { FaCheck, FaChevronRight } from "react-icons/fa";
-import Empty from "~/components/Data/Empty";
import type { OptionGroup, SelectionItemInterface } from "../types";
import useUserSelectContext from "../provider";
import { useGroupStyles, useOptionStyles } from "./useUserSelectStyles";
@@ -34,7 +33,7 @@ const UserTreeSelect = () => {
) : groups.length > 0 ? (
groups.map((group) => <Group key={group.uid} group={group} />)
) : (
- <Empty text={"No options available"} />
+ <Text>No options found</Text>
)}
</List>
);
diff --git a/apps/carbon/app/components/Selectors/UserSelect/types.ts b/apps/carbon/app/components/Selectors/UserSelect/types.ts
index 4d8ae82a36..9bebf2a7f9 100644
--- a/apps/carbon/app/components/Selectors/UserSelect/types.ts
+++ b/apps/carbon/app/components/Selectors/UserSelect/types.ts
@@ -8,7 +8,7 @@ import type {
RefObject,
} from "react";
-import type { User, Group } from "~/modules/Users/types";
+import type { User, Group } from "~/interfaces/Users/types";
export type ComboBoxRefs = {
containerRef: RefObject<HTMLDivElement>;
diff --git a/apps/carbon/app/components/Selectors/UserSelect/useUserSelect.ts b/apps/carbon/app/components/Selectors/UserSelect/useUserSelect.ts
index 0f43f43bcb..bd31327788 100644
--- a/apps/carbon/app/components/Selectors/UserSelect/useUserSelect.ts
+++ b/apps/carbon/app/components/Selectors/UserSelect/useUserSelect.ts
@@ -5,7 +5,7 @@ import debounce from "lodash/debounce";
import words from "lodash/words";
import type { AriaAttributes, ChangeEvent, KeyboardEvent } from "react";
import { useEffect, useState, useMemo, useCallback, useRef } from "react";
-import type { Group } from "~/modules/Users/types";
+import type { Group } from "~/interfaces/Users/types";
import type {
OptionGroup,
diff --git a/apps/carbon/app/components/Data/Table/Table.tsx b/apps/carbon/app/components/Table/Table.tsx
similarity index 97%
rename from apps/carbon/app/components/Data/Table/Table.tsx
rename to apps/carbon/app/components/Table/Table.tsx
index d46a9ed7b5..a078f310f0 100644
--- a/apps/carbon/app/components/Data/Table/Table.tsx
+++ b/apps/carbon/app/components/Table/Table.tsx
@@ -44,8 +44,10 @@ interface TableProps<T extends object> {
colorScheme?: ThemeTypings["colorSchemes"];
defaultColumnVisibility?: Record<string, boolean>;
withColumnOrdering?: boolean;
+ withFilters?: boolean;
withPagination?: boolean;
withSelectableRows?: boolean;
+ withSimpleSorting?: boolean;
onRowClick?: (row: T) => void;
onSelectedRowsChange?: (selectedRows: T[]) => void;
}
@@ -57,9 +59,11 @@ const Table = <T extends object>({
count = 0,
colorScheme = "blackAlpha",
defaultColumnVisibility = {},
+ withFilters = false,
withColumnOrdering = false,
withPagination = true,
withSelectableRows = false,
+ withSimpleSorting = true,
onRowClick,
onSelectedRowsChange,
}: TableProps<T>) => {
@@ -140,7 +144,7 @@ const Table = <T extends object>({
return (
<>
<Box w="full" h="full">
- {(withColumnOrdering || withSelectableRows) && (
+ {(withColumnOrdering || withFilters || withSelectableRows) && (
<Header
actions={actions}
columnAccessors={columnAccessors}
@@ -150,6 +154,7 @@ const Table = <T extends object>({
setColumnOrder={setColumnOrder}
pagination={pagination}
withColumnOrdering={withColumnOrdering}
+ withFilters={withFilters}
withPagination={withPagination}
withSelectableRows={withSelectableRows}
/>
@@ -175,6 +180,7 @@ const Table = <T extends object>({
{headerGroup.headers.map((header) => {
// TODO: improve this
const sortable =
+ withSimpleSorting &&
"accessorKey" in header.column.columnDef &&
header.column.columnDef.enableSorting !== false;
const sorted = isSorted(
@@ -283,7 +289,9 @@ const Table = <T extends object>({
).map((headerGroup) => (
<Tr key={headerGroup.id}>
{headerGroup.headers.map((header) => {
- const sortable = "accessorKey" in header.column.columnDef;
+ const sortable =
+ withSimpleSorting &&
+ "accessorKey" in header.column.columnDef;
const sorted = isSorted(
// @ts-ignore
header.column.columnDef?.accessorKey ?? ""
diff --git a/apps/carbon/app/components/Data/Table/components/Actions/Actions.tsx b/apps/carbon/app/components/Table/components/Actions/Actions.tsx
similarity index 100%
rename from apps/carbon/app/components/Data/Table/components/Actions/Actions.tsx
rename to apps/carbon/app/components/Table/components/Actions/Actions.tsx
diff --git a/apps/carbon/app/components/Data/Table/components/Actions/index.ts b/apps/carbon/app/components/Table/components/Actions/index.ts
similarity index 100%
rename from apps/carbon/app/components/Data/Table/components/Actions/index.ts
rename to apps/carbon/app/components/Table/components/Actions/index.ts
diff --git a/apps/carbon/app/components/Data/Table/components/Columns/Columns.tsx b/apps/carbon/app/components/Table/components/Columns/Columns.tsx
similarity index 100%
rename from apps/carbon/app/components/Data/Table/components/Columns/Columns.tsx
rename to apps/carbon/app/components/Table/components/Columns/Columns.tsx
diff --git a/apps/carbon/app/components/Data/Table/components/Columns/index.ts b/apps/carbon/app/components/Table/components/Columns/index.ts
similarity index 100%
rename from apps/carbon/app/components/Data/Table/components/Columns/index.ts
rename to apps/carbon/app/components/Table/components/Columns/index.ts
diff --git a/apps/carbon/app/components/Data/Table/components/Filter/Filter.tsx b/apps/carbon/app/components/Table/components/Filter/Filter.tsx
similarity index 100%
rename from apps/carbon/app/components/Data/Table/components/Filter/Filter.tsx
rename to apps/carbon/app/components/Table/components/Filter/Filter.tsx
diff --git a/apps/carbon/app/components/Data/Table/components/Filter/FilterRow.tsx b/apps/carbon/app/components/Table/components/Filter/FilterRow.tsx
similarity index 100%
rename from apps/carbon/app/components/Data/Table/components/Filter/FilterRow.tsx
rename to apps/carbon/app/components/Table/components/Filter/FilterRow.tsx
diff --git a/apps/carbon/app/components/Data/Table/components/Filter/index.ts b/apps/carbon/app/components/Table/components/Filter/index.ts
similarity index 100%
rename from apps/carbon/app/components/Data/Table/components/Filter/index.ts
rename to apps/carbon/app/components/Table/components/Filter/index.ts
diff --git a/apps/carbon/app/components/Data/Table/components/Header/Header.tsx b/apps/carbon/app/components/Table/components/Header/Header.tsx
similarity index 89%
rename from apps/carbon/app/components/Data/Table/components/Header/Header.tsx
rename to apps/carbon/app/components/Table/components/Header/Header.tsx
index 679f6bfa8b..3e42570658 100644
--- a/apps/carbon/app/components/Data/Table/components/Header/Header.tsx
+++ b/apps/carbon/app/components/Table/components/Header/Header.tsx
@@ -18,6 +18,7 @@ type HeaderProps<T> = {
selectedRows: T[];
setColumnOrder: (newOrder: ColumnOrderState) => void;
withColumnOrdering: boolean;
+ withFilters: boolean;
withPagination: boolean;
withSelectableRows: boolean;
};
@@ -31,6 +32,7 @@ const Header = <T extends object>({
selectedRows,
setColumnOrder,
withColumnOrdering,
+ withFilters,
withPagination,
withSelectableRows,
}: HeaderProps<T>) => {
@@ -52,8 +54,12 @@ const Header = <T extends object>({
)}
</HStack>
<HStack spacing={2}>
- <Filter columnAccessors={columnAccessors} />
- <Sort columnAccessors={columnAccessors} />
+ {withFilters && (
+ <>
+ <Filter columnAccessors={columnAccessors} />
+ <Sort columnAccessors={columnAccessors} />
+ </>
+ )}
{withColumnOrdering && (
<Columns
diff --git a/apps/carbon/app/components/Data/Table/components/Header/index.ts b/apps/carbon/app/components/Table/components/Header/index.ts
similarity index 100%
rename from apps/carbon/app/components/Data/Table/components/Header/index.ts
rename to apps/carbon/app/components/Table/components/Header/index.ts
diff --git a/apps/carbon/app/components/Data/Table/components/IndeterminateCheckbox/IndeterminateCheckbox.tsx b/apps/carbon/app/components/Table/components/IndeterminateCheckbox/IndeterminateCheckbox.tsx
similarity index 76%
rename from apps/carbon/app/components/Data/Table/components/IndeterminateCheckbox/IndeterminateCheckbox.tsx
rename to apps/carbon/app/components/Table/components/IndeterminateCheckbox/IndeterminateCheckbox.tsx
index 55f1acc8c7..864d90e2ff 100644
--- a/apps/carbon/app/components/Data/Table/components/IndeterminateCheckbox/IndeterminateCheckbox.tsx
+++ b/apps/carbon/app/components/Table/components/IndeterminateCheckbox/IndeterminateCheckbox.tsx
@@ -1,4 +1,4 @@
-import { Checkbox } from "@chakra-ui/react";
+import { Checkbox, VisuallyHidden } from "@chakra-ui/react";
type IndeterminateCheckboxProps = {
checked: boolean;
@@ -13,12 +13,13 @@ const IndeterminateCheckbox = ({
}: IndeterminateCheckboxProps) => {
return (
<Checkbox
- colorScheme="blackAlpha"
isChecked={checked}
isIndeterminate={indeterminate}
ml={2}
{...rest}
- />
+ >
+ <VisuallyHidden>Select Row</VisuallyHidden>
+ </Checkbox>
);
};
diff --git a/apps/carbon/app/components/Data/Table/components/IndeterminateCheckbox/index.ts b/apps/carbon/app/components/Table/components/IndeterminateCheckbox/index.ts
similarity index 100%
rename from apps/carbon/app/components/Data/Table/components/IndeterminateCheckbox/index.ts
rename to apps/carbon/app/components/Table/components/IndeterminateCheckbox/index.ts
diff --git a/apps/carbon/app/components/Data/Table/components/Pagination/Pagination.tsx b/apps/carbon/app/components/Table/components/Pagination/Pagination.tsx
similarity index 96%
rename from apps/carbon/app/components/Data/Table/components/Pagination/Pagination.tsx
rename to apps/carbon/app/components/Table/components/Pagination/Pagination.tsx
index c306c2e308..1d8998c607 100644
--- a/apps/carbon/app/components/Data/Table/components/Pagination/Pagination.tsx
+++ b/apps/carbon/app/components/Table/components/Pagination/Pagination.tsx
@@ -109,7 +109,8 @@ export const PaginationButtons = ({
) : (
<>
<Flex fontSize="sm" h={8} fontWeight="medium" alignItems="center">
- {offset + 1} - {Math.min(offset + pageSize, count)} of {count}
+ {count > 0 ? offset + 1 : 0} - {Math.min(offset + pageSize, count)}{" "}
+ of {count}
</Flex>
<Button
disabled={!canPreviousPage}
diff --git a/apps/carbon/app/components/Data/Table/components/Pagination/index.ts b/apps/carbon/app/components/Table/components/Pagination/index.ts
similarity index 100%
rename from apps/carbon/app/components/Data/Table/components/Pagination/index.ts
rename to apps/carbon/app/components/Table/components/Pagination/index.ts
diff --git a/apps/carbon/app/components/Data/Table/components/Pagination/usePagination.tsx b/apps/carbon/app/components/Table/components/Pagination/usePagination.tsx
similarity index 100%
rename from apps/carbon/app/components/Data/Table/components/Pagination/usePagination.tsx
rename to apps/carbon/app/components/Table/components/Pagination/usePagination.tsx
diff --git a/apps/carbon/app/components/Data/Table/components/Sort/Sort.tsx b/apps/carbon/app/components/Table/components/Sort/Sort.tsx
similarity index 98%
rename from apps/carbon/app/components/Data/Table/components/Sort/Sort.tsx
rename to apps/carbon/app/components/Table/components/Sort/Sort.tsx
index 07311618cb..61effb563e 100644
--- a/apps/carbon/app/components/Data/Table/components/Sort/Sort.tsx
+++ b/apps/carbon/app/components/Table/components/Sort/Sort.tsx
@@ -86,7 +86,6 @@ const Sort = ({ columnAccessors }: SortProps) => {
<>{columnAccessors[column] ?? ""}</>
</Text>
<Switch
- colorScheme="blackAlpha"
isChecked={direction === "asc"}
onChange={() => toggleSortByDirection(column)}
/>
diff --git a/apps/carbon/app/components/Data/Table/components/Sort/index.ts b/apps/carbon/app/components/Table/components/Sort/index.ts
similarity index 100%
rename from apps/carbon/app/components/Data/Table/components/Sort/index.ts
rename to apps/carbon/app/components/Table/components/Sort/index.ts
diff --git a/apps/carbon/app/components/Data/Table/components/Sort/useSort.tsx b/apps/carbon/app/components/Table/components/Sort/useSort.tsx
similarity index 100%
rename from apps/carbon/app/components/Data/Table/components/Sort/useSort.tsx
rename to apps/carbon/app/components/Table/components/Sort/useSort.tsx
diff --git a/apps/carbon/app/components/Data/Table/components/index.ts b/apps/carbon/app/components/Table/components/index.ts
similarity index 100%
rename from apps/carbon/app/components/Data/Table/components/index.ts
rename to apps/carbon/app/components/Table/components/index.ts
diff --git a/apps/carbon/app/components/Data/Table/index.ts b/apps/carbon/app/components/Table/index.ts
similarity index 100%
rename from apps/carbon/app/components/Data/Table/index.ts
rename to apps/carbon/app/components/Table/index.ts
diff --git a/apps/carbon/app/components/Data/Table/types.ts b/apps/carbon/app/components/Table/types.ts
similarity index 100%
rename from apps/carbon/app/components/Data/Table/types.ts
rename to apps/carbon/app/components/Table/types.ts
diff --git a/apps/carbon/app/components/index.ts b/apps/carbon/app/components/index.ts
new file mode 100644
index 0000000000..3fce9611b7
--- /dev/null
+++ b/apps/carbon/app/components/index.ts
@@ -0,0 +1,4 @@
+import Avatar from "./Avatar";
+import Table from "./Table";
+
+export { Avatar, Table };
diff --git a/apps/carbon/app/hooks/usePermissions.tsx b/apps/carbon/app/hooks/usePermissions.tsx
index 955b352936..3e50dd119b 100644
--- a/apps/carbon/app/hooks/usePermissions.tsx
+++ b/apps/carbon/app/hooks/usePermissions.tsx
@@ -1,5 +1,5 @@
import { useCallback } from "react";
-import type { Permission } from "~/modules/Users/types";
+import type { Permission } from "~/interfaces/Users/types";
import { useRouteData } from "./useRouteData";
export function usePermissions() {
diff --git a/apps/carbon/app/hooks/useUser.tsx b/apps/carbon/app/hooks/useUser.tsx
index f654ec6426..b1744aeeb7 100644
--- a/apps/carbon/app/hooks/useUser.tsx
+++ b/apps/carbon/app/hooks/useUser.tsx
@@ -1,6 +1,7 @@
import { useRouteData } from "./useRouteData";
type User = {
+ id: string;
email: string;
firstName: string;
lastName: string;
@@ -20,6 +21,7 @@ export function useUser() {
function isUser(value: any): value is User {
return (
+ typeof value.id === "string" &&
typeof value.email === "string" &&
typeof value.firstName === "string" &&
typeof value.lastName === "string" &&
diff --git a/apps/carbon/app/modules/Account/Password/PasswordForm/PasswordForm.tsx b/apps/carbon/app/interfaces/Account/Password/PasswordForm/PasswordForm.tsx
similarity index 96%
rename from apps/carbon/app/modules/Account/Password/PasswordForm/PasswordForm.tsx
rename to apps/carbon/app/interfaces/Account/Password/PasswordForm/PasswordForm.tsx
index ed7ba16379..6e267909e2 100644
--- a/apps/carbon/app/modules/Account/Password/PasswordForm/PasswordForm.tsx
+++ b/apps/carbon/app/interfaces/Account/Password/PasswordForm/PasswordForm.tsx
@@ -1,4 +1,4 @@
-import { Box, Heading, Text, VStack } from "@chakra-ui/react";
+import { Box, VStack } from "@chakra-ui/react";
import { useRef, useState } from "react";
import { ValidatedForm } from "remix-validated-form";
import { Password, Submit } from "~/components/Form";
diff --git a/apps/carbon/app/modules/Account/Password/PasswordForm/index.ts b/apps/carbon/app/interfaces/Account/Password/PasswordForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Account/Password/PasswordForm/index.ts
rename to apps/carbon/app/interfaces/Account/Password/PasswordForm/index.ts
diff --git a/apps/carbon/app/modules/Account/Password/index.ts b/apps/carbon/app/interfaces/Account/Password/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Account/Password/index.ts
rename to apps/carbon/app/interfaces/Account/Password/index.ts
diff --git a/apps/carbon/app/modules/Account/Personal/PersonalDataForm/PersonalDataForm.tsx b/apps/carbon/app/interfaces/Account/Personal/PersonalDataForm/PersonalDataForm.tsx
similarity index 92%
rename from apps/carbon/app/modules/Account/Personal/PersonalDataForm/PersonalDataForm.tsx
rename to apps/carbon/app/interfaces/Account/Personal/PersonalDataForm/PersonalDataForm.tsx
index 2ef8720eb1..e16042d755 100644
--- a/apps/carbon/app/modules/Account/Personal/PersonalDataForm/PersonalDataForm.tsx
+++ b/apps/carbon/app/interfaces/Account/Personal/PersonalDataForm/PersonalDataForm.tsx
@@ -1,7 +1,7 @@
import { Box, Grid, VStack } from "@chakra-ui/react";
import { ValidatedForm } from "remix-validated-form";
import { Submit } from "~/components/Form";
-import type { PersonalData } from "~/modules/Account/types";
+import type { PersonalData } from "~/interfaces/Account/types";
import { accountPersonalDataValidator } from "~/services/account";
type PersonalDataFormProps = {
diff --git a/apps/carbon/app/modules/Account/Personal/PersonalDataForm/index.ts b/apps/carbon/app/interfaces/Account/Personal/PersonalDataForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Account/Personal/PersonalDataForm/index.ts
rename to apps/carbon/app/interfaces/Account/Personal/PersonalDataForm/index.ts
diff --git a/apps/carbon/app/modules/Account/Personal/index.ts b/apps/carbon/app/interfaces/Account/Personal/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Account/Personal/index.ts
rename to apps/carbon/app/interfaces/Account/Personal/index.ts
diff --git a/apps/carbon/app/modules/Account/Profile/ProfileForm/ProfileForm.tsx b/apps/carbon/app/interfaces/Account/Profile/ProfileForm/ProfileForm.tsx
similarity index 83%
rename from apps/carbon/app/modules/Account/Profile/ProfileForm/ProfileForm.tsx
rename to apps/carbon/app/interfaces/Account/Profile/ProfileForm/ProfileForm.tsx
index 41ebc047a3..0d4d7a991a 100644
--- a/apps/carbon/app/modules/Account/Profile/ProfileForm/ProfileForm.tsx
+++ b/apps/carbon/app/interfaces/Account/Profile/ProfileForm/ProfileForm.tsx
@@ -1,7 +1,8 @@
import { Box, Grid, VStack } from "@chakra-ui/react";
import { ValidatedForm } from "remix-validated-form";
import { Hidden, Input, Submit, TextArea } from "~/components/Form";
-import type { User } from "~/modules/Users/types";
+import { SectionTitle } from "~/components/Layout";
+import type { User } from "~/interfaces/Users/types";
import { accountProfileValidator } from "~/services/account";
type ProfileFormProps = {
@@ -11,6 +12,7 @@ type ProfileFormProps = {
const ProfileForm = ({ user }: ProfileFormProps) => {
return (
<Box w="full">
+ <SectionTitle title="Basic Information" />
<ValidatedForm
method="post"
action="/app/account/profile"
@@ -24,7 +26,7 @@ const ProfileForm = ({ user }: ProfileFormProps) => {
</Grid>
<TextArea name="about" label="About" characterLimit={160} my={2} />
<Hidden name="intent" value="about" />
- <Submit>Save</Submit>
+ <Submit size="sm">Save</Submit>
</VStack>
</ValidatedForm>
</Box>
diff --git a/apps/carbon/app/modules/Account/Profile/ProfileForm/index.ts b/apps/carbon/app/interfaces/Account/Profile/ProfileForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Account/Profile/ProfileForm/index.ts
rename to apps/carbon/app/interfaces/Account/Profile/ProfileForm/index.ts
diff --git a/apps/carbon/app/modules/Account/Profile/ProfilePhotoForm/ProfilePhotoForm.tsx b/apps/carbon/app/interfaces/Account/Profile/ProfilePhotoForm/ProfilePhotoForm.tsx
similarity index 93%
rename from apps/carbon/app/modules/Account/Profile/ProfilePhotoForm/ProfilePhotoForm.tsx
rename to apps/carbon/app/interfaces/Account/Profile/ProfilePhotoForm/ProfilePhotoForm.tsx
index 6e5bce9263..279a5993e3 100644
--- a/apps/carbon/app/modules/Account/Profile/ProfilePhotoForm/ProfilePhotoForm.tsx
+++ b/apps/carbon/app/interfaces/Account/Profile/ProfilePhotoForm/ProfilePhotoForm.tsx
@@ -3,9 +3,9 @@ import { Button, Input, InputGroup, VStack } from "@chakra-ui/react";
import { useSubmit } from "@remix-run/react";
import type { ChangeEvent } from "react";
import { useRef } from "react";
-import { Avatar } from "~/components/Avatar";
+import { Avatar } from "~/components";
import { useSupabase } from "~/lib/supabase";
-import type { Account } from "~/modules/Account/types";
+import type { Account } from "~/interfaces/Account/types";
type ProfilePhotoFormProps = {
user: Account;
@@ -78,7 +78,6 @@ const ProfilePhotoForm = ({ user }: ProfilePhotoFormProps) => {
onChange={uploadImage}
/>
<Button
- size="md"
variant="solid"
colorScheme="brand"
onClick={() => {
@@ -89,7 +88,7 @@ const ProfilePhotoForm = ({ user }: ProfilePhotoFormProps) => {
</Button>
</InputGroup>
{user.avatarUrl && (
- <Button size="md" variant="outline" onClick={deleteImage}>
+ <Button variant="outline" onClick={deleteImage}>
Remove
</Button>
)}
diff --git a/apps/carbon/app/modules/Account/Profile/ProfilePhotoForm/index.ts b/apps/carbon/app/interfaces/Account/Profile/ProfilePhotoForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Account/Profile/ProfilePhotoForm/index.ts
rename to apps/carbon/app/interfaces/Account/Profile/ProfilePhotoForm/index.ts
diff --git a/apps/carbon/app/modules/Account/Profile/index.ts b/apps/carbon/app/interfaces/Account/Profile/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Account/Profile/index.ts
rename to apps/carbon/app/interfaces/Account/Profile/index.ts
diff --git a/apps/carbon/app/interfaces/Account/UserAttributes/UserAttributesForm.tsx b/apps/carbon/app/interfaces/Account/UserAttributes/UserAttributesForm.tsx
new file mode 100644
index 0000000000..7f2bcaa6d9
--- /dev/null
+++ b/apps/carbon/app/interfaces/Account/UserAttributes/UserAttributesForm.tsx
@@ -0,0 +1,659 @@
+import { useColor } from "@carbon/react";
+import {
+ Box,
+ Button,
+ Grid,
+ HStack,
+ Switch,
+ Text,
+ useDisclosure,
+ VStack,
+} from "@chakra-ui/react";
+import { parseDate } from "@internationalized/date";
+import { useFetcher } from "@remix-run/react";
+import { useState } from "react";
+import { ValidatedForm } from "remix-validated-form";
+import {
+ Boolean as BooleanInput,
+ DatePicker,
+ Input,
+ Hidden,
+ Number as NumberInput,
+ Submit,
+ User,
+ Select,
+} from "~/components/Form";
+import { SectionTitle } from "~/components/Layout";
+import { UserSelect } from "~/components/Selectors";
+import { useUser } from "~/hooks";
+import type { PublicAttributes } from "~/interfaces/Account/types";
+import { DataType } from "~/interfaces/Users/types";
+import {
+ attributeBooleanValidator,
+ attributeNumericValidator,
+ attributeTextValidator,
+ attributeUserValidator,
+ deleteUserAttributeValueValidator,
+} from "~/services/account";
+
+type UserAttributesFormProps = {
+ attributeCategory?: PublicAttributes;
+};
+
+const UserAttributesForm = ({ attributeCategory }: UserAttributesFormProps) => {
+ const user = useUser();
+ const updateFetcher = useFetcher<{}>();
+ const [optimisticUpdates, setOptimisticUpdates] = useState<
+ Record<number, boolean | string | number>
+ >({});
+
+ if (
+ !attributeCategory ||
+ !attributeCategory.userAttribute ||
+ !Array.isArray(attributeCategory.userAttribute) ||
+ attributeCategory.userAttribute.length === 0
+ )
+ return null;
+
+ return (
+ <Box w="full">
+ <SectionTitle title={attributeCategory.name} mt={8} />
+ <VStack alignItems="start" my={4} w="full" spacing={4}>
+ {attributeCategory.userAttribute.map((attribute) => {
+ const genericProps = getGenericProps(
+ attribute,
+ optimisticUpdates[attribute.id]
+ );
+
+ return (
+ <GenericAttributeRow
+ key={attribute.id}
+ attribute={attribute}
+ setOptimisticUpdate={(value: boolean | string | number) =>
+ setOptimisticUpdates((prev) => ({
+ ...prev,
+ [attribute.id]: value,
+ }))
+ }
+ // @ts-ignore
+ updateFetcher={updateFetcher}
+ userId={user.id}
+ {...genericProps}
+ />
+ );
+ })}
+ </VStack>
+ </Box>
+ );
+};
+
+type GenericAttributeRowProps = {
+ attribute: {
+ id: number | null;
+ name: string | null;
+ canSelfManage: boolean | null;
+ listOptions: string[] | null;
+ };
+ displayValue: string | number | boolean;
+ type: DataType;
+ updateFetcher: ReturnType<typeof useFetcher>;
+ userAttributeId: number;
+ userAttributeValueId?: number;
+ userId: string;
+ value: Date | string | number | boolean | null;
+ setOptimisticUpdate: (value: boolean | string | number) => void;
+};
+
+const GenericAttributeRow = (props: GenericAttributeRowProps) => {
+ const editing = useDisclosure();
+ const onSubmit = (value: string | boolean | number) => {
+ props.setOptimisticUpdate(value);
+ editing.onClose();
+ };
+
+ return (
+ <Box key={props.attribute.id} w="full">
+ {editing.isOpen
+ ? TypedForm({ ...props, onSubmit, onClose: editing.onClose })
+ : TypedDisplay({ ...props, onOpen: editing.onOpen })}
+ </Box>
+ );
+};
+
+function renderTypedForm({
+ attribute,
+ borderColor,
+ type,
+ value,
+ updateFetcher,
+ userAttributeId,
+ userAttributeValueId,
+ userId,
+ onSubmit,
+ onClose,
+}: GenericAttributeRowProps & {
+ borderColor: string;
+ userId: string;
+ onSubmit: (value: string | boolean | number) => void;
+ onClose: () => void;
+}) {
+ switch (type) {
+ case DataType.Boolean:
+ return (
+ <ValidatedForm
+ method="post"
+ action={`/app/account/${userId}/attribute`}
+ validator={attributeBooleanValidator}
+ defaultValues={{
+ userAttributeId,
+ userAttributeValueId,
+ value: value === true,
+ }}
+ fetcher={updateFetcher}
+ onSubmit={(data) => onSubmit(data.value)}
+ >
+ <Grid
+ gridTemplateColumns="1fr 2fr 1fr"
+ borderTopColor={borderColor}
+ borderTopStyle="solid"
+ borderTopWidth={1}
+ pt={3}
+ w="full"
+ >
+ <Text color="gray.500" alignSelf="center">
+ {attribute.name}
+ </Text>
+ <Box>
+ <Hidden name="type" value="boolean" />
+ <Hidden name="userAttributeId" />
+ <Hidden name="userAttributeValueId" />
+ <BooleanInput name="value" />
+ </Box>
+ <HStack justifyContent="end" w="full" alignSelf="center">
+ <Submit size="sm" type="submit">
+ Save
+ </Submit>
+ <Button variant="ghost" onClick={onClose}>
+ Cancel
+ </Button>
+ </HStack>
+ </Grid>
+ </ValidatedForm>
+ );
+ case DataType.Date:
+ return (
+ <ValidatedForm
+ method="post"
+ action={`/app/account/${userId}/attribute`}
+ validator={attributeTextValidator}
+ defaultValues={{
+ userAttributeId,
+ userAttributeValueId,
+ value: value?.toString(),
+ }}
+ fetcher={updateFetcher}
+ onSubmit={(data) => onSubmit(data.value)}
+ >
+ <Grid
+ gridTemplateColumns="1fr 2fr 1fr"
+ borderTopColor={borderColor}
+ borderTopStyle="solid"
+ borderTopWidth={1}
+ pt={3}
+ w="full"
+ >
+ <Text color="gray.500" alignSelf="center">
+ {attribute.name}
+ </Text>
+ <Box>
+ <Hidden name="type" value="date" />
+ <Hidden name="userAttributeId" />
+ <Hidden name="userAttributeValueId" />
+ <DatePicker name="value" />
+ </Box>
+ <HStack justifyContent="end" w="full" alignSelf="center">
+ <Submit size="sm" type="submit">
+ Save
+ </Submit>
+ <Button variant="ghost" onClick={onClose}>
+ Cancel
+ </Button>
+ </HStack>
+ </Grid>
+ </ValidatedForm>
+ );
+ case DataType.List:
+ return (
+ <ValidatedForm
+ method="post"
+ action={`/app/account/${userId}/attribute`}
+ validator={attributeTextValidator}
+ defaultValues={{
+ userAttributeId,
+ userAttributeValueId,
+ value: value?.toString(),
+ }}
+ fetcher={updateFetcher}
+ onSubmit={(data) => onSubmit(data.value)}
+ >
+ <Grid
+ gridTemplateColumns="1fr 2fr 1fr"
+ borderTopColor={borderColor}
+ borderTopStyle="solid"
+ borderTopWidth={1}
+ pt={3}
+ w="full"
+ >
+ <Text color="gray.500" alignSelf="center">
+ {attribute.name}
+ </Text>
+ <Box>
+ <Hidden name="type" value="list" />
+ <Hidden name="userAttributeId" />
+ <Hidden name="userAttributeValueId" />
+ <Select
+ name="value"
+ options={
+ attribute.listOptions?.map((option) => ({
+ label: option,
+ value: option,
+ })) ?? []
+ }
+ />
+ </Box>
+ <HStack justifyContent="end" w="full" alignSelf="center">
+ <Submit size="sm" type="submit">
+ Save
+ </Submit>
+ <Button variant="ghost" onClick={onClose}>
+ Cancel
+ </Button>
+ </HStack>
+ </Grid>
+ </ValidatedForm>
+ );
+ case DataType.Numeric:
+ return (
+ <ValidatedForm
+ method="post"
+ action={`/app/account/${userId}/attribute`}
+ validator={attributeNumericValidator}
+ defaultValues={{
+ userAttributeId,
+ userAttributeValueId,
+ value: value ? Number(value) : undefined,
+ }}
+ fetcher={updateFetcher}
+ onSubmit={(data) => onSubmit(data.value)}
+ >
+ <Grid
+ gridTemplateColumns="1fr 2fr 1fr"
+ borderTopColor={borderColor}
+ borderTopStyle="solid"
+ borderTopWidth={1}
+ pt={3}
+ w="full"
+ >
+ <Text color="gray.500" alignSelf="center">
+ {attribute.name}
+ </Text>
+ <Box>
+ <Hidden name="type" value="numeric" />
+ <Hidden name="userAttributeId" />
+ <Hidden name="userAttributeValueId" />
+ <NumberInput name="value" />
+ </Box>
+ <HStack justifyContent="end" w="full" alignSelf="center">
+ <Submit size="sm" type="submit">
+ Save
+ </Submit>
+ <Button variant="ghost" onClick={onClose}>
+ Cancel
+ </Button>
+ </HStack>
+ </Grid>
+ </ValidatedForm>
+ );
+ case DataType.Text:
+ return (
+ <ValidatedForm
+ method="post"
+ action={`/app/account/${userId}/attribute`}
+ validator={attributeTextValidator}
+ defaultValues={{
+ userAttributeId,
+ userAttributeValueId,
+ value: value?.toString(),
+ }}
+ fetcher={updateFetcher}
+ onSubmit={(data) => onSubmit(data.value)}
+ >
+ <Grid
+ gridTemplateColumns="1fr 2fr 1fr"
+ borderTopColor={borderColor}
+ borderTopStyle="solid"
+ borderTopWidth={1}
+ pt={3}
+ w="full"
+ >
+ <Text color="gray.500" alignSelf="center">
+ {attribute.name}
+ </Text>
+ <Box>
+ <Hidden name="type" value="text" />
+ <Hidden name="userAttributeId" />
+ <Hidden name="userAttributeValueId" />
+ <Input name="value" />
+ </Box>
+ <HStack justifyContent="end" w="full" alignSelf="center">
+ <Submit size="sm" type="submit">
+ Save
+ </Submit>
+ <Button variant="ghost" onClick={onClose}>
+ Cancel
+ </Button>
+ </HStack>
+ </Grid>
+ </ValidatedForm>
+ );
+ case DataType.User:
+ return (
+ <ValidatedForm
+ method="post"
+ action={`/app/account/${userId}/attribute`}
+ validator={attributeUserValidator}
+ defaultValues={{
+ userAttributeId,
+ userAttributeValueId,
+ value: value?.toString(),
+ }}
+ fetcher={updateFetcher}
+ onSubmit={(data) => onSubmit(data.value)}
+ >
+ <Grid
+ gridTemplateColumns="1fr 2fr 1fr"
+ borderTopColor={borderColor}
+ borderTopStyle="solid"
+ borderTopWidth={1}
+ pt={3}
+ w="full"
+ >
+ <Text color="gray.500" alignSelf="center">
+ {attribute.name}
+ </Text>
+ <Box>
+ <Hidden name="type" value="user" />
+ <Hidden name="userAttributeId" />
+ <Hidden name="userAttributeValueId" />
+ <User name="value" />
+ </Box>
+ <HStack justifyContent="end" w="full" alignSelf="center">
+ <Submit size="sm" type="submit">
+ Save
+ </Submit>
+ <Button variant="ghost" onClick={onClose}>
+ Cancel
+ </Button>
+ </HStack>
+ </Grid>
+ </ValidatedForm>
+ );
+ default:
+ return (
+ <Box bg="red.100" color="red.800" p={4} w="full">
+ Unknown data type
+ </Box>
+ );
+ }
+}
+
+function TypedForm(
+ props: GenericAttributeRowProps & {
+ onSubmit: (value: string | boolean | number) => void;
+ onClose: () => void;
+ }
+) {
+ const borderColor = useColor("gray.100");
+ return renderTypedForm({ ...props, borderColor });
+}
+
+function renderTypedDisplay({
+ borderColor,
+ ...props
+}: GenericAttributeRowProps & { borderColor: string; onOpen: () => void }) {
+ const { attribute, displayValue, type, userAttributeValueId, value, onOpen } =
+ props;
+ switch (type) {
+ case DataType.Boolean:
+ return (
+ <Grid
+ gridTemplateColumns="1fr 2fr 1fr"
+ borderTopColor={borderColor}
+ borderTopStyle="solid"
+ borderTopWidth={1}
+ pt={3}
+ w="full"
+ >
+ <Text color="gray.500" alignSelf="center">
+ {attribute.name}
+ </Text>
+ {displayValue === "N/A" ? (
+ <Text alignSelf="center">{displayValue}</Text>
+ ) : (
+ <Switch isReadOnly isChecked={displayValue === true} />
+ )}
+ <HStack justifyContent="end" w="full" alignSelf="center">
+ <Button
+ isDisabled={!attribute.canSelfManage ?? true}
+ variant="ghost"
+ onClick={onOpen}
+ >
+ Update
+ </Button>
+ </HStack>
+ </Grid>
+ );
+ case DataType.Date:
+ case DataType.List:
+ case DataType.Text:
+ return (
+ <Grid
+ gridTemplateColumns="1fr 2fr 1fr"
+ borderTopColor={borderColor}
+ borderTopStyle="solid"
+ borderTopWidth={1}
+ pt={3}
+ w="full"
+ >
+ <Text color="gray.500" alignSelf="center">
+ {attribute.name}
+ </Text>
+ <Text alignSelf="center">{displayValue}</Text>
+ <UpdateRemoveButtons
+ canRemove={
+ attribute.canSelfManage === true &&
+ !!value &&
+ !!userAttributeValueId
+ }
+ canUpdate={attribute.canSelfManage ?? false}
+ {...props}
+ />
+ </Grid>
+ );
+ case DataType.Numeric:
+ return (
+ <Grid
+ gridTemplateColumns="1fr 2fr 1fr"
+ borderTopColor={borderColor}
+ borderTopStyle="solid"
+ borderTopWidth={1}
+ pt={3}
+ w="full"
+ >
+ <Text color="gray.500" alignSelf="center">
+ {attribute.name}
+ </Text>
+ <Text alignSelf="center">{displayValue.toLocaleString("en-US")}</Text>
+ <UpdateRemoveButtons
+ canRemove={attribute.canSelfManage === true && !!value}
+ canUpdate={attribute.canSelfManage ?? false}
+ {...props}
+ />
+ </Grid>
+ );
+ case DataType.User:
+ return (
+ <Grid
+ gridTemplateColumns="1fr 2fr 1fr"
+ borderTopColor={borderColor}
+ borderTopStyle="solid"
+ borderTopWidth={1}
+ pt={3}
+ w="full"
+ >
+ <Text color="gray.500" alignSelf="center">
+ {attribute.name}
+ </Text>
+ {value ? (
+ <UserSelect disabled value={value.toString()} />
+ ) : (
+ <Text alignSelf="center">{displayValue}</Text>
+ )}
+
+ <UpdateRemoveButtons
+ canRemove={attribute.canSelfManage === true && !!value}
+ canUpdate={attribute.canSelfManage ?? false}
+ {...props}
+ />
+ </Grid>
+ );
+ }
+}
+
+function TypedDisplay(
+ props: GenericAttributeRowProps & {
+ onOpen: () => void;
+ }
+) {
+ const borderColor = useColor("gray.100");
+ return renderTypedDisplay({ ...props, borderColor });
+}
+
+function getGenericProps(
+ attribute: NonNullable<PublicAttributes["userAttribute"]>,
+ optimisticUpdate: string | boolean | number | undefined
+) {
+ if (
+ !("attributeDataType" in attribute) ||
+ !attribute.attributeDataType ||
+ Array.isArray(attribute.attributeDataType)
+ )
+ throw new Error("Missing attributeDataType");
+
+ const type = attribute.attributeDataType.id;
+ const userAttributeId = attribute.id;
+ let userAttributeValueId = undefined;
+
+ let displayValue: string | number | boolean = "N/A";
+ let value: string | number | boolean | Date | null = null;
+
+ if (
+ attribute.userAttributeValue &&
+ Array.isArray(attribute.userAttributeValue) &&
+ attribute.userAttributeValue.length === 1
+ ) {
+ const userAttributeValue = attribute.userAttributeValue[0];
+ userAttributeValueId = userAttributeValue.id;
+
+ switch (type) {
+ case DataType.Boolean:
+ value = userAttributeValue.valueBoolean;
+ displayValue = userAttributeValue.valueBoolean ?? false;
+ break;
+ case DataType.Date:
+ value = userAttributeValue.valueDate;
+ if (userAttributeValue.valueDate)
+ displayValue = parseDate(userAttributeValue.valueDate).toString();
+ break;
+ case DataType.List:
+ value = userAttributeValue.valueText;
+ if (userAttributeValue.valueText)
+ displayValue = userAttributeValue.valueText;
+ break;
+ case DataType.Numeric:
+ value = userAttributeValue.valueNumeric;
+ if (userAttributeValue.valueNumeric)
+ displayValue = Number(userAttributeValue.valueNumeric);
+ break;
+ case DataType.Text:
+ value = userAttributeValue.valueText;
+ if (userAttributeValue.valueText)
+ displayValue = userAttributeValue.valueText;
+ break;
+ case DataType.User:
+ value = userAttributeValue.valueUser;
+ if (userAttributeValue.valueUser)
+ displayValue = userAttributeValue.valueUser;
+ }
+ }
+
+ if (optimisticUpdate !== undefined) {
+ displayValue = optimisticUpdate;
+ value = optimisticUpdate;
+ }
+
+ return {
+ displayValue,
+ type,
+ userAttributeId,
+ userAttributeValueId,
+ value,
+ };
+}
+
+function UpdateRemoveButtons({
+ canRemove,
+ canUpdate,
+ updateFetcher,
+ userId,
+ userAttributeId,
+ userAttributeValueId,
+ onOpen,
+}: {
+ canRemove: boolean;
+ canUpdate: boolean;
+ updateFetcher: ReturnType<typeof useFetcher>;
+ userId: string;
+ userAttributeId: number;
+ userAttributeValueId?: number;
+ onOpen: () => void;
+}) {
+ return (
+ <HStack justifyContent="end" w="full" alignSelf="center">
+ {userAttributeValueId && (
+ <ValidatedForm
+ method="post"
+ action={`/app/account/${userId}/delete/attribute`}
+ validator={deleteUserAttributeValueValidator}
+ defaultValues={{
+ userAttributeId,
+ userAttributeValueId,
+ }}
+ fetcher={updateFetcher}
+ >
+ <Hidden name="userAttributeId" />
+ <Hidden name="userAttributeValueId" />
+ <Button isDisabled={!canRemove} variant="ghost" type="submit">
+ Remove
+ </Button>
+ </ValidatedForm>
+ )}
+
+ <Button isDisabled={!canUpdate} variant="ghost" onClick={onOpen}>
+ Update
+ </Button>
+ </HStack>
+ );
+}
+
+export default UserAttributesForm;
diff --git a/apps/carbon/app/interfaces/Account/UserAttributes/index.ts b/apps/carbon/app/interfaces/Account/UserAttributes/index.ts
new file mode 100644
index 0000000000..7fc16d76a2
--- /dev/null
+++ b/apps/carbon/app/interfaces/Account/UserAttributes/index.ts
@@ -0,0 +1,3 @@
+import UserAttributesForm from "./UserAttributesForm";
+
+export { UserAttributesForm };
diff --git a/apps/carbon/app/modules/Account/index.ts b/apps/carbon/app/interfaces/Account/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Account/index.ts
rename to apps/carbon/app/interfaces/Account/index.ts
diff --git a/apps/carbon/app/interfaces/Account/types.ts b/apps/carbon/app/interfaces/Account/types.ts
new file mode 100644
index 0000000000..a734ca0a9e
--- /dev/null
+++ b/apps/carbon/app/interfaces/Account/types.ts
@@ -0,0 +1,13 @@
+import type { getAccount, getPublicAttributes } from "~/services/account";
+
+export type Account = NonNullable<
+ Awaited<ReturnType<typeof getAccount>>["data"]
+>;
+
+export type PersonalData = {};
+
+export type PublicAttributes = NonNullable<
+ Awaited<ReturnType<typeof getPublicAttributes>>["data"]
+>[number];
+
+export type PrivateAttributes = PublicAttributes;
diff --git a/apps/carbon/app/modules/Account/useAccountSidebar.tsx b/apps/carbon/app/interfaces/Account/useAccountSidebar.tsx
similarity index 100%
rename from apps/carbon/app/modules/Account/useAccountSidebar.tsx
rename to apps/carbon/app/interfaces/Account/useAccountSidebar.tsx
diff --git a/apps/carbon/app/modules/Parts/Toolbar/PartsTree.tsx b/apps/carbon/app/interfaces/Parts/Toolbar/PartsTree.tsx
similarity index 100%
rename from apps/carbon/app/modules/Parts/Toolbar/PartsTree.tsx
rename to apps/carbon/app/interfaces/Parts/Toolbar/PartsTree.tsx
diff --git a/apps/carbon/app/modules/Parts/Toolbar/index.ts b/apps/carbon/app/interfaces/Parts/Toolbar/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Parts/Toolbar/index.ts
rename to apps/carbon/app/interfaces/Parts/Toolbar/index.ts
diff --git a/apps/carbon/app/modules/Parts/index.ts b/apps/carbon/app/interfaces/Parts/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Parts/index.ts
rename to apps/carbon/app/interfaces/Parts/index.ts
diff --git a/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoriesTable/AttributesCategoriesTable.tsx b/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoriesTable/AttributesCategoriesTable.tsx
new file mode 100644
index 0000000000..3a22e54595
--- /dev/null
+++ b/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoriesTable/AttributesCategoriesTable.tsx
@@ -0,0 +1,153 @@
+import { ActionMenu } from "@carbon/react";
+import {
+ Button,
+ Flex,
+ MenuItem,
+ Tag,
+ TagLabel,
+ useDisclosure,
+ VisuallyHidden,
+} from "@chakra-ui/react";
+import { Link, useNavigate } from "@remix-run/react";
+import type { ColumnDef } from "@tanstack/react-table";
+import { memo, useMemo, useState } from "react";
+import { BiAddToQueue } from "react-icons/bi";
+import { BsPencilSquare, BsListUl } from "react-icons/bs";
+import { IoMdTrash } from "react-icons/io";
+import { Table } from "~/components";
+import { usePermissions } from "~/hooks";
+import type { AttributeCategory } from "~/interfaces/Users/types";
+import DeleteAttributeCategoryModal from "../DeleteAttributeCategoryModal";
+
+type AttributeCategoriesTableProps = {
+ data: AttributeCategory[];
+ count: number;
+};
+
+const AttributeCategoriesTable = memo(
+ ({ data, count }: AttributeCategoriesTableProps) => {
+ const navigate = useNavigate();
+ const permissions = usePermissions();
+ const deleteModal = useDisclosure();
+ const [selectedCategory, setSelectedCategory] = useState<
+ AttributeCategory | undefined
+ >();
+
+ const onDelete = (data: AttributeCategory) => {
+ setSelectedCategory(data);
+ deleteModal.onOpen();
+ };
+
+ const onDeleteCancel = () => {
+ setSelectedCategory(undefined);
+ deleteModal.onClose();
+ };
+
+ const columns = useMemo<ColumnDef<typeof data[number]>[]>(() => {
+ return [
+ {
+ accessorKey: "name",
+ header: "Category",
+ cell: (item) => item.getValue(),
+ },
+ {
+ header: "Attributes",
+ cell: ({ row }) => (
+ <Button
+ as={Link}
+ to={`/app/users/attributes/list/${row.original.id}`}
+ >
+ {Array.isArray(row.original.userAttribute)
+ ? row.original.userAttribute?.length ?? 0
+ : 0}{" "}
+ Attributes
+ </Button>
+ ),
+ },
+ {
+ header: "Visibility",
+ accessorKey: "public",
+ cell: (item) => {
+ const isPublic = item.getValue<boolean>().toString() === "true";
+ return (
+ <Tag
+ size="md"
+ borderRadius="full"
+ variant={isPublic ? "solid" : "outline"}
+ colorScheme={isPublic ? "green" : "gray "}
+ >
+ <TagLabel>{isPublic ? "Public" : "Private"}</TagLabel>
+ </Tag>
+ );
+ },
+ },
+
+ {
+ accessorKey: "id",
+ header: () => <VisuallyHidden>Actions</VisuallyHidden>,
+ cell: ({ row }) => (
+ <Flex justifyContent="end">
+ <ActionMenu>
+ <MenuItem
+ icon={<BiAddToQueue />}
+ onClick={() => {
+ navigate(
+ `/app/users/attributes/list/${row.original.id}/new`
+ );
+ }}
+ >
+ New Attribute
+ </MenuItem>
+ <MenuItem
+ icon={<BsListUl />}
+ onClick={() => {
+ navigate(`/app/users/attributes/list/${row.original.id}`);
+ }}
+ >
+ View Attributes
+ </MenuItem>
+ <MenuItem
+ icon={<BsPencilSquare />}
+ onClick={() => {
+ navigate(`/app/users/attributes/${row.original.id}`);
+ }}
+ >
+ Edit Attribute Category
+ </MenuItem>
+ <MenuItem
+ isDisabled={
+ row.original.protected ||
+ !permissions.can("delete", "users")
+ }
+ icon={<IoMdTrash />}
+ onClick={() => onDelete(row.original)}
+ >
+ Delete Category
+ </MenuItem>
+ </ActionMenu>
+ </Flex>
+ ),
+ },
+ ];
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
+ return (
+ <>
+ <Table<typeof data[number]>
+ data={data}
+ columns={columns}
+ count={count}
+ />
+ <DeleteAttributeCategoryModal
+ onCancel={onDeleteCancel}
+ isOpen={deleteModal.isOpen}
+ data={selectedCategory}
+ />
+ </>
+ );
+ }
+);
+
+AttributeCategoriesTable.displayName = "AttributeCategoriesTable";
+export default AttributeCategoriesTable;
diff --git a/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoriesTable/index.ts b/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoriesTable/index.ts
new file mode 100644
index 0000000000..ceb9c1b289
--- /dev/null
+++ b/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoriesTable/index.ts
@@ -0,0 +1,3 @@
+import AttributesCategoriesTable from "./AttributesCategoriesTable";
+
+export default AttributesCategoriesTable;
diff --git a/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoriesTableFilters/AttributeCategoriesTableFilters.tsx b/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoriesTableFilters/AttributeCategoriesTableFilters.tsx
new file mode 100644
index 0000000000..da21a4b9cc
--- /dev/null
+++ b/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoriesTableFilters/AttributeCategoriesTableFilters.tsx
@@ -0,0 +1,40 @@
+import { useColor } from "@carbon/react";
+import { Button, HStack } from "@chakra-ui/react";
+import { Link } from "@remix-run/react";
+import { IoMdAdd } from "react-icons/io";
+import { DebouncedInput } from "~/components/Search";
+import { usePermissions } from "~/hooks";
+
+const AttributesTableFilters = () => {
+ const permissions = usePermissions();
+ const borderColor = useColor("gray.200");
+ return (
+ <HStack
+ px={4}
+ py={3}
+ justifyContent="space-between"
+ borderBottomColor={borderColor}
+ borderBottomStyle="solid"
+ borderBottomWidth={1}
+ w="full"
+ >
+ <HStack spacing={2}>
+ <DebouncedInput
+ param="name"
+ size="sm"
+ minW={180}
+ placeholder="Search by name"
+ />
+ </HStack>
+ <HStack spacing={2}>
+ {permissions.can("update", "users") && (
+ <Button as={Link} to="new" colorScheme="brand" leftIcon={<IoMdAdd />}>
+ New Attribute Category
+ </Button>
+ )}
+ </HStack>
+ </HStack>
+ );
+};
+
+export default AttributesTableFilters;
diff --git a/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoriesTableFilters/index.ts b/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoriesTableFilters/index.ts
new file mode 100644
index 0000000000..478ea508ee
--- /dev/null
+++ b/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoriesTableFilters/index.ts
@@ -0,0 +1,3 @@
+import AttributeCategoriesTableFilters from "./AttributeCategoriesTableFilters";
+
+export default AttributeCategoriesTableFilters;
diff --git a/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoryDetail/AttributeCategoryDetail.tsx b/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoryDetail/AttributeCategoryDetail.tsx
new file mode 100644
index 0000000000..1c0212cb40
--- /dev/null
+++ b/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoryDetail/AttributeCategoryDetail.tsx
@@ -0,0 +1,223 @@
+import {
+ Button,
+ Drawer,
+ DrawerBody,
+ DrawerCloseButton,
+ DrawerContent,
+ DrawerFooter,
+ DrawerHeader,
+ DrawerOverlay,
+ HStack,
+ IconButton,
+ List,
+ ListItem,
+ Tag,
+ TagLabel,
+ Text,
+ useDisclosure,
+} from "@chakra-ui/react";
+import { Link, useFetcher } from "@remix-run/react";
+import { Reorder } from "framer-motion";
+import { useMemo, useState } from "react";
+import { AiOutlineNumber } from "react-icons/ai";
+import { BiText } from "react-icons/bi";
+import { BsCalendarDate, BsPencilSquare, BsToggleOn } from "react-icons/bs";
+import { CgProfile } from "react-icons/cg";
+import { IoMdTrash } from "react-icons/io";
+import { MdOutlineDragIndicator } from "react-icons/md";
+import type {
+ Attribute,
+ AttributeCategoryDetail as AttributeCategoryDetailType,
+} from "~/interfaces/Users/types";
+import { DeleteAttributeModal } from "~/interfaces/Users/Attributes";
+
+type AttributeCategoryDetailProps = {
+ attributeCategory: AttributeCategoryDetailType;
+ onClose: () => void;
+};
+
+const AttributeCategoryDetail = ({
+ attributeCategory,
+ onClose,
+}: AttributeCategoryDetailProps) => {
+ const sortOrderFetcher = useFetcher();
+
+ const attributeMap = useMemo(
+ () =>
+ Array.isArray(attributeCategory.userAttribute)
+ ? attributeCategory.userAttribute.reduce<
+ Record<string, AttributeCategoryDetailType["userAttribute"]>
+ >((acc, attribute) => {
+ return {
+ ...acc,
+ [attribute.id]: attribute,
+ };
+ }, {})
+ : {},
+ [attributeCategory]
+ );
+
+ const [sortOrder, setSortOrder] = useState(
+ Array.isArray(attributeCategory.userAttribute)
+ ? attributeCategory.userAttribute
+ .sort((a, b) => a.sortOrder - b.sortOrder)
+ .map((attribute) => attribute.id)
+ : []
+ );
+
+ const onReorder = (newOrder: number[]) => {
+ let updates: Record<number, number> = {};
+ newOrder.forEach((id, index) => {
+ if (id !== sortOrder[index]) {
+ updates[id] = index + 1;
+ }
+ });
+ setSortOrder(newOrder);
+ updateSortOrder(updates);
+ };
+
+ const updateSortOrder = (updates: Record<number, number>) => {
+ let formData = new FormData();
+ formData.append("updates", JSON.stringify(updates));
+ sortOrderFetcher.submit(formData, { method: "post" });
+ };
+
+ const deleteModal = useDisclosure();
+ const [selectedAttribute, setSelectedAttribute] = useState<
+ Attribute | undefined
+ >();
+
+ const onDelete = (data?: Attribute) => {
+ setSelectedAttribute(data);
+ deleteModal.onOpen();
+ };
+
+ const onDeleteCancel = () => {
+ setSelectedAttribute(undefined);
+ deleteModal.onClose();
+ };
+
+ return (
+ <>
+ <Drawer onClose={onClose} isOpen={true} size="sm">
+ <DrawerOverlay />
+ <DrawerContent>
+ <DrawerCloseButton />
+ <DrawerHeader>
+ <HStack justifyContent="space-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>
+ </DrawerHeader>
+ <DrawerBody>
+ {Array.isArray(attributeCategory?.userAttribute) && (
+ <List
+ as={Reorder.Group}
+ axis="y"
+ values={sortOrder}
+ onReorder={onReorder}
+ spacing={2}
+ >
+ {sortOrder.map((sortId) => {
+ return (
+ <ListItem
+ key={sortId}
+ as={Reorder.Item}
+ value={sortId}
+ rounded="lg"
+ >
+ <HStack>
+ <IconButton
+ aria-label="Drag handle"
+ icon={<MdOutlineDragIndicator />}
+ variant="ghost"
+ />
+ <Text flexGrow={1}>
+ {
+ // @ts-ignore
+ attributeMap[sortId]?.name
+ }
+ </Text>
+ <Button
+ isDisabled
+ leftIcon={getIcon(
+ // @ts-ignore
+ attributeMap[sortId]?.attributeDataType
+ )}
+ variant="ghost`"
+ >
+ {
+ // @ts-ignore
+ attributeMap[sortId]?.attributeDataType?.label ??
+ "Unknown"
+ }
+ </Button>
+
+ <IconButton
+ as={Link}
+ // @ts-ignore
+ to={sortId.toString()}
+ aria-label="Edit"
+ icon={<BsPencilSquare />}
+ />
+ <IconButton
+ aria-label="Delete"
+ icon={<IoMdTrash />}
+ onClick={() =>
+ // @ts-ignore
+ onDelete(attributeMap[sortId])
+ }
+ />
+ </HStack>
+ </ListItem>
+ );
+ })}
+ </List>
+ )}
+ </DrawerBody>
+ <DrawerFooter>
+ <Button as={Link} to="new" colorScheme="brand" size="md">
+ New Attribute
+ </Button>
+ </DrawerFooter>
+ </DrawerContent>
+ </Drawer>
+ <DeleteAttributeModal
+ onCancel={onDeleteCancel}
+ isOpen={deleteModal.isOpen}
+ data={selectedAttribute}
+ />
+ </>
+ );
+};
+
+function getIcon({
+ isBoolean,
+ isDate,
+ isNumeric,
+ isText,
+ isUser,
+}: {
+ isBoolean: boolean;
+ isDate: boolean;
+ isNumeric: boolean;
+ isText: boolean;
+ isUser: boolean;
+}) {
+ if (isBoolean) return <BsToggleOn />;
+ if (isDate) return <BsCalendarDate />;
+ if (isNumeric) return <AiOutlineNumber />;
+ if (isText) return <BiText />;
+ if (isUser) return <CgProfile />;
+}
+
+export default AttributeCategoryDetail;
diff --git a/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoryDetail/index.ts b/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoryDetail/index.ts
new file mode 100644
index 0000000000..1ffe488d92
--- /dev/null
+++ b/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoryDetail/index.ts
@@ -0,0 +1,3 @@
+import AttributeCategoryDetail from "./AttributeCategoryDetail";
+
+export default AttributeCategoryDetail;
diff --git a/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoryForm/AttributeCategoryForm.tsx b/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoryForm/AttributeCategoryForm.tsx
new file mode 100644
index 0000000000..3b7d12e45b
--- /dev/null
+++ b/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoryForm/AttributeCategoryForm.tsx
@@ -0,0 +1,77 @@
+import {
+ Button,
+ Drawer,
+ DrawerBody,
+ DrawerCloseButton,
+ DrawerContent,
+ DrawerHeader,
+ DrawerOverlay,
+ HStack,
+ VStack,
+} from "@chakra-ui/react";
+import { ValidatedForm } from "remix-validated-form";
+import { Boolean, Input, Hidden, Submit } from "~/components/Form";
+import { attributeCategoryValidator } from "~/services/users";
+
+type AttributeCategoryFormProps = {
+ initialValues: {
+ id?: number;
+ name: string;
+ isPublic: boolean;
+ };
+ onClose: () => void;
+};
+
+const AttributeCategoryForm = ({
+ initialValues,
+ onClose,
+}: AttributeCategoryFormProps) => {
+ const isEditing = initialValues.id !== undefined;
+
+ return (
+ <Drawer onClose={onClose} isOpen={true} size="sm">
+ <DrawerOverlay />
+ <DrawerContent>
+ <DrawerCloseButton />
+ <DrawerHeader>
+ {isEditing ? "Edit" : "New"} Attribute Category
+ </DrawerHeader>
+ <DrawerBody pb={8}>
+ <ValidatedForm
+ validator={attributeCategoryValidator}
+ method="post"
+ action={
+ isEditing
+ ? `/app/users/attributes/${initialValues.id}`
+ : "/app/users/attributes/new"
+ }
+ defaultValues={initialValues}
+ >
+ <VStack spacing={4} alignItems="start">
+ <Hidden name="id" />
+ <Input name="name" label="Category Name" />
+ <Boolean
+ name="isPublic"
+ label="Public"
+ description="Visible on a user's public profile"
+ />
+ </VStack>
+ <HStack spacing={2} mt={8}>
+ <Submit>Save</Submit>
+ <Button
+ size="md"
+ colorScheme="gray"
+ variant="solid"
+ onClick={onClose}
+ >
+ Cancel
+ </Button>
+ </HStack>
+ </ValidatedForm>
+ </DrawerBody>
+ </DrawerContent>
+ </Drawer>
+ );
+};
+
+export default AttributeCategoryForm;
diff --git a/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoryForm/index.ts b/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoryForm/index.ts
new file mode 100644
index 0000000000..f74052d036
--- /dev/null
+++ b/apps/carbon/app/interfaces/Users/Attributes/AttributeCategoryForm/index.ts
@@ -0,0 +1,3 @@
+import AttributeCategoryForm from "./AttributeCategoryForm";
+
+export default AttributeCategoryForm;
diff --git a/apps/carbon/app/interfaces/Users/Attributes/AttributeForm/AttributeForm.tsx b/apps/carbon/app/interfaces/Users/Attributes/AttributeForm/AttributeForm.tsx
new file mode 100644
index 0000000000..4df064267e
--- /dev/null
+++ b/apps/carbon/app/interfaces/Users/Attributes/AttributeForm/AttributeForm.tsx
@@ -0,0 +1,126 @@
+import {
+ Button,
+ Drawer,
+ DrawerBody,
+ DrawerCloseButton,
+ DrawerContent,
+ DrawerHeader,
+ DrawerOverlay,
+ HStack,
+ VStack,
+} from "@chakra-ui/react";
+import { useState } from "react";
+import { ValidatedForm } from "remix-validated-form";
+import {
+ Array,
+ Boolean,
+ Input,
+ Hidden,
+ Submit,
+ Select,
+} from "~/components/Form";
+import { DataType } from "~/interfaces/Users/types";
+import { attributeValidator } from "~/services/users";
+import { mapRowsToOptions } from "~/utils/form";
+
+type AttributeFormProps = {
+ initialValues: {
+ id?: number;
+ name: string;
+ userAttributeCategoryId: number;
+ attributeDataTypeId?: number;
+ listOptions?: string[];
+ canSelfManage: boolean;
+ };
+ dataTypes: {
+ id: number;
+ label: string;
+ isBoolean: boolean;
+ isDate: boolean;
+ isList: boolean;
+ isNumeric: boolean;
+ isText: boolean;
+ }[];
+ onClose: () => void;
+};
+
+const AttributeForm = ({
+ initialValues,
+ dataTypes,
+ onClose,
+}: AttributeFormProps) => {
+ const options = mapRowsToOptions({
+ data: dataTypes,
+ value: "id",
+ label: "label",
+ });
+ const isEditing = initialValues.id !== undefined;
+ const [isList, setIsList] = useState(
+ initialValues.attributeDataTypeId === DataType.List
+ );
+
+ const onChangeCheckForListType = (selected: {
+ value: string | number;
+ label: string;
+ }) => {
+ setIsList(Number(selected.value) === DataType.List);
+ };
+
+ return (
+ <Drawer onClose={onClose} isOpen={true} size="sm">
+ <DrawerOverlay />
+ <DrawerContent>
+ <DrawerCloseButton />
+ <DrawerHeader>{isEditing ? "Edit" : "New"} Attribute</DrawerHeader>
+ <DrawerBody pb={8}>
+ <ValidatedForm
+ validator={attributeValidator}
+ method="post"
+ action={
+ isEditing
+ ? `/app/users/attribute/${initialValues.id}`
+ : "/app/users/attribute/new"
+ }
+ defaultValues={initialValues}
+ >
+ <VStack spacing={2} alignItems="start">
+ <Hidden name="id" />
+ <Input name="name" label="Name" />
+ <Hidden name="userAttributeCategoryId" />
+
+ <Select
+ name="attributeDataTypeId"
+ label="Data Type"
+ isReadOnly={isEditing}
+ helperText={
+ isEditing ? "Data type cannot be changed" : undefined
+ }
+ options={options}
+ onChange={onChangeCheckForListType}
+ />
+ {isList && <Array name="listOptions" label="List Options" />}
+ <Boolean
+ name="canSelfManage"
+ label="Self Managed"
+ description="Users can update this value for themselves"
+ />
+ </VStack>
+ <HStack spacing={2} mt={8}>
+ <Submit>Save</Submit>
+ <Button
+ size="md"
+ colorScheme="gray"
+ variant="solid"
+ onClick={onClose}
+ >
+ Cancel
+ </Button>
+ </HStack>
+ </ValidatedForm>
+ </DrawerBody>
+ </DrawerContent>
+ </Drawer>
+ );
+};
+
+export default AttributeForm;
diff --git a/apps/carbon/app/interfaces/Users/Attributes/AttributeForm/index.ts b/apps/carbon/app/interfaces/Users/Attributes/AttributeForm/index.ts
new file mode 100644
index 0000000000..0cb93425a9
--- /dev/null
+++ b/apps/carbon/app/interfaces/Users/Attributes/AttributeForm/index.ts
@@ -0,0 +1,3 @@
+import AttributeForm from "./AttributeForm";
+
+export default AttributeForm;
diff --git a/apps/carbon/app/interfaces/Users/Attributes/DeleteAttributeCategoryModal/DeleteAttributeCategoryModal.tsx b/apps/carbon/app/interfaces/Users/Attributes/DeleteAttributeCategoryModal/DeleteAttributeCategoryModal.tsx
new file mode 100644
index 0000000000..a560cb2514
--- /dev/null
+++ b/apps/carbon/app/interfaces/Users/Attributes/DeleteAttributeCategoryModal/DeleteAttributeCategoryModal.tsx
@@ -0,0 +1,55 @@
+import {
+ Button,
+ Modal,
+ ModalBody,
+ ModalCloseButton,
+ ModalContent,
+ ModalFooter,
+ ModalHeader,
+ ModalOverlay,
+} from "@chakra-ui/react";
+import { Form } from "@remix-run/react";
+import type { AttributeCategory } from "../../types";
+
+type DeleteAttributeCategoryModalProps = {
+ data?: AttributeCategory;
+ isOpen: boolean;
+ onCancel: () => void;
+};
+
+const DeleteAttributeCategoryModal = ({
+ data,
+ isOpen,
+ onCancel,
+}: DeleteAttributeCategoryModalProps) => {
+ return (
+ <Modal isOpen={isOpen} onClose={onCancel}>
+ <ModalOverlay />
+ <ModalContent>
+ <ModalHeader>Delete {data?.name}</ModalHeader>
+ <ModalCloseButton />
+ <ModalBody>
+ Are you sure you want to deactivate the {data?.name} attribute
+ category?
+ </ModalBody>
+
+ <ModalFooter>
+ <Button colorScheme="gray" mr={3} onClick={onCancel}>
+ Cancel
+ </Button>
+ <Form
+ method="post"
+ action={`/app/users/attributes/delete/${data?.id}`}
+ onSubmit={onCancel}
+ >
+ <Button colorScheme="red" type="submit">
+ Delete
+ </Button>
+ </Form>
+ </ModalFooter>
+ </ModalContent>
+ </Modal>
+ );
+};
+
+export default DeleteAttributeCategoryModal;
diff --git a/apps/carbon/app/interfaces/Users/Attributes/DeleteAttributeCategoryModal/index.ts b/apps/carbon/app/interfaces/Users/Attributes/DeleteAttributeCategoryModal/index.ts
new file mode 100644
index 0000000000..758047f1b2
--- /dev/null
+++ b/apps/carbon/app/interfaces/Users/Attributes/DeleteAttributeCategoryModal/index.ts
@@ -0,0 +1,3 @@
+import DeleteAttributeCategoryModal from "./DeleteAttributeCategoryModal";
+
+export default DeleteAttributeCategoryModal;
diff --git a/apps/carbon/app/interfaces/Users/Attributes/DeleteAttributeModal/DeleteAttributeModal.tsx b/apps/carbon/app/interfaces/Users/Attributes/DeleteAttributeModal/DeleteAttributeModal.tsx
new file mode 100644
index 0000000000..75cea8bee8
--- /dev/null
+++ b/apps/carbon/app/interfaces/Users/Attributes/DeleteAttributeModal/DeleteAttributeModal.tsx
@@ -0,0 +1,57 @@
+import {
+ Button,
+ Modal,
+ ModalBody,
+ ModalCloseButton,
+ ModalContent,
+ ModalFooter,
+ ModalHeader,
+ ModalOverlay,
+} from "@chakra-ui/react";
+import { Form } from "@remix-run/react";
+import type { Attribute } from "../../types";
+
+type DeleteAttributeModalProps = {
+ data?: Attribute;
+ isOpen: boolean;
+ onCancel: () => void;
+};
+
+const DeleteAttributeModal = ({
+ data,
+ isOpen,
+ onCancel,
+}: DeleteAttributeModalProps) => {
+ if (Array.isArray(data?.userAttributeCategory))
+ throw new Error("received an array for userAttributeCategory");
+
+ return (
+ <Modal isOpen={isOpen} onClose={onCancel}>
+ <ModalOverlay />
+ <ModalContent>
+ <ModalHeader>Delete {data?.name}</ModalHeader>
+ <ModalCloseButton />
+ <ModalBody>
+ Are you sure you want to deactivate the {data?.name} attribute?
+ </ModalBody>
+
+ <ModalFooter>
+ <Button colorScheme="gray" mr={3} onClick={onCancel}>
+ Cancel
+ </Button>
+ <Form
+ method="post"
+ action={`/app/users/attribute/delete/${data?.id}`}
+ onSubmit={onCancel}
+ >
+ <Button colorScheme="red" type="submit">
+ Delete
+ </Button>
+ </Form>
+ </ModalFooter>
+ </ModalContent>
+ </Modal>
+ );
+};
+
+export default DeleteAttributeModal;
diff --git a/apps/carbon/app/interfaces/Users/Attributes/DeleteAttributeModal/index.ts b/apps/carbon/app/interfaces/Users/Attributes/DeleteAttributeModal/index.ts
new file mode 100644
index 0000000000..a7fdb6d203
--- /dev/null
+++ b/apps/carbon/app/interfaces/Users/Attributes/DeleteAttributeModal/index.ts
@@ -0,0 +1,3 @@
+import DeleteAttributeModal from "./DeleteAttributeModal";
+
+export default DeleteAttributeModal;
diff --git a/apps/carbon/app/interfaces/Users/Attributes/index.ts b/apps/carbon/app/interfaces/Users/Attributes/index.ts
new file mode 100644
index 0000000000..74c1ac62d5
--- /dev/null
+++ b/apps/carbon/app/interfaces/Users/Attributes/index.ts
@@ -0,0 +1,17 @@
+import AttributeForm from "./AttributeForm";
+import AttributeCategoriesTable from "./AttributeCategoriesTable";
+import AttributeCategoriesTableFilters from "./AttributeCategoriesTableFilters";
+import AttributeCategoryDetail from "./AttributeCategoryDetail";
+import AttributeCategoryForm from "./AttributeCategoryForm";
+import DeleteAttributeModal from "./DeleteAttributeModal";
+import DeleteAttributeCategoryModal from "./DeleteAttributeCategoryModal";
+
+export {
+ AttributeForm,
+ AttributeCategoriesTable,
+ AttributeCategoriesTableFilters,
+ AttributeCategoryDetail,
+ AttributeCategoryForm,
+ DeleteAttributeModal,
+ DeleteAttributeCategoryModal,
+};
diff --git a/apps/carbon/app/modules/Users/BulkEditPermissions/BulkEditPermissionsForm.tsx b/apps/carbon/app/interfaces/Users/BulkEditPermissions/BulkEditPermissionsForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/Users/BulkEditPermissions/BulkEditPermissionsForm.tsx
rename to apps/carbon/app/interfaces/Users/BulkEditPermissions/BulkEditPermissionsForm.tsx
diff --git a/apps/carbon/app/modules/Users/BulkEditPermissions/index.ts b/apps/carbon/app/interfaces/Users/BulkEditPermissions/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/BulkEditPermissions/index.ts
rename to apps/carbon/app/interfaces/Users/BulkEditPermissions/index.ts
diff --git a/apps/carbon/app/modules/Users/EmployeeTypes/DeleteEmployeeTypeModal/DeleteEmployeeTypeModal.tsx b/apps/carbon/app/interfaces/Users/EmployeeTypes/DeleteEmployeeTypeModal/DeleteEmployeeTypeModal.tsx
similarity index 95%
rename from apps/carbon/app/modules/Users/EmployeeTypes/DeleteEmployeeTypeModal/DeleteEmployeeTypeModal.tsx
rename to apps/carbon/app/interfaces/Users/EmployeeTypes/DeleteEmployeeTypeModal/DeleteEmployeeTypeModal.tsx
index c18e6fc8cf..a095a98496 100644
--- a/apps/carbon/app/modules/Users/EmployeeTypes/DeleteEmployeeTypeModal/DeleteEmployeeTypeModal.tsx
+++ b/apps/carbon/app/interfaces/Users/EmployeeTypes/DeleteEmployeeTypeModal/DeleteEmployeeTypeModal.tsx
@@ -25,7 +25,7 @@ const DeleteEmployeeTypeModal = ({
<Modal isOpen={true} onClose={onCancel}>
<ModalOverlay />
<ModalContent>
- <ModalHeader>{data?.name}</ModalHeader>
+ <ModalHeader>Delete {data?.name}</ModalHeader>
<ModalCloseButton />
<ModalBody>
Are you sure you want to delete the {data?.name} employee type? This
diff --git a/apps/carbon/app/modules/Users/EmployeeTypes/DeleteEmployeeTypeModal/index.ts b/apps/carbon/app/interfaces/Users/EmployeeTypes/DeleteEmployeeTypeModal/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/EmployeeTypes/DeleteEmployeeTypeModal/index.ts
rename to apps/carbon/app/interfaces/Users/EmployeeTypes/DeleteEmployeeTypeModal/index.ts
diff --git a/apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypeForm/EmployeeTypeForm.tsx b/apps/carbon/app/interfaces/Users/EmployeeTypes/EmployeeTypeForm/EmployeeTypeForm.tsx
similarity index 91%
rename from apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypeForm/EmployeeTypeForm.tsx
rename to apps/carbon/app/interfaces/Users/EmployeeTypes/EmployeeTypeForm/EmployeeTypeForm.tsx
index e1a8432344..22c3a346b3 100644
--- a/apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypeForm/EmployeeTypeForm.tsx
+++ b/apps/carbon/app/interfaces/Users/EmployeeTypes/EmployeeTypeForm/EmployeeTypeForm.tsx
@@ -9,20 +9,19 @@ import {
DrawerOverlay,
FormLabel,
HStack,
- Text,
VStack,
} from "@chakra-ui/react";
import { useNavigate } from "@remix-run/react";
import { useState } from "react";
import { ValidatedForm } from "remix-validated-form";
import { Color, Hidden, Input, Submit } from "~/components/Form";
-import PermissionCheckboxes from "~/modules/Users/components/Permission";
-import type { Permission } from "~/modules/Users/types";
+import PermissionCheckboxes from "~/interfaces/Users/components/Permission";
+import type { Permission } from "~/interfaces/Users/types";
import { employeeTypeValidator } from "~/services/users";
type EmployeeTypeFormProps = {
initialValues: {
- id: string;
+ id?: string;
name: string;
color: string;
permissions: Record<
@@ -37,9 +36,7 @@ type EmployeeTypeFormProps = {
const EmployeeTypeForm = ({ initialValues }: EmployeeTypeFormProps) => {
const navigate = useNavigate();
- const onClose = () => {
- navigate("/app/users/employee-types");
- };
+ const onClose = () => navigate(-1);
const [permissions, setPermissions] = useState(initialValues.permissions);
const updatePermissions = (module: string, permission: Permission) => {
@@ -52,7 +49,7 @@ const EmployeeTypeForm = ({ initialValues }: EmployeeTypeFormProps) => {
}));
};
- const isEditing = initialValues.id !== "";
+ const isEditing = initialValues.id !== undefined;
return (
<Drawer onClose={onClose} isOpen={true} size="sm">
diff --git a/apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypeForm/index.ts b/apps/carbon/app/interfaces/Users/EmployeeTypes/EmployeeTypeForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypeForm/index.ts
rename to apps/carbon/app/interfaces/Users/EmployeeTypes/EmployeeTypeForm/index.ts
diff --git a/apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypesTable/EmployeeTypesTable.tsx b/apps/carbon/app/interfaces/Users/EmployeeTypes/EmployeeTypesTable/EmployeeTypesTable.tsx
similarity index 96%
rename from apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypesTable/EmployeeTypesTable.tsx
rename to apps/carbon/app/interfaces/Users/EmployeeTypes/EmployeeTypesTable/EmployeeTypesTable.tsx
index d9db5ecd89..ad19302760 100644
--- a/apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypesTable/EmployeeTypesTable.tsx
+++ b/apps/carbon/app/interfaces/Users/EmployeeTypes/EmployeeTypesTable/EmployeeTypesTable.tsx
@@ -5,9 +5,9 @@ import type { ColumnDef } from "@tanstack/react-table";
import { memo, useMemo } from "react";
import { BsPencilSquare, BsPeopleFill } from "react-icons/bs";
import { IoMdTrash } from "react-icons/io";
-import { Table } from "~/components/Data";
+import { Table } from "~/components";
import { usePermissions } from "~/hooks";
-import type { EmployeeType } from "~/modules/Users/types";
+import type { EmployeeType } from "~/interfaces/Users/types";
type EmployeeTypesTableProps = {
data: EmployeeType[];
diff --git a/apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypesTable/index.ts b/apps/carbon/app/interfaces/Users/EmployeeTypes/EmployeeTypesTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypesTable/index.ts
rename to apps/carbon/app/interfaces/Users/EmployeeTypes/EmployeeTypesTable/index.ts
diff --git a/apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypesTableFilters/EmployeeTypesTableFilters.tsx b/apps/carbon/app/interfaces/Users/EmployeeTypes/EmployeeTypesTableFilters/EmployeeTypesTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypesTableFilters/EmployeeTypesTableFilters.tsx
rename to apps/carbon/app/interfaces/Users/EmployeeTypes/EmployeeTypesTableFilters/EmployeeTypesTableFilters.tsx
diff --git a/apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypesTableFilters/index.ts b/apps/carbon/app/interfaces/Users/EmployeeTypes/EmployeeTypesTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/EmployeeTypes/EmployeeTypesTableFilters/index.ts
rename to apps/carbon/app/interfaces/Users/EmployeeTypes/EmployeeTypesTableFilters/index.ts
diff --git a/apps/carbon/app/modules/Users/EmployeeTypes/index.ts b/apps/carbon/app/interfaces/Users/EmployeeTypes/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/EmployeeTypes/index.ts
rename to apps/carbon/app/interfaces/Users/EmployeeTypes/index.ts
diff --git a/apps/carbon/app/modules/Users/Employees/CreateEmployeeModal/CreateEmployeeModal.tsx b/apps/carbon/app/interfaces/Users/Employees/CreateEmployeeModal/CreateEmployeeModal.tsx
similarity index 97%
rename from apps/carbon/app/modules/Users/Employees/CreateEmployeeModal/CreateEmployeeModal.tsx
rename to apps/carbon/app/interfaces/Users/Employees/CreateEmployeeModal/CreateEmployeeModal.tsx
index 8f273cde94..482cbaf144 100644
--- a/apps/carbon/app/modules/Users/Employees/CreateEmployeeModal/CreateEmployeeModal.tsx
+++ b/apps/carbon/app/interfaces/Users/Employees/CreateEmployeeModal/CreateEmployeeModal.tsx
@@ -14,7 +14,7 @@ import type { PostgrestResponse } from "@supabase/supabase-js";
import { useEffect, useRef } from "react";
import { ValidatedForm } from "remix-validated-form";
import { Input, Select, Submit } from "~/components/Form";
-import type { EmployeeType } from "~/modules/Users/types";
+import type { EmployeeType } from "~/interfaces/Users/types";
import { createEmployeeValidator } from "~/services/users";
import type { Result } from "~/types";
import { mapRowsToOptions } from "~/utils/form";
diff --git a/apps/carbon/app/modules/Users/Employees/CreateEmployeeModal/index.ts b/apps/carbon/app/interfaces/Users/Employees/CreateEmployeeModal/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/Employees/CreateEmployeeModal/index.ts
rename to apps/carbon/app/interfaces/Users/Employees/CreateEmployeeModal/index.ts
diff --git a/apps/carbon/app/modules/Users/Employees/EmployeePermissionsForm/EmployeePermissionsForm.tsx b/apps/carbon/app/interfaces/Users/Employees/EmployeePermissionsForm/EmployeePermissionsForm.tsx
similarity index 93%
rename from apps/carbon/app/modules/Users/Employees/EmployeePermissionsForm/EmployeePermissionsForm.tsx
rename to apps/carbon/app/interfaces/Users/Employees/EmployeePermissionsForm/EmployeePermissionsForm.tsx
index b5b07ad46c..4c7ed73958 100644
--- a/apps/carbon/app/modules/Users/Employees/EmployeePermissionsForm/EmployeePermissionsForm.tsx
+++ b/apps/carbon/app/interfaces/Users/Employees/EmployeePermissionsForm/EmployeePermissionsForm.tsx
@@ -9,7 +9,6 @@ import {
DrawerOverlay,
FormLabel,
HStack,
- Text,
VStack,
} from "@chakra-ui/react";
import { useFetcher, useNavigate } from "@remix-run/react";
@@ -17,8 +16,8 @@ import type { PostgrestResponse } from "@supabase/supabase-js";
import { useEffect, useState } from "react";
import { ValidatedForm } from "remix-validated-form";
import { Hidden, Select, Submit } from "~/components/Form";
-import PermissionCheckboxes from "~/modules/Users/components/Permission";
-import type { EmployeeType, Permission } from "~/modules/Users/types";
+import PermissionCheckboxes from "~/interfaces/Users/components/Permission";
+import type { EmployeeType, Permission } from "~/interfaces/Users/types";
import { employeeValidator } from "~/services/users";
import { mapRowsToOptions } from "~/utils/form";
@@ -36,9 +35,7 @@ const EmployeePermissionsForm = ({
initialValues,
}: EmployeePermissionsFormProps) => {
const navigate = useNavigate();
- const onClose = () => {
- navigate("/app/users/employees");
- };
+ const onClose = () => navigate(-1);
const employeeTypeFetcher = useFetcher<PostgrestResponse<EmployeeType>>();
diff --git a/apps/carbon/app/modules/Users/Employees/EmployeePermissionsForm/index.ts b/apps/carbon/app/interfaces/Users/Employees/EmployeePermissionsForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/Employees/EmployeePermissionsForm/index.ts
rename to apps/carbon/app/interfaces/Users/Employees/EmployeePermissionsForm/index.ts
diff --git a/apps/carbon/app/modules/Users/Employees/EmployeesTable/EmployeesTable.tsx b/apps/carbon/app/interfaces/Users/Employees/EmployeesTable/EmployeesTable.tsx
similarity index 95%
rename from apps/carbon/app/modules/Users/Employees/EmployeesTable/EmployeesTable.tsx
rename to apps/carbon/app/interfaces/Users/Employees/EmployeesTable/EmployeesTable.tsx
index 455ea5ec33..e0e5d0b99d 100644
--- a/apps/carbon/app/modules/Users/Employees/EmployeesTable/EmployeesTable.tsx
+++ b/apps/carbon/app/interfaces/Users/Employees/EmployeesTable/EmployeesTable.tsx
@@ -10,11 +10,11 @@ import type { ColumnDef } from "@tanstack/react-table";
import { memo, useMemo, useState } from "react";
import { BsPencilSquare } from "react-icons/bs";
import { IoMdTrash } from "react-icons/io";
-import { Table } from "~/components/Data";
+import { Table } from "~/components";
import { usePermissions } from "~/hooks";
-import type { Employee } from "~/modules/Users/types";
-import { BulkEditPermissionsForm } from "~/modules/Users/BulkEditPermissions";
-import { Avatar } from "~/components/Avatar";
+import type { Employee } from "~/interfaces/Users/types";
+import { BulkEditPermissionsForm } from "~/interfaces/Users/BulkEditPermissions";
+import { Avatar } from "~/components";
type EmployeesTableProps = {
data: Employee[];
@@ -155,6 +155,7 @@ const EmployeesTable = memo(
data={rows}
defaultColumnVisibility={defaultColumnVisibility}
withColumnOrdering
+ withFilters
withPagination
withSelectableRows={withSelectableRows}
/>
diff --git a/apps/carbon/app/modules/Users/Employees/EmployeesTable/index.ts b/apps/carbon/app/interfaces/Users/Employees/EmployeesTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/Employees/EmployeesTable/index.ts
rename to apps/carbon/app/interfaces/Users/Employees/EmployeesTable/index.ts
diff --git a/apps/carbon/app/modules/Users/Employees/EmployeesTableFilters/EmployeesTableFilters.tsx b/apps/carbon/app/interfaces/Users/Employees/EmployeesTableFilters/EmployeesTableFilters.tsx
similarity index 97%
rename from apps/carbon/app/modules/Users/Employees/EmployeesTableFilters/EmployeesTableFilters.tsx
rename to apps/carbon/app/interfaces/Users/Employees/EmployeesTableFilters/EmployeesTableFilters.tsx
index 5e9e0f5b0d..9e20578944 100644
--- a/apps/carbon/app/modules/Users/Employees/EmployeesTableFilters/EmployeesTableFilters.tsx
+++ b/apps/carbon/app/interfaces/Users/Employees/EmployeesTableFilters/EmployeesTableFilters.tsx
@@ -4,7 +4,7 @@ import { useNavigate } from "@remix-run/react";
import { IoMdAdd } from "react-icons/io";
import { DebouncedInput } from "~/components/Search";
import { usePermissions, useUrlParams } from "~/hooks";
-import type { EmployeeType } from "~/modules/Users/types";
+import type { EmployeeType } from "~/interfaces/Users/types";
import { mapRowsToOptions } from "~/utils/form";
type EmployeeTypeFiltersProps = {
diff --git a/apps/carbon/app/modules/Users/Employees/EmployeesTableFilters/index.ts b/apps/carbon/app/interfaces/Users/Employees/EmployeesTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/Employees/EmployeesTableFilters/index.ts
rename to apps/carbon/app/interfaces/Users/Employees/EmployeesTableFilters/index.ts
diff --git a/apps/carbon/app/modules/Users/Employees/index.ts b/apps/carbon/app/interfaces/Users/Employees/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/Employees/index.ts
rename to apps/carbon/app/interfaces/Users/Employees/index.ts
diff --git a/apps/carbon/app/modules/Users/Groups/DeleteGroupsModal/DeleteGroupsModal.tsx b/apps/carbon/app/interfaces/Users/Groups/DeleteGroupsModal/DeleteGroupsModal.tsx
similarity index 94%
rename from apps/carbon/app/modules/Users/Groups/DeleteGroupsModal/DeleteGroupsModal.tsx
rename to apps/carbon/app/interfaces/Users/Groups/DeleteGroupsModal/DeleteGroupsModal.tsx
index 9f772ea5d3..a50b1c684c 100644
--- a/apps/carbon/app/modules/Users/Groups/DeleteGroupsModal/DeleteGroupsModal.tsx
+++ b/apps/carbon/app/interfaces/Users/Groups/DeleteGroupsModal/DeleteGroupsModal.tsx
@@ -21,7 +21,7 @@ const DeleteGroupModal = ({ data, onCancel }: DeleteGroupModalProps) => {
<Modal isOpen={true} onClose={onCancel}>
<ModalOverlay />
<ModalContent>
- <ModalHeader>{data?.name}</ModalHeader>
+ <ModalHeader>Delete {data?.name}</ModalHeader>
<ModalCloseButton />
<ModalBody>
Are you sure you want to delete the group: {data?.name}? This cannot
diff --git a/apps/carbon/app/modules/Users/Groups/DeleteGroupsModal/index.ts b/apps/carbon/app/interfaces/Users/Groups/DeleteGroupsModal/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/Groups/DeleteGroupsModal/index.ts
rename to apps/carbon/app/interfaces/Users/Groups/DeleteGroupsModal/index.ts
diff --git a/apps/carbon/app/modules/Users/Groups/GroupsForm/GroupsForm.tsx b/apps/carbon/app/interfaces/Users/Groups/GroupsForm/GroupsForm.tsx
similarity index 93%
rename from apps/carbon/app/modules/Users/Groups/GroupsForm/GroupsForm.tsx
rename to apps/carbon/app/interfaces/Users/Groups/GroupsForm/GroupsForm.tsx
index 95b210e45e..f790b56b71 100644
--- a/apps/carbon/app/modules/Users/Groups/GroupsForm/GroupsForm.tsx
+++ b/apps/carbon/app/interfaces/Users/Groups/GroupsForm/GroupsForm.tsx
@@ -16,7 +16,7 @@ import { groupValidator } from "~/services/users";
type GroupFormProps = {
initialValues: {
- id: string;
+ id?: string;
name: string;
selections: string[];
};
@@ -24,11 +24,9 @@ type GroupFormProps = {
const GroupForm = ({ initialValues }: GroupFormProps) => {
const navigate = useNavigate();
- const onClose = () => {
- navigate("/app/users/groups");
- };
+ const onClose = () => navigate(-1);
- const isEditing = initialValues.id !== "";
+ const isEditing = initialValues.id !== undefined;
return (
<Drawer onClose={onClose} isOpen={true} size="sm">
diff --git a/apps/carbon/app/modules/Users/Groups/GroupsForm/index.ts b/apps/carbon/app/interfaces/Users/Groups/GroupsForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/Groups/GroupsForm/index.ts
rename to apps/carbon/app/interfaces/Users/Groups/GroupsForm/index.ts
diff --git a/apps/carbon/app/modules/Users/Groups/GroupsTable/GroupsTable.tsx b/apps/carbon/app/interfaces/Users/Groups/GroupsTable/GroupsTable.tsx
similarity index 95%
rename from apps/carbon/app/modules/Users/Groups/GroupsTable/GroupsTable.tsx
rename to apps/carbon/app/interfaces/Users/Groups/GroupsTable/GroupsTable.tsx
index 607073fc75..b7ed13ea8a 100644
--- a/apps/carbon/app/modules/Users/Groups/GroupsTable/GroupsTable.tsx
+++ b/apps/carbon/app/interfaces/Users/Groups/GroupsTable/GroupsTable.tsx
@@ -4,10 +4,10 @@ import { useNavigate } from "@remix-run/react";
import { memo } from "react";
import { BsPencilSquare } from "react-icons/bs";
import { IoMdTrash } from "react-icons/io";
-import { Avatar } from "~/components/Avatar";
-import { Table } from "~/components/Data";
+import { Avatar } from "~/components";
+import { Table } from "~/components";
import { usePermissions } from "~/hooks";
-import type { Group } from "~/modules/Users/types";
+import type { Group } from "~/interfaces/Users/types";
type GroupsTableProps = {
data: Group[];
diff --git a/apps/carbon/app/modules/Users/Groups/GroupsTable/index.ts b/apps/carbon/app/interfaces/Users/Groups/GroupsTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/Groups/GroupsTable/index.ts
rename to apps/carbon/app/interfaces/Users/Groups/GroupsTable/index.ts
diff --git a/apps/carbon/app/modules/Users/Groups/GroupsTableFilters/GroupsTableFilters.tsx b/apps/carbon/app/interfaces/Users/Groups/GroupsTableFilters/GroupsTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/Users/Groups/GroupsTableFilters/GroupsTableFilters.tsx
rename to apps/carbon/app/interfaces/Users/Groups/GroupsTableFilters/GroupsTableFilters.tsx
diff --git a/apps/carbon/app/modules/Users/Groups/GroupsTableFilters/index.ts b/apps/carbon/app/interfaces/Users/Groups/GroupsTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/Groups/GroupsTableFilters/index.ts
rename to apps/carbon/app/interfaces/Users/Groups/GroupsTableFilters/index.ts
diff --git a/apps/carbon/app/modules/Users/Groups/index.ts b/apps/carbon/app/interfaces/Users/Groups/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/Groups/index.ts
rename to apps/carbon/app/interfaces/Users/Groups/index.ts
diff --git a/apps/carbon/app/modules/Users/components/Permission/Permission.tsx b/apps/carbon/app/interfaces/Users/components/Permission/Permission.tsx
similarity index 92%
rename from apps/carbon/app/modules/Users/components/Permission/Permission.tsx
rename to apps/carbon/app/interfaces/Users/components/Permission/Permission.tsx
index ba1215adef..529540c2b0 100644
--- a/apps/carbon/app/modules/Users/components/Permission/Permission.tsx
+++ b/apps/carbon/app/interfaces/Users/components/Permission/Permission.tsx
@@ -1,6 +1,6 @@
import { Box, Checkbox, Stack } from "@chakra-ui/react";
import { capitalize } from "~/utils/string";
-import type { Permission } from "~/modules/Users/types";
+import type { Permission } from "~/interfaces/Users/types";
type PermissionProps = {
module: string;
@@ -28,7 +28,6 @@ const PermissionCheckboxes = ({
return (
<Box mb={8}>
<Checkbox
- colorScheme="blackAlpha"
isChecked={allChecked}
isIndeterminate={isIndeterminate}
onChange={(e) =>
@@ -46,7 +45,6 @@ const PermissionCheckboxes = ({
{labels.map((verb, index) => (
<Checkbox
key={index}
- colorScheme="blackAlpha"
isChecked={permissions[verb]}
onChange={(e) => updateByPosition(index, e.target.checked)}
>
diff --git a/apps/carbon/app/modules/Users/components/Permission/index.ts b/apps/carbon/app/interfaces/Users/components/Permission/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/components/Permission/index.ts
rename to apps/carbon/app/interfaces/Users/components/Permission/index.ts
diff --git a/apps/carbon/app/modules/Users/index.ts b/apps/carbon/app/interfaces/Users/index.ts
similarity index 100%
rename from apps/carbon/app/modules/Users/index.ts
rename to apps/carbon/app/interfaces/Users/index.ts
diff --git a/apps/carbon/app/modules/Users/types.ts b/apps/carbon/app/interfaces/Users/types.ts
similarity index 61%
rename from apps/carbon/app/modules/Users/types.ts
rename to apps/carbon/app/interfaces/Users/types.ts
index e58f121169..16be7f3b6a 100644
--- a/apps/carbon/app/modules/Users/types.ts
+++ b/apps/carbon/app/interfaces/Users/types.ts
@@ -1,5 +1,8 @@
import type { Database } from "@carbon/database";
import type {
+ getAttribute,
+ getAttributeCategories,
+ getAttributeCategory,
getEmployees,
getEmployeeTypes,
getFeatures,
@@ -7,6 +10,37 @@ import type {
getUsers,
} from "~/services/users";
+export type Attribute = NonNullable<
+ Awaited<ReturnType<typeof getAttribute>>["data"]
+>;
+
+export type AttributeCategory = NonNullable<
+ Awaited<ReturnType<typeof getAttributeCategories>>["data"]
+>[number];
+
+export type AttributeCategoryDetail = NonNullable<
+ Awaited<ReturnType<typeof getAttributeCategory>>["data"]
+>;
+
+export type AttributeDataType = {
+ id: number;
+ label: string;
+ isBoolean: boolean;
+ isDate: boolean;
+ isList: boolean;
+ isNumeric: boolean;
+ isText: boolean;
+};
+
+export enum DataType {
+ Boolean = 1,
+ Date = 2,
+ List = 3,
+ Numeric = 4,
+ Text = 5,
+ User = 6,
+}
+
export type Employee = NonNullable<
Awaited<ReturnType<typeof getEmployees>>["data"]
>[number];
diff --git a/apps/carbon/app/modules/Users/useUsersSidebar.tsx b/apps/carbon/app/interfaces/Users/useUsersSidebar.tsx
similarity index 88%
rename from apps/carbon/app/modules/Users/useUsersSidebar.tsx
rename to apps/carbon/app/interfaces/Users/useUsersSidebar.tsx
index fd20993b6f..1af8d963ea 100644
--- a/apps/carbon/app/modules/Users/useUsersSidebar.tsx
+++ b/apps/carbon/app/interfaces/Users/useUsersSidebar.tsx
@@ -23,6 +23,10 @@ const usersRoutes: Record<string, Route[]>[] = [
},
{
Configuration: [
+ {
+ name: "Attributes",
+ to: "/app/users/attributes",
+ },
{
name: "Employee Types",
to: "/app/users/employee-types",
diff --git a/apps/carbon/app/modules/Account/types.ts b/apps/carbon/app/modules/Account/types.ts
deleted file mode 100644
index 644302a57c..0000000000
--- a/apps/carbon/app/modules/Account/types.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import type { getAccountById } from "~/services/account";
-
-export type PersonalData = {};
-
-export type Account = NonNullable<
- Awaited<ReturnType<typeof getAccountById>>["data"]
->;
diff --git a/apps/carbon/app/queue/bulk-permissions.queue.server.ts b/apps/carbon/app/queue/bulk-permissions.queue.server.ts
index ef287b4dd5..85bcf61c66 100644
--- a/apps/carbon/app/queue/bulk-permissions.queue.server.ts
+++ b/apps/carbon/app/queue/bulk-permissions.queue.server.ts
@@ -1,6 +1,6 @@
import { Queue } from "~/lib/bullmq";
import { getSupabaseAdmin } from "~/lib/supabase";
-import type { Permission } from "~/modules/Users/types";
+import type { Permission } from "~/interfaces/Users/types";
import { updatePermissions } from "~/services/users";
export type BulkPermissionsQueueData = {
diff --git a/apps/carbon/app/routes/_auth.callback.tsx b/apps/carbon/app/routes/_auth.callback.tsx
index e1398d69fb..574fbe4f70 100644
--- a/apps/carbon/app/routes/_auth.callback.tsx
+++ b/apps/carbon/app/routes/_auth.callback.tsx
@@ -4,7 +4,7 @@ import { json, redirect } from "@remix-run/node";
import type { LoaderArgs, ActionArgs } from "@remix-run/node";
import { useFetcher } from "@remix-run/react";
import { callbackValidator } from "~/services/auth/auth.form";
-import { getSupabase, getSupabaseAdmin } from "~/lib/supabase";
+import { getSupabase } from "~/lib/supabase";
import { refreshAccessToken } from "~/services/auth";
import { getUserByEmail } from "~/services/users";
import {
diff --git a/apps/carbon/app/routes/_auth.forgot-password.tsx b/apps/carbon/app/routes/_auth.forgot-password.tsx
index bb66103ad0..3aa0894675 100644
--- a/apps/carbon/app/routes/_auth.forgot-password.tsx
+++ b/apps/carbon/app/routes/_auth.forgot-password.tsx
@@ -22,7 +22,6 @@ import { getUserByEmail } from "~/services/users";
import { assertIsPost } from "~/utils/http";
import type { FormActionData, Result } from "~/types";
import { error } from "~/utils/result";
-import { getSupabaseAdmin } from "~/lib/supabase";
export const meta: MetaFunction = () => ({
title: "Carbon | Forgot Password",
diff --git a/apps/carbon/app/routes/app.account.$userId.attribute.tsx b/apps/carbon/app/routes/app.account.$userId.attribute.tsx
new file mode 100644
index 0000000000..b3b429803d
--- /dev/null
+++ b/apps/carbon/app/routes/app.account.$userId.attribute.tsx
@@ -0,0 +1,115 @@
+import type { ActionArgs } from "@remix-run/node";
+import { json } from "@remix-run/node";
+import { validationError } from "remix-validated-form";
+import {
+ attributeBooleanValidator,
+ attributeNumericValidator,
+ attributeTextValidator,
+ attributeUserValidator,
+} from "~/services/account";
+import { requirePermissions } from "~/services/auth";
+import { flash } from "~/services/session";
+import { upsertUserAttributeValue } from "~/services/account";
+import { assertIsPost } from "~/utils/http";
+import { error, success } from "~/utils/result";
+import { getAttribute, getPermissions } from "~/services/users";
+
+export async function action({ request, params }: ActionArgs) {
+ assertIsPost(request);
+
+ const { client, userId } = await requirePermissions(request, {});
+ const { userId: targetUserId } = params;
+
+ if (!targetUserId) {
+ throw new Error("No user id provided");
+ }
+
+ const formData = await request.formData();
+
+ const attributeId = formData.get("userAttributeId") as string;
+ if (!attributeId || Number.isNaN(Number(attributeId)))
+ throw new Error("No attribute id provided");
+
+ const clientPermissions = await getPermissions(request, client);
+ const canUpdateAnyUser = clientPermissions["users"]?.update === true;
+
+ if (!canUpdateAnyUser && userId !== targetUserId) {
+ return json(
+ null,
+ await flash(request, error(null, "Unauthorized: Cannot update attribute"))
+ );
+ }
+
+ if (!canUpdateAnyUser && userId === targetUserId) {
+ // check if this is a self managed attribute
+ const attribute = await getAttribute(client, Number(attributeId));
+ if (attribute.error) {
+ return json(
+ null,
+ await flash(request, error(attribute.error, "Failed to get attribute"))
+ );
+ }
+
+ const canSelfManage = attribute.data?.canSelfManage ?? false;
+ if (!canSelfManage) {
+ return json(
+ null,
+ await flash(
+ request,
+ error(null, "Unauthorized: Cannot update attribute")
+ )
+ );
+ }
+ }
+
+ const type = formData.get("type") as string;
+ if (!type) throw new Error("No type provided");
+
+ const validator = getValidatorByType(type);
+
+ const validation = await validator.validate(formData);
+ if (validation.error) {
+ return validationError(validation.error);
+ }
+
+ const upsertAttributeValue = await upsertUserAttributeValue(client, {
+ ...validation.data,
+ userId: targetUserId,
+ updatedBy: userId,
+ });
+ if (upsertAttributeValue.error) {
+ return json(
+ null,
+ await flash(
+ request,
+ error(upsertAttributeValue.error, "Failed to update attribute value")
+ )
+ );
+ }
+
+ return json(null, await flash(request, success("Updated attribute value")));
+}
+
+export default function UserAttributeValueRoute() {
+ // Remix bug
+ return null;
+}
+
+function getValidatorByType(type: string) {
+ switch (type) {
+ case "boolean":
+ return attributeBooleanValidator;
+ case "date":
+ return attributeTextValidator;
+ case "list":
+ return attributeTextValidator;
+ case "numeric":
+ return attributeNumericValidator;
+ case "text":
+ return attributeTextValidator;
+ case "user":
+ return attributeUserValidator;
+ default:
+ throw new Error("Invalid type provided");
+ }
+}
diff --git a/apps/carbon/app/routes/app.account.$userId.delete.attribute.tsx b/apps/carbon/app/routes/app.account.$userId.delete.attribute.tsx
new file mode 100644
index 0000000000..135c07d1d1
--- /dev/null
+++ b/apps/carbon/app/routes/app.account.$userId.delete.attribute.tsx
@@ -0,0 +1,83 @@
+import type { ActionArgs } from "@remix-run/node";
+import { json } from "@remix-run/node";
+import { requirePermissions } from "~/services/auth";
+import { flash } from "~/services/session";
+import { deleteUserAttributeValue } from "~/services/account";
+import { assertIsPost } from "~/utils/http";
+import { error, success } from "~/utils/result";
+import { getAttribute, getPermissions } from "~/services/users";
+
+export async function action({ request, params }: ActionArgs) {
+ assertIsPost(request);
+
+ const { client, userId } = await requirePermissions(request, {});
+ const { userId: targetUserId } = params;
+
+ if (!targetUserId) {
+ throw new Error("No user id provided");
+ }
+
+ const formData = await request.formData();
+
+ const userAttributeId = formData.get("userAttributeId") as string;
+ if (!userAttributeId || Number.isNaN(Number(userAttributeId)))
+ throw new Error("No attribute id provided");
+
+ const userAttributeValueId = formData.get("userAttributeValueId") as string;
+ if (!userAttributeValueId || Number.isNaN(Number(userAttributeValueId)))
+ throw new Error("No attribute value id provided");
+
+ const clientPermissions = await getPermissions(request, client);
+ const canUpdateAnyUser = clientPermissions["users"]?.update === true;
+
+ if (!canUpdateAnyUser && userId !== targetUserId) {
+ return json(
+ null,
+ await flash(request, error(null, "Unauthorized: Cannot remove attribute"))
+ );
+ }
+
+ if (!canUpdateAnyUser && userId === targetUserId) {
+ // check if this is a self managed attribute
+ const attribute = await getAttribute(client, Number(userAttributeId));
+ if (attribute.error) {
+ return json(
+ null,
+ await flash(request, error(attribute.error, "Failed to get attribute"))
+ );
+ }
+
+ const canSelfManage = attribute.data?.canSelfManage ?? false;
+ if (!canSelfManage) {
+ return json(
+ null,
+ await flash(
+ request,
+ error(null, "Unauthorized: Cannot remove attribute")
+ )
+ );
+ }
+ }
+
+ const removeAttributeValue = await deleteUserAttributeValue(client, {
+ userId,
+ userAttributeId: Number(userAttributeId),
+ userAttributeValueId: Number(userAttributeValueId),
+ });
+ if (removeAttributeValue.error) {
+ return json(
+ null,
+ await flash(
+ request,
+ error(removeAttributeValue.error, "Failed to delete attribute value")
+ )
+ );
+ }
+
+ return json(null, await flash(request, success("Deleted attribute value")));
+}
+
+export default function UserAttributeValueRoute() {
+ // Remix bug
+ return null;
+}
diff --git a/apps/carbon/app/routes/app.account.password.tsx b/apps/carbon/app/routes/app.account.password.tsx
index 0323dd3c15..1676909949 100644
--- a/apps/carbon/app/routes/app.account.password.tsx
+++ b/apps/carbon/app/routes/app.account.password.tsx
@@ -3,7 +3,7 @@ import { json, redirect } from "@remix-run/router";
import { validationError } from "remix-validated-form";
import { PageTitle } from "~/components/Layout";
import { getSupabaseAdmin } from "~/lib/supabase";
-import { PasswordForm } from "~/modules/Account/Password";
+import { PasswordForm } from "~/interfaces/Account/Password";
import { accountPasswordValidator } from "~/services/account";
import { requirePermissions } from "~/services/auth";
import { flash } from "~/services/session";
@@ -53,10 +53,7 @@ export async function action({ request }: ActionArgs) {
);
}
- return redirect(
- "/app",
- await flash(request, success("Succesfully updated password"))
- );
+ return redirect("/app", await flash(request, success("Updated password")));
}
export default function AccountPassword() {
diff --git a/apps/carbon/app/routes/app.account.personal.tsx b/apps/carbon/app/routes/app.account.personal.tsx
index f864e8531a..064141f7a1 100644
--- a/apps/carbon/app/routes/app.account.personal.tsx
+++ b/apps/carbon/app/routes/app.account.personal.tsx
@@ -1,14 +1,47 @@
+import type { LoaderArgs } from "@remix-run/node";
+import { redirect } from "@remix-run/node";
+import { useLoaderData } from "@remix-run/react";
+import { json } from "@remix-run/router";
import { PageTitle } from "~/components/Layout";
-import { PersonalDataForm } from "~/modules/Account/Personal";
+import { UserAttributesForm } from "~/interfaces/Account/UserAttributes";
+import type { PrivateAttributes } from "~/interfaces/Account/types";
+import { getPrivateAttributes } from "~/services/account";
+import { requirePermissions } from "~/services/auth";
+import { flash } from "~/services/session";
+import { error } from "~/utils/result";
+
+export async function loader({ request }: LoaderArgs) {
+ const { client, userId } = await requirePermissions(request, {});
+
+ const [privateAttributes] = await Promise.all([
+ getPrivateAttributes(client, userId),
+ ]);
+
+ if (privateAttributes.error) {
+ return redirect(
+ "/app",
+ await flash(
+ request,
+ error(privateAttributes.error, "Failed to get user attributes")
+ )
+ );
+ }
+
+ return json({ attributes: privateAttributes.data });
+}
export default function AccountPersonal() {
+ const { attributes } = useLoaderData<typeof loader>();
return (
<>
<PageTitle
title="Personal Data"
- subtitle="This information is private and stored in an encrypted format."
+ subtitle="This information is private and can only be seen by you and authorized employees."
/>
- <PersonalDataForm personalData={{}} />
+ {/* <PersonalDataForm personalData={{}} /> */}
+ {attributes.map((category: PrivateAttributes) => (
+ <UserAttributesForm key={category.id} attributeCategory={category} />
+ ))}
</>
);
}
diff --git a/apps/carbon/app/routes/app.account.profile.tsx b/apps/carbon/app/routes/app.account.profile.tsx
index 1cb0cb1ea8..3042e6a787 100644
--- a/apps/carbon/app/routes/app.account.profile.tsx
+++ b/apps/carbon/app/routes/app.account.profile.tsx
@@ -5,10 +5,13 @@ import { useLoaderData } from "@remix-run/react";
import { json } from "@remix-run/router";
import { validationError } from "remix-validated-form";
import { PageTitle } from "~/components/Layout";
-import { ProfileForm, ProfilePhotoForm } from "~/modules/Account/Profile";
+import { ProfileForm, ProfilePhotoForm } from "~/interfaces/Account/Profile";
+import { UserAttributesForm } from "~/interfaces/Account/UserAttributes";
+import type { PublicAttributes } from "~/interfaces/Account/types";
import {
accountProfileValidator,
- getAccountById,
+ getAccount,
+ getPublicAttributes,
updateAvatar,
updatePublicAccount,
} from "~/services/account";
@@ -20,22 +23,29 @@ import { error, success } from "~/utils/result";
export async function loader({ request }: LoaderArgs) {
const { client, userId } = await requirePermissions(request, {});
- if (!userId) {
+ const [user, publicAttributes] = await Promise.all([
+ getAccount(client, userId),
+ getPublicAttributes(client, userId),
+ ]);
+
+ if (user.error || !user.data) {
return redirect(
"/app",
- await flash(request, error(undefined, "Could not authenticate request"))
+ await flash(request, error(user.error, "Failed to get user"))
);
}
- const user = await getAccountById(client, userId);
- if (user.error || !user.data) {
+ if (publicAttributes.error) {
return redirect(
"/app",
- await flash(request, error(user.error, "Failed to get user"))
+ await flash(
+ request,
+ error(publicAttributes.error, "Failed to get user attributes")
+ )
);
}
- return json({ user: user.data });
+ return json({ user: user.data, attributes: publicAttributes.data });
}
export async function action({ request }: ActionArgs) {
@@ -86,7 +96,7 @@ export async function action({ request }: ActionArgs) {
return redirect(
"/app/account/profile",
- await flash(request, success("Successfully updated avatar"))
+ await flash(request, success("Updated avatar"))
);
} else {
return redirect(
@@ -100,7 +110,7 @@ export async function action({ request }: ActionArgs) {
}
export default function AccountProfile() {
- const { user } = useLoaderData<typeof loader>();
+ const { user, attributes } = useLoaderData<typeof loader>();
return (
<>
@@ -117,6 +127,9 @@ export default function AccountProfile() {
<ProfileForm user={user} />
<ProfilePhotoForm user={user} />
</Grid>
+ {attributes.map((category: PublicAttributes) => (
+ <UserAttributesForm key={category.id} attributeCategory={category} />
+ ))}
</>
);
}
diff --git a/apps/carbon/app/routes/app.account.tsx b/apps/carbon/app/routes/app.account.tsx
index 3508991107..6d788853fd 100644
--- a/apps/carbon/app/routes/app.account.tsx
+++ b/apps/carbon/app/routes/app.account.tsx
@@ -1,9 +1,9 @@
import { useColor } from "@carbon/react";
-import { Button, Grid, Text, VStack } from "@chakra-ui/react";
+import { Button, Grid, VStack } from "@chakra-ui/react";
import type { MetaFunction } from "@remix-run/node";
import { Link, Outlet, useMatches } from "@remix-run/react";
import { ContentSidebar } from "~/components/Layout/Sidebar";
-import { useAccountSidebar } from "~/modules/Account";
+import { useAccountSidebar } from "~/interfaces/Account";
export const meta: MetaFunction = () => ({
title: "Carbon | My Account",
diff --git a/apps/carbon/app/routes/app.tsx b/apps/carbon/app/routes/app.tsx
index e72f21b9b8..af32b93675 100644
--- a/apps/carbon/app/routes/app.tsx
+++ b/apps/carbon/app/routes/app.tsx
@@ -7,7 +7,7 @@ import { Outlet, useLoaderData } from "@remix-run/react";
import { useEffect } from "react";
import { IconSidebar, Topbar } from "~/components/Layout";
import { getSupabase, SupabaseProvider } from "~/lib/supabase";
-import { getPermissions, getUser } from "~/services/users";
+import { getPermissions, getCurrentUser } from "~/services/users";
import {
destroyAuthSession,
getSessionFlash,
@@ -27,7 +27,7 @@ export async function loader({ request }: LoaderArgs) {
const [sessionFlash, permissions, user] = await Promise.all([
getSessionFlash(request),
getPermissions(request, client),
- getUser(request, client),
+ getCurrentUser(request, client),
]);
if (!permissions || !user) {
diff --git a/apps/carbon/app/routes/app.users.attribute.$attributeId.tsx b/apps/carbon/app/routes/app.users.attribute.$attributeId.tsx
new file mode 100644
index 0000000000..3cbccb5a1b
--- /dev/null
+++ b/apps/carbon/app/routes/app.users.attribute.$attributeId.tsx
@@ -0,0 +1,38 @@
+import type { ActionArgs } from "@remix-run/node";
+import { redirect } from "@remix-run/node";
+import { validationError } from "remix-validated-form";
+import { requirePermissions } from "~/services/auth";
+import { flash } from "~/services/session";
+import { attributeValidator, updateAttribute } from "~/services/users";
+import { assertIsPost } from "~/utils/http";
+import { error, success } from "~/utils/result";
+
+export async function action({ request, params }: ActionArgs) {
+ assertIsPost(request);
+ const { client, userId } = await requirePermissions(request, {
+ update: "users",
+ });
+
+ const validation = await attributeValidator.validate(
+ await request.formData()
+ );
+
+ if (validation.error) {
+ return validationError(validation.error);
+ }
+
+ const update = await updateAttribute(client, {
+ ...validation.data,
+ updatedBy: userId,
+ });
+ if (update.error)
+ redirect(
+ "/app/users/attributes",
+ await flash(request, error(update.error, "Failed to update attribute"))
+ );
+
+ return redirect(
+ "/app/users/attributes",
+ await flash(request, success("Successfully updated attribtue"))
+ );
+}
diff --git a/apps/carbon/app/routes/app.users.attribute.delete.$attributeId.tsx b/apps/carbon/app/routes/app.users.attribute.delete.$attributeId.tsx
new file mode 100644
index 0000000000..21c1459e41
--- /dev/null
+++ b/apps/carbon/app/routes/app.users.attribute.delete.$attributeId.tsx
@@ -0,0 +1,36 @@
+import type { LoaderArgs } from "@remix-run/node";
+import { redirect } from "@remix-run/node";
+import { requirePermissions } from "~/services/auth";
+import { deleteAttribute } from "~/services/users";
+import { flash } from "~/services/session";
+import { error, success } from "~/utils/result";
+
+export async function action({ request, params }: LoaderArgs) {
+ const { client } = await requirePermissions(request, {
+ update: "users",
+ });
+
+ const { attributeId } = params;
+ if (!attributeId) {
+ return redirect(
+ "/app/users/attributes",
+ await flash(request, error(params, "Failed to get an attribute id"))
+ );
+ }
+
+ const deactivateAttribute = await deleteAttribute(client, attributeId);
+ if (deactivateAttribute.error) {
+ return redirect(
+ "/app/users/attributes",
+ await flash(
+ request,
+ error(deactivateAttribute.error, "Failed to deactivate attribute")
+ )
+ );
+ }
+
+ return redirect(
+ "/app/users/attributes",
+ await flash(request, success("Successfully deactivated attribute"))
+ );
+}
diff --git a/apps/carbon/app/routes/app.users.attribute.new.tsx b/apps/carbon/app/routes/app.users.attribute.new.tsx
new file mode 100644
index 0000000000..e0b1ff3651
--- /dev/null
+++ b/apps/carbon/app/routes/app.users.attribute.new.tsx
@@ -0,0 +1,55 @@
+import type { ActionArgs } from "@remix-run/node";
+import { json } from "@remix-run/node";
+import { redirect } from "@remix-run/node";
+import { validationError } from "remix-validated-form";
+import { requirePermissions } from "~/services/auth";
+import { flash } from "~/services/session";
+import { attributeValidator, insertAttribute } from "~/services/users";
+import { assertIsPost } from "~/utils/http";
+import { error, success } from "~/utils/result";
+
+export async function action({ request }: ActionArgs) {
+ assertIsPost(request);
+ const { client, userId } = await requirePermissions(request, {
+ create: "users",
+ });
+
+ const validation = await attributeValidator.validate(
+ await request.formData()
+ );
+
+ if (validation.error) {
+ return validationError(validation.error);
+ }
+
+ const {
+ name,
+ attributeDataTypeId,
+ userAttributeCategoryId,
+ listOptions,
+ canSelfManage,
+ } = validation.data;
+
+ const createAttribute = await insertAttribute(client, {
+ name,
+ attributeDataTypeId,
+ userAttributeCategoryId,
+ listOptions,
+ canSelfManage,
+ createdBy: userId,
+ });
+ if (createAttribute.error) {
+ return json(
+ {},
+ await flash(
+ request,
+ error(createAttribute.error, "Failed to create attribute")
+ )
+ );
+ }
+
+ return redirect(
+ `/app/users/attributes`,
+ await flash(request, success("Created attribute"))
+ );
+}
diff --git a/apps/carbon/app/routes/app.users.attributes.$categoryId.tsx b/apps/carbon/app/routes/app.users.attributes.$categoryId.tsx
new file mode 100644
index 0000000000..33036c78df
--- /dev/null
+++ b/apps/carbon/app/routes/app.users.attributes.$categoryId.tsx
@@ -0,0 +1,95 @@
+import type { ActionArgs, LoaderArgs } from "@remix-run/node";
+import { redirect, json } from "@remix-run/node";
+import { useLoaderData, useNavigate } from "@remix-run/react";
+import { validationError } from "remix-validated-form";
+import { AttributeCategoryForm } from "~/interfaces/Users/Attributes";
+import { requirePermissions } from "~/services/auth";
+import { flash } from "~/services/session";
+import {
+ attributeCategoryValidator,
+ getAttributeCategory,
+ updateAttributeCategory,
+} from "~/services/users";
+import { assertIsPost, notFound } from "~/utils/http";
+import { error, success } from "~/utils/result";
+
+export async function loader({ request, params }: LoaderArgs) {
+ const { client } = await requirePermissions(request, {
+ view: "users",
+ });
+
+ const { categoryId } = params;
+ if (!categoryId || Number.isNaN(Number(categoryId)))
+ throw notFound("Invalid categoryId");
+
+ const attributeCategory = await getAttributeCategory(
+ client,
+ Number(categoryId)
+ );
+ if (attributeCategory.error) {
+ return redirect(
+ "/app/users/attributes",
+ await flash(
+ request,
+ error(attributeCategory.error, "Failed to fetch attribute category")
+ )
+ );
+ }
+
+ return json({ attributeCategory: attributeCategory.data });
+}
+
+export async function action({ request }: ActionArgs) {
+ assertIsPost(request);
+ const { client, userId } = await requirePermissions(request, {
+ update: "users",
+ });
+
+ const validation = await attributeCategoryValidator.validate(
+ await request.formData()
+ );
+
+ if (validation.error) {
+ return validationError(validation.error);
+ }
+
+ const { id, name, isPublic } = validation.data;
+ if (!id) throw new Error("ID is was not found");
+
+ const updateCategory = await updateAttributeCategory(client, {
+ id,
+ name,
+ public: isPublic,
+ updatedBy: userId,
+ });
+ if (updateCategory.error) {
+ return redirect(
+ "/app/users/attributes",
+ await flash(
+ request,
+ error(updateCategory.error, "Failed to update attribute category")
+ )
+ );
+ }
+
+ return redirect(
+ "/app/users/attributes",
+ await flash(request, success("Updated attribute category "))
+ );
+}
+
+export default function EditAttributeCategoryRoute() {
+ const { attributeCategory } = useLoaderData<typeof loader>();
+ const navigate = useNavigate();
+ const onClose = () => navigate("/app/users/attributes/");
+
+ const initialValues = {
+ id: attributeCategory?.id,
+ name: attributeCategory?.name ?? "",
+ isPublic: attributeCategory?.public ?? false,
+ };
+
+ return (
+ <AttributeCategoryForm onClose={onClose} initialValues={initialValues} />
+ );
+}
diff --git a/apps/carbon/app/routes/app.users.attributes.delete.$categoryId.tsx b/apps/carbon/app/routes/app.users.attributes.delete.$categoryId.tsx
new file mode 100644
index 0000000000..9a1772c88b
--- /dev/null
+++ b/apps/carbon/app/routes/app.users.attributes.delete.$categoryId.tsx
@@ -0,0 +1,39 @@
+import type { LoaderArgs } from "@remix-run/node";
+import { redirect } from "@remix-run/node";
+import { requirePermissions } from "~/services/auth";
+import { deleteAttributeCategory } from "~/services/users";
+import { flash } from "~/services/session";
+import { error, success } from "~/utils/result";
+
+export async function action({ request, params }: LoaderArgs) {
+ const { client } = await requirePermissions(request, {
+ update: "users",
+ });
+
+ const { categoryId } = params;
+ if (!categoryId) {
+ return redirect(
+ "/app/users/attributes",
+ await flash(request, error(params, "Failed to get a category id"))
+ );
+ }
+
+ const deactivateAttribute = await deleteAttributeCategory(client, categoryId);
+ if (deactivateAttribute.error) {
+ return redirect(
+ "/app/users/attributes",
+ await flash(
+ request,
+ error(
+ deactivateAttribute.error,
+ "Failed to deactivate attribute category"
+ )
+ )
+ );
+ }
+
+ return redirect(
+ "/app/users/attributes",
+ await flash(request, success("Successfully deactivated attribute category"))
+ );
+}
diff --git a/apps/carbon/app/routes/app.users.attributes.list.$categoryId.$attributeId.tsx b/apps/carbon/app/routes/app.users.attributes.list.$categoryId.$attributeId.tsx
new file mode 100644
index 0000000000..518510a52a
--- /dev/null
+++ b/apps/carbon/app/routes/app.users.attributes.list.$categoryId.$attributeId.tsx
@@ -0,0 +1,65 @@
+import type { LoaderArgs } from "@remix-run/node";
+import { redirect } from "@remix-run/node";
+import { json } from "@remix-run/node";
+import { useLoaderData, useNavigate, useParams } from "@remix-run/react";
+import { useRouteData } from "~/hooks";
+import { AttributeForm } from "~/interfaces/Users/Attributes";
+import type { AttributeDataType } from "~/interfaces/Users/types";
+import { requirePermissions } from "~/services/auth";
+import { flash } from "~/services/session";
+import { getAttribute } from "~/services/users";
+import { notFound } from "~/utils/http";
+import { error } from "~/utils/result";
+
+export async function loader({ request, params }: LoaderArgs) {
+ const { client } = await requirePermissions(request, {
+ view: "users",
+ });
+
+ const { categoryId, attributeId } = params;
+ if (!attributeId || Number.isNaN(Number(attributeId)))
+ throw notFound("attributeId not found");
+
+ const attribute = await getAttribute(client, Number(attributeId));
+ if (attribute.error) {
+ return redirect(
+ `/app/users/attributes/list/${categoryId}`,
+ await flash(request, error(attribute.error, "Failed to fetch attribute"))
+ );
+ }
+
+ return json({
+ attribute: attribute.data,
+ });
+}
+
+export default function EditAttributeRoute() {
+ const { attribute } = useLoaderData<typeof loader>();
+ const { categoryId } = useParams();
+ if (Number.isNaN(categoryId)) throw new Error("categoryId is not a number");
+
+ const navigate = useNavigate();
+ const onClose = () => navigate(`/app/users/attributes/list/${categoryId}`);
+ const attributesRouteData = useRouteData<{
+ dataTypes: {
+ data: AttributeDataType[] | null;
+ };
+ }>("/app/users/attributes");
+
+ console.log("attribute", attribute);
+
+ return (
+ <AttributeForm
+ initialValues={{
+ id: attribute?.id,
+ name: attribute?.name,
+ attributeDataTypeId: attribute?.attributeDataTypeId,
+ userAttributeCategoryId: attribute?.userAttributeCategoryId,
+ canSelfManage: attribute.canSelfManage ?? true,
+ listOptions: attribute?.listOptions ?? [],
+ }}
+ dataTypes={attributesRouteData?.dataTypes?.data ?? []}
+ onClose={onClose}
+ />
+ );
+}
diff --git a/apps/carbon/app/routes/app.users.attributes.list.$categoryId.new.tsx b/apps/carbon/app/routes/app.users.attributes.list.$categoryId.new.tsx
new file mode 100644
index 0000000000..6e2f26b1fd
--- /dev/null
+++ b/apps/carbon/app/routes/app.users.attributes.list.$categoryId.new.tsx
@@ -0,0 +1,30 @@
+import { useNavigate, useParams } from "@remix-run/react";
+import { useRouteData } from "~/hooks";
+import { AttributeForm } from "~/interfaces/Users/Attributes";
+import type { AttributeDataType } from "~/interfaces/Users/types";
+
+export default function NewAttributeRoute() {
+ const { categoryId } = useParams();
+ if (Number.isNaN(categoryId)) throw new Error("categoryId is not a number");
+
+ const navigate = useNavigate();
+ const onClose = () => navigate(-1);
+ const attributesRouteData = useRouteData<{
+ dataTypes: {
+ data: AttributeDataType[] | null;
+ };
+ }>("/app/users/attributes");
+
+ return (
+ <AttributeForm
+ initialValues={{
+ name: "",
+ attributeDataTypeId: undefined,
+ userAttributeCategoryId: Number(categoryId),
+ canSelfManage: true,
+ }}
+ dataTypes={attributesRouteData?.dataTypes?.data ?? []}
+ onClose={onClose}
+ />
+ );
+}
diff --git a/apps/carbon/app/routes/app.users.attributes.list.$categoryId.tsx b/apps/carbon/app/routes/app.users.attributes.list.$categoryId.tsx
new file mode 100644
index 0000000000..c3473ed496
--- /dev/null
+++ b/apps/carbon/app/routes/app.users.attributes.list.$categoryId.tsx
@@ -0,0 +1,90 @@
+import type { ActionArgs, LoaderArgs } from "@remix-run/node";
+import { json, redirect } from "@remix-run/node";
+import { Outlet, useLoaderData, useNavigate } from "@remix-run/react";
+import { AttributeCategoryDetail } from "~/interfaces/Users/Attributes";
+import { requirePermissions } from "~/services/auth";
+import { flash } from "~/services/session";
+import {
+ getAttributeCategory,
+ updateAttributeSortOrder,
+} from "~/services/users";
+import { assertIsPost, notFound } from "~/utils/http";
+import { error } from "~/utils/result";
+
+export async function loader({ request, params }: LoaderArgs) {
+ const { client } = await requirePermissions(request, {
+ view: "users",
+ });
+
+ const { categoryId } = params;
+ if (!categoryId || Number.isNaN(Number(categoryId)))
+ throw notFound("Invalid categoryId");
+
+ const attributeCategory = await getAttributeCategory(
+ client,
+ Number(categoryId)
+ );
+ if (attributeCategory.error) {
+ return redirect(
+ "/app/users/attributes",
+ await flash(
+ request,
+ error(attributeCategory.error, "Failed to fetch attribute category")
+ )
+ );
+ }
+
+ return json({ attributeCategory: attributeCategory.data });
+}
+
+export async function action({ request }: ActionArgs) {
+ assertIsPost(request);
+ const { client, userId } = await requirePermissions(request, {
+ update: "users",
+ });
+
+ const updateMap = (await request.formData()).get("updates") as string;
+ if (!updateMap) {
+ return json(
+ {},
+ await flash(request, error(null, "Failed to receive a new sort order"))
+ );
+ }
+
+ const updates = Object.entries(JSON.parse(updateMap)).map(
+ ([idString, sortOrderString]) => ({
+ id: Number(idString),
+ sortOrder: Number(sortOrderString),
+ updatedBy: userId,
+ })
+ );
+
+ const updateSortOrders = await updateAttributeSortOrder(client, updates);
+ if (updateSortOrders.some((update) => update.error))
+ return json(
+ {},
+ await flash(
+ request,
+ error(updateSortOrders, "Failed to update sort order")
+ )
+ );
+
+ return null;
+}
+
+export default function AttributeCategoryListRoute() {
+ const { attributeCategory } = useLoaderData<typeof loader>();
+
+ const navigate = useNavigate();
+ const onClose = () => navigate("/app/users/attributes");
+
+ return (
+ <>
+ <AttributeCategoryDetail
+ attributeCategory={attributeCategory}
+ onClose={onClose}
+ />
+ <Outlet />
+ </>
+ );
+}
diff --git a/apps/carbon/app/routes/app.users.attributes.new.tsx b/apps/carbon/app/routes/app.users.attributes.new.tsx
new file mode 100644
index 0000000000..97b9f748d9
--- /dev/null
+++ b/apps/carbon/app/routes/app.users.attributes.new.tsx
@@ -0,0 +1,67 @@
+import type { ActionArgs } from "@remix-run/node";
+import { redirect } from "@remix-run/node";
+import { useNavigate } from "@remix-run/react";
+import { validationError } from "remix-validated-form";
+import { AttributeCategoryForm } from "~/interfaces/Users/Attributes";
+import { requirePermissions } from "~/services/auth";
+import { flash } from "~/services/session";
+import {
+ attributeCategoryValidator,
+ insertAttributeCategory,
+} from "~/services/users";
+import { assertIsPost } from "~/utils/http";
+import { error, success } from "~/utils/result";
+
+export async function action({ request }: ActionArgs) {
+ assertIsPost(request);
+ const { client, userId } = await requirePermissions(request, {
+ update: "users",
+ });
+
+ const validation = await attributeCategoryValidator.validate(
+ await request.formData()
+ );
+
+ if (validation.error) {
+ return validationError(validation.error);
+ }
+
+ const { name, isPublic } = validation.data;
+
+ const createAttributeCategory = await insertAttributeCategory(client, {
+ name,
+ public: isPublic,
+ createdBy: userId,
+ });
+ if (createAttributeCategory.error) {
+ return redirect(
+ "/app/users/attributes",
+ await flash(
+ request,
+ error(
+ createAttributeCategory.error,
+ "Failed to create attribute category"
+ )
+ )
+ );
+ }
+
+ return redirect(
+ "/app/users/attributes",
+ await flash(request, success("Created attribute category "))
+ );
+}
+
+export default function NewAttributeCategoryRoute() {
+ const navigate = useNavigate();
+ const onClose = () => navigate("/app/users/attributes");
+
+ const initialValues = {
+ name: "",
+ isPublic: false,
+ };
+
+ return (
+ <AttributeCategoryForm onClose={onClose} initialValues={initialValues} />
+ );
+}
diff --git a/apps/carbon/app/routes/app.users.attributes.tsx b/apps/carbon/app/routes/app.users.attributes.tsx
new file mode 100644
index 0000000000..02a5a3e735
--- /dev/null
+++ b/apps/carbon/app/routes/app.users.attributes.tsx
@@ -0,0 +1,49 @@
+import type { LoaderArgs } from "@remix-run/node";
+import { json } from "@remix-run/node";
+import { Outlet, useLoaderData } from "@remix-run/react";
+import {
+ AttributeCategoriesTable,
+ AttributeCategoriesTableFilters,
+} from "~/interfaces/Users/Attributes";
+import { requirePermissions } from "~/services/auth";
+import {
+ getAttributeCategories,
+ getAttributeDataTypes,
+} from "~/services/users";
+import { getGenericQueryFilters } from "~/utils/query";
+
+export async function loader({ request }: LoaderArgs) {
+ const { client } = await requirePermissions(request, {
+ view: "users",
+ });
+
+ const url = new URL(request.url);
+ const searchParams = new URLSearchParams(url.search);
+ const name = searchParams.get("name");
+ const { limit, offset, sorts } = getGenericQueryFilters(searchParams);
+
+ const [categories, dataTypes] = await Promise.all([
+ getAttributeCategories(client, { name, limit, offset, sorts }),
+ getAttributeDataTypes(client),
+ ]);
+
+ return json({
+ categories,
+ dataTypes,
+ });
+}
+
+export default function UserAttributesRoute() {
+ const { categories } = useLoaderData<typeof loader>();
+
+ return (
+ <>
+ <AttributeCategoriesTableFilters />
+ <AttributeCategoriesTable
+ data={categories.data ?? []}
+ count={categories.count ?? 0}
+ />
+ <Outlet />
+ </>
+ );
+}
diff --git a/apps/carbon/app/routes/app.users.bulk-edit-permissions.tsx b/apps/carbon/app/routes/app.users.bulk-edit-permissions.tsx
index d0dd2e0aeb..83121094b4 100644
--- a/apps/carbon/app/routes/app.users.bulk-edit-permissions.tsx
+++ b/apps/carbon/app/routes/app.users.bulk-edit-permissions.tsx
@@ -1,7 +1,7 @@
import type { ActionArgs } from "@remix-run/node";
import { redirect } from "@remix-run/node";
import { validationError } from "remix-validated-form";
-import type { Permission } from "~/modules/Users/types";
+import type { Permission } from "~/interfaces/Users/types";
import type { BulkPermissionsQueueData } from "~/queue";
import { bulkPermissionsQueue } from "~/queue";
import { requirePermissions } from "~/services/auth";
diff --git a/apps/carbon/app/routes/app.users.employee-types.$employeeTypeId.tsx b/apps/carbon/app/routes/app.users.employee-types.$employeeTypeId.tsx
index 2d7763d3d9..94f1736636 100644
--- a/apps/carbon/app/routes/app.users.employee-types.$employeeTypeId.tsx
+++ b/apps/carbon/app/routes/app.users.employee-types.$employeeTypeId.tsx
@@ -3,7 +3,7 @@ import { redirect } from "@remix-run/node";
import { json } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
import { validationError } from "remix-validated-form";
-import { EmployeeTypeForm } from "~/modules/Users/EmployeeTypes";
+import { EmployeeTypeForm } from "~/interfaces/Users/EmployeeTypes";
import { requirePermissions } from "~/services/auth";
import {
employeeTypeValidator,
@@ -15,7 +15,7 @@ import {
upsertEmployeeTypePermissions,
} from "~/services/users";
import { flash } from "~/services/session";
-import { assertIsPost } from "~/utils/http";
+import { assertIsPost, notFound } from "~/utils/http";
import { error, success } from "~/utils/result";
export async function loader({ request, params }: LoaderArgs) {
@@ -24,7 +24,7 @@ export async function loader({ request, params }: LoaderArgs) {
});
const { employeeTypeId } = params;
- if (!employeeTypeId) return redirect("/app/users/employee-types");
+ if (!employeeTypeId) throw notFound("employeeTypeId not found");
const [employeeType, employeeTypePermissions] = await Promise.all([
getEmployeeType(client, employeeTypeId),
@@ -32,7 +32,10 @@ export async function loader({ request, params }: LoaderArgs) {
]);
if (employeeType?.data?.protected) {
- return redirect("/app/users/employee-types");
+ return redirect(
+ "/app/users/employee-types",
+ await flash(request, error(null, "Cannot edit a protected employee type"))
+ );
}
return json({
diff --git a/apps/carbon/app/routes/app.users.employee-types.delete.$employeeTypeId.tsx b/apps/carbon/app/routes/app.users.employee-types.delete.$employeeTypeId.tsx
index 580641fb13..ca83aae476 100644
--- a/apps/carbon/app/routes/app.users.employee-types.delete.$employeeTypeId.tsx
+++ b/apps/carbon/app/routes/app.users.employee-types.delete.$employeeTypeId.tsx
@@ -1,19 +1,21 @@
import type { ActionArgs, LoaderArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
import { useLoaderData, useNavigate, useParams } from "@remix-run/react";
-import { DeleteEmployeeTypeModal } from "~/modules/Users/EmployeeTypes";
+import { DeleteEmployeeTypeModal } from "~/interfaces/Users/EmployeeTypes";
import { requirePermissions } from "~/services/auth";
import { deleteEmployeeType, getEmployeeType } from "~/services/users";
import { flash } from "~/services/session";
import { error, success } from "~/utils/result";
+import { notFound } from "~/utils/http";
export async function loader({ request, params }: LoaderArgs) {
const { client } = await requirePermissions(request, {
view: "users",
});
const { employeeTypeId } = params;
+ if (!employeeTypeId) throw notFound("EmployeeTypeId not found");
- const employeeType = await getEmployeeType(client, employeeTypeId!);
+ const employeeType = await getEmployeeType(client, employeeTypeId);
if (employeeType.error) {
return redirect(
"/app/users/employee-types",
diff --git a/apps/carbon/app/routes/app.users.employee-types.new.tsx b/apps/carbon/app/routes/app.users.employee-types.new.tsx
index 68f09266c6..8b271506d9 100644
--- a/apps/carbon/app/routes/app.users.employee-types.new.tsx
+++ b/apps/carbon/app/routes/app.users.employee-types.new.tsx
@@ -3,7 +3,7 @@ import { redirect } from "@remix-run/node";
import { json } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
import { validationError } from "remix-validated-form";
-import { EmployeeTypeForm } from "~/modules/Users/EmployeeTypes";
+import { EmployeeTypeForm } from "~/interfaces/Users/EmployeeTypes";
import { requirePermissions } from "~/services/auth";
import {
employeeTypeValidator,
@@ -117,7 +117,6 @@ export default function NewEmployeeTypesRoute() {
const { permissions } = useLoaderData<typeof loader>();
const initialValues = {
- id: "",
name: "",
color: "#000000",
permissions,
diff --git a/apps/carbon/app/routes/app.users.employee-types.tsx b/apps/carbon/app/routes/app.users.employee-types.tsx
index 53cf4b31ce..3c773eb190 100644
--- a/apps/carbon/app/routes/app.users.employee-types.tsx
+++ b/apps/carbon/app/routes/app.users.employee-types.tsx
@@ -4,7 +4,7 @@ import { Outlet, useLoaderData } from "@remix-run/react";
import {
EmployeeTypesTable,
EmployeeTypesTableFilters,
-} from "~/modules/Users/EmployeeTypes";
+} from "~/interfaces/Users/EmployeeTypes";
import { requirePermissions } from "~/services/auth";
import { getEmployeeTypes } from "~/services/users";
import { getGenericQueryFilters } from "~/utils/query";
diff --git a/apps/carbon/app/routes/app.users.employees.$employeeId.tsx b/apps/carbon/app/routes/app.users.employees.$employeeId.tsx
index 30d3e0a55f..3655414905 100644
--- a/apps/carbon/app/routes/app.users.employees.$employeeId.tsx
+++ b/apps/carbon/app/routes/app.users.employees.$employeeId.tsx
@@ -3,7 +3,7 @@ import { json } from "@remix-run/node";
import { redirect } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
import { validationError } from "remix-validated-form";
-import { EmployeePermissionsForm } from "~/modules/Users/Employees";
+import { EmployeePermissionsForm } from "~/interfaces/Users/Employees";
import { requirePermissions } from "~/services/auth";
import { flash } from "~/services/session";
import {
@@ -14,7 +14,7 @@ import {
makePermissionsFromClaims,
updateEmployee,
} from "~/services/users";
-import { assertIsPost } from "~/utils/http";
+import { assertIsPost, notFound } from "~/utils/http";
import { error } from "~/utils/result";
export async function loader({ request, params }: LoaderArgs) {
@@ -23,7 +23,7 @@ export async function loader({ request, params }: LoaderArgs) {
});
const { employeeId } = params;
- if (!employeeId) return redirect("/app/users/employees");
+ if (!employeeId) throw notFound("EmployeeId was not found");
const [claims, employee] = await Promise.all([
getClaimsById(client, employeeId),
diff --git a/apps/carbon/app/routes/app.users.employees.new.tsx b/apps/carbon/app/routes/app.users.employees.new.tsx
index 8ed542a917..b586be95c6 100644
--- a/apps/carbon/app/routes/app.users.employees.new.tsx
+++ b/apps/carbon/app/routes/app.users.employees.new.tsx
@@ -8,7 +8,7 @@ import {
createEmployeeValidator,
} from "~/services/users";
import { assertIsPost } from "~/utils/http";
-import { CreateEmployeeModal } from "~/modules/Users/Employees";
+import { CreateEmployeeModal } from "~/interfaces/Users/Employees";
export async function action({ request }: ActionArgs) {
assertIsPost(request);
diff --git a/apps/carbon/app/routes/app.users.employees.tsx b/apps/carbon/app/routes/app.users.employees.tsx
index 0d6ea8f3b0..29c3a03882 100644
--- a/apps/carbon/app/routes/app.users.employees.tsx
+++ b/apps/carbon/app/routes/app.users.employees.tsx
@@ -5,7 +5,7 @@ import { usePermissions } from "~/hooks";
import {
EmployeesTable,
EmployeesTableFilters,
-} from "~/modules/Users/Employees";
+} from "~/interfaces/Users/Employees";
import { requirePermissions } from "~/services/auth";
import { getEmployees, getEmployeeTypes } from "~/services/users";
import { getGenericQueryFilters } from "~/utils/query";
diff --git a/apps/carbon/app/routes/app.users.groups.$groupId.tsx b/apps/carbon/app/routes/app.users.groups.$groupId.tsx
index 69e86eecc0..682d54d4ea 100644
--- a/apps/carbon/app/routes/app.users.groups.$groupId.tsx
+++ b/apps/carbon/app/routes/app.users.groups.$groupId.tsx
@@ -3,7 +3,7 @@ import { json } from "@remix-run/node";
import { redirect } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
import { validationError } from "remix-validated-form";
-import { GroupForm } from "~/modules/Users/Groups";
+import { GroupForm } from "~/interfaces/Users/Groups";
import { requirePermissions } from "~/services/auth";
import { flash } from "~/services/session";
import {
@@ -12,7 +12,7 @@ import {
upsertGroup,
upsertGroupMembers,
} from "~/services/users";
-import { assertIsPost } from "~/utils/http";
+import { assertIsPost, notFound } from "~/utils/http";
import { error, success } from "~/utils/result";
export async function loader({ request, params }: LoaderArgs) {
@@ -21,7 +21,7 @@ export async function loader({ request, params }: LoaderArgs) {
});
const { groupId } = params;
- if (!groupId) return redirect("/app/users/groups");
+ if (!groupId) throw notFound("groupId not found");
const groupWithMembers = await getGroupMembersById(client, groupId);
diff --git a/apps/carbon/app/routes/app.users.groups.delete.$groupId.tsx b/apps/carbon/app/routes/app.users.groups.delete.$groupId.tsx
index a5362cd09a..05d2aae398 100644
--- a/apps/carbon/app/routes/app.users.groups.delete.$groupId.tsx
+++ b/apps/carbon/app/routes/app.users.groups.delete.$groupId.tsx
@@ -1,19 +1,21 @@
import type { ActionArgs, LoaderArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
import { useLoaderData, useNavigate, useParams } from "@remix-run/react";
-import { DeleteGroupModal } from "~/modules/Users/Groups";
+import { DeleteGroupModal } from "~/interfaces/Users/Groups";
import { requirePermissions } from "~/services/auth";
import { deleteGroup, getGroup } from "~/services/users";
import { flash } from "~/services/session";
import { error, success } from "~/utils/result";
+import { notFound } from "~/utils/http";
export async function loader({ request, params }: LoaderArgs) {
const { client } = await requirePermissions(request, {
view: "users",
});
const { groupId } = params;
+ if (!groupId) throw notFound("groupId not found");
- const group = await getGroup(client, groupId!);
+ const group = await getGroup(client, groupId);
if (group.error) {
return redirect(
"/app/users/groups",
diff --git a/apps/carbon/app/routes/app.users.groups.new.tsx b/apps/carbon/app/routes/app.users.groups.new.tsx
index 55ea467ae4..b120a2c15d 100644
--- a/apps/carbon/app/routes/app.users.groups.new.tsx
+++ b/apps/carbon/app/routes/app.users.groups.new.tsx
@@ -2,7 +2,7 @@ import type { ActionArgs } from "@remix-run/node";
import { redirect } from "@remix-run/node";
import { json } from "@remix-run/node";
import { validationError } from "remix-validated-form";
-import { GroupForm } from "~/modules/Users/Groups";
+import { GroupForm } from "~/interfaces/Users/Groups";
import { flash } from "~/services/session";
import { assertIsPost } from "~/utils/http";
import { error, success } from "~/utils/result";
@@ -69,7 +69,6 @@ export async function action({ request }: ActionArgs) {
export default function NewGroupRoute() {
const initialValues = {
- id: "",
name: "",
selections: [],
};
diff --git a/apps/carbon/app/routes/app.users.groups.tsx b/apps/carbon/app/routes/app.users.groups.tsx
index 51530f4d1b..2b45afdc5e 100644
--- a/apps/carbon/app/routes/app.users.groups.tsx
+++ b/apps/carbon/app/routes/app.users.groups.tsx
@@ -2,8 +2,8 @@ import type { LoaderArgs } from "@remix-run/node";
import { json } from "@remix-run/node";
import { Outlet, useLoaderData } from "@remix-run/react";
import { arrayToTree } from "performant-array-to-tree";
-import { GroupsTable, GroupsTableFilters } from "~/modules/Users/Groups";
-import type { Group } from "~/modules/Users/types";
+import { GroupsTable, GroupsTableFilters } from "~/interfaces/Users/Groups";
+import type { Group } from "~/interfaces/Users/types";
import { requirePermissions } from "~/services/auth";
import { flash } from "~/services/session";
import { getGroups } from "~/services/users";
diff --git a/apps/carbon/app/routes/app.users.tsx b/apps/carbon/app/routes/app.users.tsx
index 7e82820764..919b49f62f 100644
--- a/apps/carbon/app/routes/app.users.tsx
+++ b/apps/carbon/app/routes/app.users.tsx
@@ -3,7 +3,7 @@ import { Button, Grid, Text, VStack } from "@chakra-ui/react";
import type { MetaFunction } from "@remix-run/node";
import { Link, Outlet, useMatches } from "@remix-run/react";
import { ContentSidebar } from "~/components/Layout/Sidebar";
-import { useUsersSidebar } from "~/modules/Users";
+import { useUsersSidebar } from "~/interfaces/Users";
export const meta: MetaFunction = () => ({
title: "Carbon | Users",
diff --git a/apps/carbon/app/routes/resource.users.groups.tsx b/apps/carbon/app/routes/resource.users.groups.tsx
index cef561ebd2..c381f2bab5 100644
--- a/apps/carbon/app/routes/resource.users.groups.tsx
+++ b/apps/carbon/app/routes/resource.users.groups.tsx
@@ -1,7 +1,7 @@
import type { LoaderArgs } from "@remix-run/node";
import { json } from "@remix-run/node";
import { arrayToTree } from "performant-array-to-tree";
-import type { Group } from "~/modules/Users/types";
+import type { Group } from "~/interfaces/Users/types";
import { requirePermissions } from "~/services/auth";
import { flash } from "~/services/session";
import { error } from "~/utils/result";
diff --git a/apps/carbon/app/services/account/account.form.ts b/apps/carbon/app/services/account/account.form.ts
index c0efda5ca7..daa26cbf7e 100644
--- a/apps/carbon/app/services/account/account.form.ts
+++ b/apps/carbon/app/services/account/account.form.ts
@@ -1,5 +1,6 @@
import { withZod } from "@remix-validated-form/with-zod";
import { z } from "zod";
+import { zfd } from "zod-form-data";
export const accountProfileValidator = withZod(
z.object({
@@ -31,3 +32,44 @@ export const accountPasswordValidator = withZod(
);
export const accountPersonalDataValidator = withZod(z.object({}));
+
+const attributeDefaults = {
+ type: z.string().min(1, { message: "Type is required" }),
+ userAttributeId: zfd.numeric(),
+ userAttributeValueId: zfd.numeric(z.number().optional()),
+};
+
+export const attributeBooleanValidator = withZod(
+ z.object({
+ ...attributeDefaults,
+ value: zfd.checkbox(),
+ })
+);
+
+export const attributeNumericValidator = withZod(
+ z.object({
+ ...attributeDefaults,
+ value: zfd.numeric(z.number()),
+ })
+);
+
+export const attributeTextValidator = withZod(
+ z.object({
+ ...attributeDefaults,
+ value: z.string().min(1, { message: "Value is required" }),
+ })
+);
+
+export const attributeUserValidator = withZod(
+ z.object({
+ ...attributeDefaults,
+ value: z.string().min(36, { message: "User is required" }),
+ })
+);
+
+export const deleteUserAttributeValueValidator = withZod(
+ z.object({
+ userAttributeId: zfd.numeric(),
+ userAttributeValueId: zfd.numeric(),
+ })
+);
diff --git a/apps/carbon/app/services/account/account.server.ts b/apps/carbon/app/services/account/account.server.ts
index 045f5b1fc1..5d004b64dd 100644
--- a/apps/carbon/app/services/account/account.server.ts
+++ b/apps/carbon/app/services/account/account.server.ts
@@ -1,13 +1,63 @@
import type { Database } from "@carbon/database";
import type { SupabaseClient } from "@supabase/supabase-js";
-export async function getAccountById(
+export async function deleteUserAttributeValue(
client: SupabaseClient<Database>,
- id: string
+ args: {
+ userId: string;
+ userAttributeId: number;
+ userAttributeValueId: number;
+ }
) {
+ return client
+ .from("userAttributeValue")
+ .delete()
+ .eq("id", args.userAttributeValueId)
+ .eq("userAttributeId", args.userAttributeId)
+ .eq("userId", args.userId);
+}
+
+export async function getAccount(client: SupabaseClient<Database>, id: string) {
return client.from("user").select("*").eq("id", id).single();
}
+export async function getAttributes(
+ client: SupabaseClient<Database>,
+ userId: string,
+ isPublic: boolean
+) {
+ return client
+ .from("userAttributeCategory")
+ .select(
+ `id, name, id,
+ userAttribute(id, name, listOptions, canSelfManage,
+ attributeDataType(id, isBoolean, isDate, isNumeric, isText, isUser),
+ userAttributeValue(
+ id, valueBoolean, valueDate, valueNumeric, valueText, valueUser
+ )
+ )`
+ )
+ .eq("public", isPublic)
+ .eq("active", true)
+ .eq("userAttribute.active", true)
+ .eq("userAttribute.userAttributeValue.userId", userId)
+ .order("sortOrder", { foreignTable: "userAttribute", ascending: true });
+}
+
+export async function getPrivateAttributes(
+ client: SupabaseClient<Database>,
+ userId: string
+) {
+ return getAttributes(client, userId, false);
+}
+
+export async function getPublicAttributes(
+ client: SupabaseClient<Database>,
+ userId: string
+) {
+ return getAttributes(client, userId, true);
+}
+
export async function updateAvatar(
client: SupabaseClient<Database>,
userId: string,
@@ -40,3 +90,71 @@ export async function updatePublicAccount(
})
.eq("id", id);
}
+
+export async function upsertUserAttributeValue(
+ client: SupabaseClient<Database>,
+ update: {
+ userAttributeValueId?: number | undefined;
+ userAttributeId: number;
+ value: boolean | string | number;
+ type: string;
+ userId: string;
+ updatedBy: string;
+ }
+) {
+ const {
+ userAttributeValueId,
+ userAttributeId,
+ value,
+ type,
+ userId,
+ updatedBy,
+ } = update;
+
+ let valueUpdate: Record<string, number | string | boolean> = {};
+
+ if (type === "boolean" && typeof value === "boolean") {
+ valueUpdate = { valueBoolean: value };
+ }
+
+ if (type === "date" && typeof value === "string") {
+ valueUpdate = { valueDate: value };
+ }
+
+ if (type === "list" && typeof value === "string") {
+ valueUpdate = { valueText: value };
+ }
+
+ if (type === "numeric" && typeof value === "number") {
+ valueUpdate = { valueNumeric: value };
+ }
+
+ if (type === "text" && typeof value === "string") {
+ valueUpdate = { valueText: value };
+ }
+
+ if (type === "user" && typeof value === "string") {
+ valueUpdate = { valueUser: value };
+ }
+
+ if (userAttributeValueId) {
+ return client
+ .from("userAttributeValue")
+ .update({
+ ...valueUpdate,
+ updatedBy,
+ })
+ .eq("id", userAttributeValueId)
+ .select("id");
+ } else {
+ return client
+ .from("userAttributeValue")
+ .insert({
+ userAttributeId,
+ ...valueUpdate,
+ userId,
+ createdBy: updatedBy,
+ })
+ .select("id");
+ }
+}
diff --git a/apps/carbon/app/services/users/users.form.ts b/apps/carbon/app/services/users/users.form.ts
index f8da6fb9de..151a6e05fb 100644
--- a/apps/carbon/app/services/users/users.form.ts
+++ b/apps/carbon/app/services/users/users.form.ts
@@ -1,5 +1,39 @@
import { withZod } from "@remix-validated-form/with-zod";
import { z } from "zod";
+import { zfd } from "zod-form-data";
+import { DataType } from "~/interfaces/Users/types";
+
+export const attributeValidator = withZod(
+ z
+ .object({
+ id: zfd.numeric(z.number().optional()),
+ name: z.string().min(1, { message: "Name is required" }),
+ userAttributeCategoryId: zfd.numeric(),
+ attributeDataTypeId: zfd.numeric(),
+ listOptions: z.string().min(1).array().optional(),
+ canSelfManage: zfd.checkbox(),
+ })
+ .refine((input) => {
+ // allows bar to be optional only when foo is 'foo'
+ if (
+ input.attributeDataTypeId === DataType.List &&
+ (input.listOptions === undefined ||
+ input.listOptions.length === 0 ||
+ input.listOptions.some((option) => option.length === 0))
+ )
+ return false;
+
+ return true;
+ })
+);
+
+export const attributeCategoryValidator = withZod(
+ z.object({
+ id: zfd.numeric(z.number().optional()),
+ name: z.string().min(1, { message: "Name is required" }),
+ isPublic: zfd.checkbox(),
+ })
+);
export const bulkPermissionsValidator = withZod(
z.object({
diff --git a/apps/carbon/app/services/users/users.server.ts b/apps/carbon/app/services/users/users.server.ts
index 7c06eae0be..d1798a4b2e 100644
--- a/apps/carbon/app/services/users/users.server.ts
+++ b/apps/carbon/app/services/users/users.server.ts
@@ -9,7 +9,7 @@ import type {
Feature,
Permission,
User,
-} from "~/modules/Users/types";
+} from "~/interfaces/Users/types";
import { deleteAuthAccount, sendInviteByEmail } from "~/services/auth";
import { requireAuthSession, flash } from "~/services/session";
import type { Result } from "~/types";
@@ -108,6 +108,27 @@ async function createUser(
return { data, error };
}
+export async function deleteAttribute(
+ client: SupabaseClient<Database>,
+ attributeId: string
+) {
+ return client
+ .from("userAttribute")
+ .update({ active: false })
+ .eq("id", attributeId);
+}
+
+export async function deleteAttributeCategory(
+ client: SupabaseClient<Database>,
+ attributeCategoryId: string
+) {
+ console.log("deleting attribute category", attributeCategoryId);
+ return client
+ .from("userAttributeCategory")
+ .update({ active: false })
+ .eq("id", attributeCategoryId);
+}
+
export async function deleteEmployeeType(
client: SupabaseClient<Database>,
employeeTypeId: string
@@ -122,6 +143,69 @@ export async function deleteGroup(
return client.from("group").delete().eq("id", groupId);
}
+export async function getAttribute(
+ client: SupabaseClient<Database>,
+ attributeId: number
+) {
+ return client
+ .from("userAttribute")
+ .select(
+ "id, name, sortOrder, listOptions, attributeDataTypeId, userAttributeCategoryId, canSelfManage, userAttributeCategory(name)"
+ )
+ .eq("id", attributeId)
+ .eq("active", true)
+ .single();
+}
+
+export async function getAttributeCategories(
+ client: SupabaseClient<Database>,
+ args: { name: string | null } & GenericQueryFilters
+) {
+ let query = client
+ .from("userAttributeCategory")
+ .select("id, name, public, protected, userAttribute(id, name)", {
+ count: "exact",
+ })
+ .eq("active", true)
+ .eq("userAttribute.active", true);
+
+ if (args?.name) {
+ query = query.ilike("name", `%${args.name}%`);
+ }
+
+ if (args) {
+ query = setGenericQueryFilters(query, args, "name");
+ }
+
+ return query;
+}
+
+export async function getAttributeCategory(
+ client: SupabaseClient<Database>,
+ id: number
+) {
+ return client
+ .from("userAttributeCategory")
+ .select(
+ `id, name, public, protected,
+ userAttribute(
+ id, name, sortOrder,
+ attributeDataType(id, label, isBoolean, isDate, isList, isNumeric, isText, isUser ))
+ `,
+ {
+ count: "exact",
+ }
+ )
+ .eq("id", id)
+ .eq("active", true)
+ .eq("userAttribute.active", true)
+ .single();
+}
+
+export async function getAttributeDataTypes(client: SupabaseClient<Database>) {
+ return client.from("attributeDataType").select("*");
+}
+
export async function getClaimsById(
client: SupabaseClient<Database>,
uid: string
@@ -291,7 +375,7 @@ export async function getPermissions(
}
}
-export async function getUser(
+export async function getCurrentUser(
request: Request,
client: SupabaseClient<Database>
) {
@@ -312,7 +396,12 @@ export async function getUserById(
client: SupabaseClient<Database>,
id: string
) {
- return client.from("user").select("*").eq("id", id).single();
+ return client
+ .from("user")
+ .select("*")
+ .eq("id", id)
+ .eq("active", true)
+ .single();
}
export async function getUserByEmail(email: string) {
@@ -327,9 +416,52 @@ export async function getUsers(client: SupabaseClient<Database>) {
return client
.from("user")
.select("id, firstName, lastName, fullName, email, avatarUrl")
+ .eq("active", true)
.order("lastName");
}
+export async function insertAttribute(
+ client: SupabaseClient<Database>,
+ attribute: {
+ name: string;
+ attributeDataTypeId: number;
+ userAttributeCategoryId: number;
+ listOptions?: string[];
+ canSelfManage: boolean;
+ createdBy: string;
+ }
+) {
+ // TODO: there's got to be a better way to get the max
+ const sortOrders = await client
+ .from("userAttribute")
+ .select("sortOrder")
+ .eq("userAttributeCategoryId", attribute.userAttributeCategoryId);
+
+ if (sortOrders.error) return sortOrders;
+ const maxSortOrder = sortOrders.data.reduce((max, item) => {
+ return Math.max(max, item.sortOrder);
+ }, 0);
+
+ return client
+ .from("userAttribute")
+ .upsert([{ ...attribute, sortOrder: maxSortOrder + 1 }])
+ .select("id");
+}
+
+export async function insertAttributeCategory(
+ client: SupabaseClient<Database>,
+ attributeCategory: {
+ name: string;
+ public: boolean;
+ createdBy: string;
+ }
+) {
+ return client
+ .from("userAttributeCategory")
+ .upsert([attributeCategory])
+ .select("id");
+}
+
export async function insertEmployee(
client: SupabaseClient<Database>,
employee: EmployeeRow
@@ -548,6 +680,55 @@ export async function updatePermissions(
}
}
+export async function updateAttribute(
+ client: SupabaseClient<Database>,
+ attribute: {
+ id?: number;
+ name: string;
+ listOptions?: string[];
+ canSelfManage: boolean;
+ updatedBy: string;
+ }
+) {
+ if (!attribute.id) throw new Error("id is required");
+ return client
+ .from("userAttribute")
+ .update({
+ name: attribute.name,
+ listOptions: attribute.listOptions,
+ canSelfManage: attribute.canSelfManage,
+ updatedBy: attribute.updatedBy,
+ })
+ .eq("id", attribute.id);
+}
+
+export async function updateAttributeCategory(
+ client: SupabaseClient<Database>,
+ attributeCategory: {
+ id: number;
+ name: string;
+ public: boolean;
+ updatedBy: string;
+ }
+) {
+ const { id, ...update } = attributeCategory;
+ return client.from("userAttributeCategory").update(update).eq("id", id);
+}
+
+export async function updateAttributeSortOrder(
+ client: SupabaseClient<Database>,
+ updates: {
+ id: number;
+ sortOrder: number;
+ updatedBy: string;
+ }[]
+) {
+ const updatePromises = updates.map(({ id, sortOrder, updatedBy }) =>
+ client.from("userAttribute").update({ sortOrder, updatedBy }).eq("id", id)
+ );
+ return Promise.all(updatePromises);
+}
+
export async function upsertEmployeeType(
client: SupabaseClient<Database>,
employeeType: { id?: string; name: string; color: string | null }
diff --git a/apps/carbon/app/utils/form.ts b/apps/carbon/app/utils/form.ts
index 739f870315..0a72d575c3 100644
--- a/apps/carbon/app/utils/form.ts
+++ b/apps/carbon/app/utils/form.ts
@@ -15,14 +15,17 @@ export const mapRowsToOptions = <T extends Record<string, any>>({
}) => {
if (!data) return [];
- return data.reduce<{ value: string; label: string }[]>((acc, row) => {
- const v = row[value];
- const l = typeof label === "function" ? label(row) : row[label];
+ return data.reduce<{ value: string | number; label: string }[]>(
+ (acc, row) => {
+ const v = row[value];
+ const l = typeof label === "function" ? label(row) : row[label];
- if (v && l) {
- return [...acc, { label: l, value: v }];
- }
+ if (v && l) {
+ return [...acc, { label: l, value: v }];
+ }
- return acc;
- }, []);
+ return acc;
+ },
+ []
+ );
};
diff --git a/apps/carbon/package.json b/apps/carbon/package.json
index 15f938b557..5c5f91a6f6 100644
--- a/apps/carbon/package.json
+++ b/apps/carbon/package.json
@@ -12,10 +12,11 @@
},
"dependencies": {
"@chakra-ui/react": "^2.4.1",
- "@chakra-ui/skip-nav": "^2.0.12",
+ "@chakra-ui/skip-nav": "^2.0.13",
"@emotion/react": "^11.10.4",
"@emotion/server": "^11.10.0",
"@emotion/styled": "^11.10.4",
+ "@internationalized/date": "^3.0.2",
"@remix-run/eslint-config": "^1.9.0",
"@remix-run/node": "^1.9.0",
"@remix-run/react": "^1.9.0",
@@ -37,9 +38,10 @@
"react-dom": "^18.2.0",
"react-icons": "4.6.0",
"reactflow": "^11.3.3",
- "remix-flat-routes": "^0.4.8",
- "remix-validated-form": "^4.6.4",
- "zod": "^3.19.1"
+ "remix-flat-routes": "^0.5.4",
+ "remix-validated-form": "^4.6.5",
+ "zod": "^3.20.2",
+ "zod-form-data": "1.2.4"
},
"devDependencies": {
"@remix-run/dev": "^1.8.2",
diff --git a/packages/carbon-database/prisma/migrations/20221121124933_claims/migration.sql b/packages/carbon-database/prisma/migrations/20221121000000_claims/migration.sql
similarity index 100%
rename from packages/carbon-database/prisma/migrations/20221121124933_claims/migration.sql
rename to packages/carbon-database/prisma/migrations/20221121000000_claims/migration.sql
diff --git a/packages/carbon-database/prisma/migrations/20221122043019_user/migration.sql b/packages/carbon-database/prisma/migrations/20221122000000_user/migration.sql
similarity index 90%
rename from packages/carbon-database/prisma/migrations/20221122043019_user/migration.sql
rename to packages/carbon-database/prisma/migrations/20221122000000_user/migration.sql
index db2d89f9a5..df1a6491c6 100644
--- a/packages/carbon-database/prisma/migrations/20221122043019_user/migration.sql
+++ b/packages/carbon-database/prisma/migrations/20221122000000_user/migration.sql
@@ -6,6 +6,7 @@ CREATE TABLE "user" (
"fullName" TEXT GENERATED ALWAYS AS ("firstName" || ' ' || "lastName") STORED,
"about" TEXT NOT NULL DEFAULT '',
"avatarUrl" TEXT,
+ "active" BOOLEAN DEFAULT TRUE,
"emailVerified" TIMESTAMP(3),
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT NOW(),
"updatedAt" TIMESTAMP(3),
diff --git a/packages/carbon-database/prisma/migrations/20221126132027_employee_type/migration.sql b/packages/carbon-database/prisma/migrations/20221126000000_employee_type/migration.sql
similarity index 100%
rename from packages/carbon-database/prisma/migrations/20221126132027_employee_type/migration.sql
rename to packages/carbon-database/prisma/migrations/20221126000000_employee_type/migration.sql
diff --git a/packages/carbon-database/prisma/migrations/20221126133855_permissions/migration.sql b/packages/carbon-database/prisma/migrations/20221126000000_permissions/migration.sql
similarity index 100%
rename from packages/carbon-database/prisma/migrations/20221126133855_permissions/migration.sql
rename to packages/carbon-database/prisma/migrations/20221126000000_permissions/migration.sql
diff --git a/packages/carbon-database/prisma/migrations/20221202032804_employee/migration.sql b/packages/carbon-database/prisma/migrations/20221202000000_employee/migration.sql
similarity index 100%
rename from packages/carbon-database/prisma/migrations/20221202032804_employee/migration.sql
rename to packages/carbon-database/prisma/migrations/20221202000000_employee/migration.sql
diff --git a/packages/carbon-database/prisma/migrations/20221208201232_groups/migration.sql b/packages/carbon-database/prisma/migrations/20221208000000_groups/migration.sql
similarity index 100%
rename from packages/carbon-database/prisma/migrations/20221208201232_groups/migration.sql
rename to packages/carbon-database/prisma/migrations/20221208000000_groups/migration.sql
diff --git a/packages/carbon-database/prisma/migrations/20221223438102_buckets/migration.sql b/packages/carbon-database/prisma/migrations/20221223000000_buckets/migration.sql
similarity index 100%
rename from packages/carbon-database/prisma/migrations/20221223438102_buckets/migration.sql
rename to packages/carbon-database/prisma/migrations/20221223000000_buckets/migration.sql
diff --git a/packages/carbon-database/prisma/migrations/20221227000000_attributes/migration.sql b/packages/carbon-database/prisma/migrations/20221227000000_attributes/migration.sql
new file mode 100644
index 0000000000..6dbdc9e880
--- /dev/null
+++ b/packages/carbon-database/prisma/migrations/20221227000000_attributes/migration.sql
@@ -0,0 +1,179 @@
+
+CREATE TABLE "userAttributeCategory" (
+ "id" SERIAL PRIMARY KEY,
+ "name" TEXT NOT NULL,
+ "public" BOOLEAN DEFAULT FALSE,
+ "protected" BOOLEAN DEFAULT FALSE,
+ "active" BOOLEAN DEFAULT TRUE,
+ "createdAt" TIMESTAMP(3) DEFAULT now() NOT NULL,
+ "createdBy" TEXT NOT NULL,
+ "updatedAt" TIMESTAMP(3),
+ "updatedBy" TEXT,
+
+ CONSTRAINT "userAttributeCategory_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
+ CONSTRAINT "userAttributeCategory_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
+);
+
+-- ALTER TABLE "userAttributeCategory" ENABLE ROW LEVEL SECURITY;
+
+CREATE TABLE "attributeDataType" (
+ "id" SERIAL PRIMARY KEY,
+ "label" TEXT NOT NULL,
+ "isBoolean" BOOLEAN NOT NULL DEFAULT FALSE,
+ "isDate" BOOLEAN NOT NULL DEFAULT FALSE,
+ "isList" BOOLEAN NOT NULL DEFAULT FALSE,
+ "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
+ "isUser" = false
+ )
+ OR (
+ "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
+ "isUser" = false
+ )
+ OR (
+ "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
+ "isUser" = false
+ )
+ OR (
+ "isBoolean" = false AND
+ "isDate" = false AND
+ "isList" = false AND
+ "isNumeric" = false AND
+ "isText" = false AND
+ "isUser" = true
+ )
+ )
+);
+
+INSERT INTO "attributeDataType" ("label", "isBoolean", "isDate", "isList", "isNumeric", "isText", "isUser")
+VALUES
+ ('Yes/No', true, false, false, false, false, false),
+ ('Date', false, true, false, false, false, false),
+ ('List', false, false, true, false, false, false),
+ ('Numeric', false, false, false, true, false, false),
+ ('Text', false, false, false, false, true, false),
+ ('User', false, false, false, false, false, true);
+
+
+-- ALTER TABLE "attributeDataType" ENABLE ROW LEVEL SECURITY;
+
+CREATE TABLE "userAttribute" (
+ "id" SERIAL PRIMARY KEY,
+ "name" TEXT NOT NULL,
+ "sortOrder" INTEGER NOT NULL DEFAULT 1,
+ "userAttributeCategoryId" INTEGER NOT NULL,
+ "attributeDataTypeId" INTEGER NOT NULL,
+ "listOptions" TEXT ARRAY,
+ "canSelfManage" BOOLEAN DEFAULT FALSE,
+ "active" BOOLEAN DEFAULT TRUE,
+ "createdAt" TIMESTAMP(3) DEFAULT now() NOT NULL,
+ "createdBy" TEXT NOT NULL,
+ "updatedAt" TIMESTAMP(3),
+ "updatedBy" TEXT,
+
+ CONSTRAINT "userAttribute_userAttributeCategoryId_fkey" FOREIGN KEY ("userAttributeCategoryId") REFERENCES "userAttributeCategory"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "userAttribute_attributeDataTypeId_fkey" FOREIGN KEY ("attributeDataTypeId") REFERENCES "attributeDataType"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "userAttribute_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
+ CONSTRAINT "userAttribute_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
+
+);
+
+-- ALTER TABLE "userAttribute" ENABLE ROW LEVEL SECURITY;
+
+CREATE TABLE "userAttributeValue" (
+ "id" SERIAL PRIMARY KEY,
+ "userAttributeId" INTEGER NOT NULL,
+ "userId" TEXT NOT NULL,
+ "valueBoolean" BOOLEAN,
+ "valueDate" DATE,
+ "valueNumeric" NUMERIC,
+ "valueText" TEXT,
+ "valueUser" TEXT,
+ "createdAt" TIMESTAMP(3) DEFAULT now() NOT NULL,
+ "createdBy" TEXT NOT NULL,
+ "updatedAt" TIMESTAMP(3),
+ "updatedBy" TEXT,
+
+ CONSTRAINT "userAttributeValue_singleValue"
+ CHECK (
+ (
+ "valueBoolean" IS NOT NULL AND
+ "valueDate" IS NULL AND
+ "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,
+ CONSTRAINT "userAttributeValue_valueUser_fkey" FOREIGN KEY ("valueUser") REFERENCES "user"("id") ON DELETE CASCADE,
+ 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
+ UNIQUE ( "userAttributeId", "userId")
+);
+
+-- ALTER TABLE "userAttributeValue" ENABLE ROW LEVEL SECURITY;
\ No newline at end of file
diff --git a/packages/carbon-database/prisma/schema.prisma b/packages/carbon-database/prisma/schema.prisma
index 041428327f..68e877b69b 100644
--- a/packages/carbon-database/prisma/schema.prisma
+++ b/packages/carbon-database/prisma/schema.prisma
@@ -8,10 +8,11 @@ datasource db {
}
model employee {
- id String @id
- employeeTypeId String
- employeeType employeeType @relation(fields: [employeeTypeId], references: [id], onDelete: NoAction, onUpdate: NoAction)
- user user @relation(fields: [id], references: [id], onDelete: Cascade, onUpdate: NoAction)
+ id String @id
+ employeeTypeId String
+ employeeType employeeType @relation(fields: [employeeTypeId], references: [id], onDelete: NoAction, onUpdate: NoAction)
+ user user @relation(fields: [id], references: [id], onDelete: Cascade, onUpdate: NoAction)
+ employeePersonalData employeePersonalData?
}
model employeeType {
@@ -49,16 +50,25 @@ model feature {
}
model user {
- id String @id
- email String @unique
- firstName String
- lastName String
- fullName String? @default(dbgenerated("((\"firstName\" || ' '::text) || \"lastName\")"))
- emailVerified DateTime?
- createdAt DateTime @default(now())
- updatedAt DateTime?
- employee employee?
- membership membership[]
+ id String @id
+ email String @unique
+ firstName String
+ lastName String
+ fullName String? @default(dbgenerated("((\"firstName\" || ' '::text) || \"lastName\")"))
+ about String @default("")
+ avatarUrl String?
+ emailVerified DateTime?
+ createdAt DateTime @default(now())
+ updatedAt DateTime?
+ attribute_attribute_createdByTouser attribute[] @relation("attribute_createdByTouser")
+ attribute_attribute_updatedByTouser attribute[] @relation("attribute_updatedByTouser")
+ attributeCategory_attributeCategory_createdByTouser attributeCategory[] @relation("attributeCategory_createdByTouser")
+ attributeCategory_attributeCategory_updatedByTouser attributeCategory[] @relation("attributeCategory_updatedByTouser")
+ attributeValue_attributeValue_createdByTouser attributeValue[] @relation("attributeValue_createdByTouser")
+ attributeValue_attributeValue_updatedByTouser attributeValue[] @relation("attributeValue_updatedByTouser")
+ attributeValue_attributeValue_userIdTouser attributeValue[] @relation("attributeValue_userIdTouser")
+ employee employee?
+ membership membership[]
@@index([fullName], map: "user_fullName_key")
}
@@ -88,3 +98,74 @@ model membership {
@@index([memberGroupId], map: "index_membership_membergroupid")
@@index([memberUserId], map: "index_membership_memberuserid")
}
+
+model attributeDataType {
+ id Int @id @default(autoincrement())
+ label String
+ value String
+ isBoolean Boolean @default(false)
+ isDate Boolean @default(false)
+ isList Boolean @default(false)
+ isNumeric Boolean @default(false)
+ isText Boolean @default(false)
+ attribute attribute[]
+}
+
+model employeePersonalData {
+ id String @id
+ employee employee @relation(fields: [id], references: [id], onDelete: Cascade, onUpdate: NoAction)
+}
+
+model attribute {
+ id Int @id @default(autoincrement())
+ label String
+ sortOrder Int @default(1)
+ attributeCategoryId Int
+ attributeDataTypeId Int
+ listOptions String[]
+ canSelfManage Boolean? @default(false)
+ isActive Boolean? @default(true)
+ createdAt DateTime @default(now())
+ createdBy String
+ updatedAt DateTime?
+ updatedBy String?
+ attributeCategory attributeCategory @relation(fields: [attributeCategoryId], references: [id], onDelete: Cascade)
+ attributeDataType attributeDataType @relation(fields: [attributeDataTypeId], references: [id], onDelete: Cascade)
+ user_attribute_createdByTouser user @relation("attribute_createdByTouser", fields: [createdBy], references: [id], onDelete: NoAction, onUpdate: NoAction)
+ user_attribute_updatedByTouser user? @relation("attribute_updatedByTouser", fields: [updatedBy], references: [id], onDelete: NoAction, onUpdate: NoAction)
+ attributeValue attributeValue[]
+
+ @@unique([attributeCategoryId, sortOrder], map: "uq_attributecategory_sortorder")
+}
+
+model attributeCategory {
+ id Int @id @default(autoincrement())
+ label String
+ isActive Boolean? @default(true)
+ createdAt DateTime @default(now())
+ createdBy String
+ updatedAt DateTime?
+ updatedBy String?
+ user_attributeCategory_createdByTouser user @relation("attributeCategory_createdByTouser", fields: [createdBy], references: [id], onDelete: NoAction, onUpdate: NoAction)
+ user_attributeCategory_updatedByTouser user? @relation("attributeCategory_updatedByTouser", fields: [updatedBy], references: [id], onDelete: NoAction, onUpdate: NoAction)
+ attribute attribute[]
+}
+
+model attributeValue {
+ id Int @id @default(autoincrement())
+ attributeId Int
+ userId String
+ valueText String?
+ valueDate DateTime? @db.Date
+ valueNumber Decimal? @db.Decimal
+ createdAt DateTime @default(now())
+ createdBy String
+ updatedAt DateTime?
+ updatedBy String?
+ attribute attribute @relation(fields: [attributeId], references: [id], onDelete: Cascade, onUpdate: NoAction)
+ user_attributeValue_createdByTouser user @relation("attributeValue_createdByTouser", fields: [createdBy], references: [id], onDelete: NoAction, onUpdate: NoAction)
+ user_attributeValue_updatedByTouser user? @relation("attributeValue_updatedByTouser", fields: [updatedBy], references: [id], onDelete: NoAction, onUpdate: NoAction)
+ user_attributeValue_userIdTouser user @relation("attributeValue_userIdTouser", fields: [userId], references: [id], onDelete: Cascade, onUpdate: NoAction)
+
+ @@unique([attributeId, userId], map: "uq_attributeid_userid")
+}
diff --git a/packages/carbon-database/src/types.ts b/packages/carbon-database/src/types.ts
index 6303ef299d..ab74853295 100644
--- a/packages/carbon-database/src/types.ts
+++ b/packages/carbon-database/src/types.ts
@@ -41,6 +41,38 @@ export interface Database {
applied_steps_count?: number
}
}
+ attributeDataType: {
+ Row: {
+ id: number
+ label: string
+ isBoolean: boolean
+ isDate: boolean
+ isList: boolean
+ isNumeric: boolean
+ isText: boolean
+ isUser: boolean
+ }
+ Insert: {
+ id?: number
+ label: string
+ isBoolean?: boolean
+ isDate?: boolean
+ isList?: boolean
+ isNumeric?: boolean
+ isText?: boolean
+ isUser?: boolean
+ }
+ Update: {
+ id?: number
+ label?: string
+ isBoolean?: boolean
+ isDate?: boolean
+ isList?: boolean
+ isNumeric?: boolean
+ isText?: boolean
+ isUser?: boolean
+ }
+ }
employee: {
Row: {
id: string
@@ -199,6 +231,7 @@ export interface Database {
fullName: string | null
about: string
avatarUrl: string | null
+ active: boolean | null
emailVerified: string | null
createdAt: string
updatedAt: string | null
@@ -211,6 +244,7 @@ export interface Database {
fullName?: string | null
about?: string
avatarUrl?: string | null
+ active?: boolean | null
emailVerified?: string | null
createdAt?: string
updatedAt?: string | null
@@ -223,11 +257,135 @@ export interface Database {
fullName?: string | null
about?: string
avatarUrl?: string | null
+ active?: boolean | null
emailVerified?: string | null
createdAt?: string
updatedAt?: string | null
}
}
+ userAttribute: {
+ Row: {
+ id: number
+ name: string
+ sortOrder: number
+ userAttributeCategoryId: number
+ attributeDataTypeId: number
+ listOptions: string[] | null
+ canSelfManage: boolean | null
+ active: boolean | null
+ createdAt: string
+ createdBy: string
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Insert: {
+ id?: number
+ name: string
+ sortOrder?: number
+ userAttributeCategoryId: number
+ attributeDataTypeId: number
+ listOptions?: string[] | null
+ canSelfManage?: boolean | null
+ active?: boolean | null
+ createdAt?: string
+ createdBy: string
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Update: {
+ id?: number
+ name?: string
+ sortOrder?: number
+ userAttributeCategoryId?: number
+ attributeDataTypeId?: number
+ listOptions?: string[] | null
+ canSelfManage?: boolean | null
+ active?: boolean | null
+ createdAt?: string
+ createdBy?: string
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ }
+ userAttributeCategory: {
+ Row: {
+ id: number
+ name: string
+ public: boolean | null
+ protected: boolean | null
+ active: boolean | null
+ createdAt: string
+ createdBy: string
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Insert: {
+ id?: number
+ name: string
+ public?: boolean | null
+ protected?: boolean | null
+ active?: boolean | null
+ createdAt?: string
+ createdBy: string
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Update: {
+ id?: number
+ name?: string
+ public?: boolean | null
+ protected?: boolean | null
+ active?: boolean | null
+ createdAt?: string
+ createdBy?: string
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ }
+ userAttributeValue: {
+ Row: {
+ id: number
+ userAttributeId: number
+ userId: string
+ valueBoolean: boolean | null
+ valueDate: string | null
+ valueNumeric: number | null
+ valueText: string | null
+ valueUser: string | null
+ createdAt: string
+ createdBy: string
+ updatedAt: string | null
+ updatedBy: string | null
+ }
+ Insert: {
+ id?: number
+ userAttributeId: number
+ userId: string
+ valueBoolean?: boolean | null
+ valueDate?: string | null
+ valueNumeric?: number | null
+ valueText?: string | null
+ valueUser?: string | null
+ createdAt?: string
+ createdBy: string
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ Update: {
+ id?: number
+ userAttributeId?: number
+ userId?: string
+ valueBoolean?: boolean | null
+ valueDate?: string | null
+ valueNumeric?: number | null
+ valueText?: string | null
+ valueUser?: string | null
+ createdAt?: string
+ createdBy?: string
+ updatedAt?: string | null
+ updatedBy?: string | null
+ }
+ }
}
Views: {
group_member: {
diff --git a/packages/carbon-react/package.json b/packages/carbon-react/package.json
index 3633d64899..2374c46940 100644
--- a/packages/carbon-react/package.json
+++ b/packages/carbon-react/package.json
@@ -24,6 +24,15 @@
"@chakra-ui/react": "^2.4.1",
"@emotion/react": "^11.10.4",
"@emotion/styled": "^11.10.4",
+ "@internationalized/date": "^3.0.2",
+ "@react-aria/button": "^3.6.4",
+ "@react-aria/calendar": "^3.0.5",
+ "@react-aria/datepicker": "^3.2.1",
+ "@react-stately/calendar": "^3.0.5",
+ "@react-stately/datepicker": "^3.2.1",
+ "@react-types/button": "^3.7.0",
+ "@react-types/calendar": "^3.4.0",
+ "@react-types/datepicker": "^3.4.0",
"framer-motion": "^7.5.4",
"react-colorful": "^5.6.1",
"react-hook-form": "^7.37.0",
diff --git a/packages/carbon-react/src/Inputs/Date/DatePicker.tsx b/packages/carbon-react/src/Inputs/Date/DatePicker.tsx
new file mode 100644
index 0000000000..87fea2e1c3
--- /dev/null
+++ b/packages/carbon-react/src/Inputs/Date/DatePicker.tsx
@@ -0,0 +1,53 @@
+import { useRef } from "react";
+import { useDatePickerState } from "@react-stately/datepicker";
+import { useDatePicker } from "@react-aria/datepicker";
+import { MdOutlineCalendarToday, MdOutlineDoNotDisturb } from "react-icons/md";
+import { Box, Icon, InputGroup, InputRightElement } from "@chakra-ui/react";
+import type { DatePickerProps } from "@react-types/datepicker";
+import type { CalendarDate } from "@internationalized/date";
+
+import { FieldButton } from "./components/Button";
+import { Calendar } from "./components/Calendar";
+import { Popover } from "./components/Popover";
+import { StyledField } from "./components/StyledField";
+import DateField from "./components/DateField";
+
+const DatePicker = (props: DatePickerProps<CalendarDate>) => {
+ const state = useDatePickerState({
+ ...props,
+ shouldCloseOnSelect: false,
+ });
+ const ref = useRef<HTMLDivElement>(null);
+ const { groupProps, fieldProps, buttonProps, dialogProps, calendarProps } =
+ useDatePicker(props, state, ref);
+
+ return (
+ <Box position="relative" display="inline-flex" flexDirection="column">
+ <InputGroup {...groupProps} ref={ref} width="auto" display="inline-flex">
+ <StyledField pr="4.5rem">
+ <DateField {...fieldProps} />
+ {state.validationState === "invalid" && (
+ <Icon
+ as={MdOutlineDoNotDisturb}
+ color="red.600"
+ position="absolute"
+ right="12"
+ />
+ )}
+ </StyledField>
+ <InputRightElement>
+ <FieldButton {...buttonProps} isPressed={state.isOpen}>
+ <Icon as={MdOutlineCalendarToday} />
+ </FieldButton>
+ </InputRightElement>
+ </InputGroup>
+ {state.isOpen && (
+ <Popover {...dialogProps} onClose={() => state.setOpen(false)}>
+ <Calendar {...calendarProps} />
+ </Popover>
+ )}
+ </Box>
+ );
+};
+
+export default DatePicker;
diff --git a/packages/carbon-react/src/Inputs/Date/DateRangePicker.tsx b/packages/carbon-react/src/Inputs/Date/DateRangePicker.tsx
new file mode 100644
index 0000000000..0c09950ae1
--- /dev/null
+++ b/packages/carbon-react/src/Inputs/Date/DateRangePicker.tsx
@@ -0,0 +1,78 @@
+import { useRef } from "react";
+import { useDateRangePickerState } from "@react-stately/datepicker";
+import { useDateRangePicker } from "@react-aria/datepicker";
+import { InputGroup, Box, Icon, InputRightElement } from "@chakra-ui/react";
+import type { DateRangePickerProps, DateValue } from "@react-types/datepicker";
+import { MdDoNotDisturbAlt, MdCalendarToday } from "react-icons/md";
+import { FieldButton } from "./components/Button";
+import { RangeCalendar } from "./components/RangeCalendar";
+import { Popover } from "./components/Popover";
+import { StyledField } from "./components/StyledField";
+import DateField from "./components/DateField";
+import TimeField from "./TimePicker";
+
+const DateRangePicker = (props: DateRangePickerProps<DateValue>) => {
+ const state = useDateRangePickerState({
+ ...props,
+ shouldCloseOnSelect: false,
+ });
+ const ref = useRef<HTMLDivElement>(null);
+ const {
+ groupProps,
+ startFieldProps,
+ endFieldProps,
+ buttonProps,
+ dialogProps,
+ calendarProps,
+ } = useDateRangePicker(props, state, ref);
+
+ return (
+ <Box position="relative" display="inline-flex" flexDirection="column">
+ <InputGroup {...groupProps} ref={ref} width="auto" display="inline-flex">
+ <StyledField pr="5.5rem">
+ <DateField {...startFieldProps} />
+ <Box as="span" aria-hidden="true" paddingX="2">
+ –
+ </Box>
+ <DateField {...endFieldProps} />
+ {state.validationState === "invalid" && (
+ <Icon
+ as={MdDoNotDisturbAlt}
+ color="red.600"
+ position="absolute"
+ right="12"
+ />
+ )}
+ </StyledField>
+ <InputRightElement>
+ <FieldButton {...buttonProps} isPressed={state.isOpen}>
+ <Icon as={MdCalendarToday} />
+ </FieldButton>
+ </InputRightElement>
+ </InputGroup>
+ {state.isOpen && (
+ <Popover
+ {...dialogProps}
+ isOpen={state.isOpen}
+ onClose={() => state.setOpen(false)}
+ >
+ <RangeCalendar {...calendarProps} />
+ <Box display="flex" gap="2">
+ <TimeField
+ label="Start time"
+ value={state.timeRange?.start || null}
+ onChange={(v) => state.setTime("start", v)}
+ />
+ <TimeField
+ label="End time"
+ value={state.timeRange?.end || null}
+ onChange={(v) => state.setTime("end", v)}
+ />
+ </Box>
+ </Popover>
+ )}
+ </Box>
+ );
+};
+
+export default DateRangePicker;
diff --git a/packages/carbon-react/src/Inputs/Date/DateTimePicker.tsx b/packages/carbon-react/src/Inputs/Date/DateTimePicker.tsx
new file mode 100644
index 0000000000..c9b4b462ce
--- /dev/null
+++ b/packages/carbon-react/src/Inputs/Date/DateTimePicker.tsx
@@ -0,0 +1,63 @@
+import { useRef } from "react";
+import { useDatePickerState } from "@react-stately/datepicker";
+import { useDatePicker } from "@react-aria/datepicker";
+import { MdOutlineCalendarToday, MdOutlineDoNotDisturb } from "react-icons/md";
+import { Box, Icon, InputGroup, InputRightElement } from "@chakra-ui/react";
+import type { DatePickerProps } from "@react-types/datepicker";
+import type { DateValue } from "@internationalized/date";
+
+import { FieldButton } from "./components/Button";
+import { Calendar } from "./components/Calendar";
+import { Popover } from "./components/Popover";
+import { StyledField } from "./components/StyledField";
+import DateField from "./components/DateField";
+import TimeField from "./TimePicker";
+
+const DateTimePicker = (props: DatePickerProps<DateValue>) => {
+ const state = useDatePickerState({
+ ...props,
+ shouldCloseOnSelect: false,
+ });
+ const ref = useRef<HTMLDivElement>(null);
+ const { groupProps, fieldProps, buttonProps, dialogProps, calendarProps } =
+ useDatePicker(props, state, ref);
+
+ return (
+ <Box position="relative" display="inline-flex" flexDirection="column">
+ <InputGroup {...groupProps} ref={ref} width="auto" display="inline-flex">
+ <StyledField pr="4.5rem">
+ <DateField {...fieldProps} />
+ {state.validationState === "invalid" && (
+ <Icon
+ as={MdOutlineDoNotDisturb}
+ color="red.600"
+ position="absolute"
+ right="12"
+ />
+ )}
+ </StyledField>
+ <InputRightElement>
+ <FieldButton {...buttonProps} isPressed={state.isOpen}>
+ <Icon as={MdOutlineCalendarToday} />
+ </FieldButton>
+ </InputRightElement>
+ </InputGroup>
+ {state.isOpen && (
+ <Popover
+ {...dialogProps}
+ isOpen={state.isOpen}
+ onClose={() => state.setOpen(false)}
+ >
+ <Calendar {...calendarProps} />
+ <TimeField
+ label="Time"
+ value={state.timeValue}
+ onChange={state.setTimeValue}
+ />
+ </Popover>
+ )}
+ </Box>
+ );
+};
+
+export default DateTimePicker;
diff --git a/packages/carbon-react/src/Inputs/Date/TimePicker.tsx b/packages/carbon-react/src/Inputs/Date/TimePicker.tsx
new file mode 100644
index 0000000000..5069d0f2bd
--- /dev/null
+++ b/packages/carbon-react/src/Inputs/Date/TimePicker.tsx
@@ -0,0 +1,33 @@
+import { useRef } from "react";
+import { useLocale } from "@react-aria/i18n";
+import { useTimeFieldState } from "@react-stately/datepicker";
+import type { TimeFieldStateOptions } from "@react-stately/datepicker";
+import { useTimeField } from "@react-aria/datepicker";
+import { Box } from "@chakra-ui/react";
+import { DateSegment } from "./components/DateSegment";
+import { StyledField } from "./components/StyledField";
+
+const TimePicker = (
+ props: Omit<TimeFieldStateOptions, "locale" | "createCalendar">
+) => {
+ const { locale } = useLocale();
+ const state = useTimeFieldState({
+ ...props,
+ locale,
+ });
+
+ const ref = useRef<HTMLDivElement>(null);
+ const { fieldProps } = useTimeField(props, state, ref);
+
+ return (
+ <Box mt={2}>
+ <StyledField {...fieldProps} ref={ref} pr={2}>
+ {state.segments.map((segment, i) => (
+ <DateSegment key={i} segment={segment} state={state} />
+ ))}
+ </StyledField>
+ </Box>
+ );
+};
+
+export default TimePicker;
diff --git a/packages/carbon-react/src/Inputs/Date/components/Button.tsx b/packages/carbon-react/src/Inputs/Date/components/Button.tsx
new file mode 100644
index 0000000000..dc1e8bcc92
--- /dev/null
+++ b/packages/carbon-react/src/Inputs/Date/components/Button.tsx
@@ -0,0 +1,35 @@
+import { useRef } from "react";
+import { useButton } from "@react-aria/button";
+import { Button } from "@chakra-ui/react";
+import type { AriaButtonProps } from "@react-types/button";
+
+export const CalendarButton = (props: AriaButtonProps) => {
+ const ref = useRef<HTMLButtonElement>(null);
+ let { buttonProps } = useButton(props, ref);
+ return (
+ <Button {...buttonProps} ref={ref} size="sm" variant="solid">
+ {props.children}
+ </Button>
+ );
+};
+
+export interface FieldButtonProps extends AriaButtonProps {
+ isPressed: boolean;
+}
+
+export const FieldButton = (props: FieldButtonProps) => {
+ const ref = useRef<HTMLButtonElement>(null);
+ const { buttonProps } = useButton(props, ref);
+ return (
+ <Button
+ {...buttonProps}
+ ref={ref}
+ size="sm"
+ h="1.75rem"
+ mr="2"
+ variant="solid"
+ >
+ {props.children}
+ </Button>
+ );
+};
diff --git a/packages/carbon-react/src/Inputs/Date/components/Calendar.tsx b/packages/carbon-react/src/Inputs/Date/components/Calendar.tsx
new file mode 100644
index 0000000000..de6fa23d1c
--- /dev/null
+++ b/packages/carbon-react/src/Inputs/Date/components/Calendar.tsx
@@ -0,0 +1,41 @@
+import { useRef } from "react";
+import { useCalendarState } from "@react-stately/calendar";
+import type { CalendarProps } from "@react-aria/calendar";
+import { useCalendar } from "@react-aria/calendar";
+import type { DateValue } from "@internationalized/date";
+import { createCalendar } from "@internationalized/date";
+import { BiChevronLeft, BiChevronRight } from "react-icons/bi";
+import { Box, Icon, Heading } from "@chakra-ui/react";
+import { CalendarButton } from "./Button";
+import { CalendarGrid } from "./CalendarGrid";
+
+const locale = "en-US"; // TODO use user's locale
+
+export const Calendar = (props: CalendarProps<DateValue>) => {
+ const state = useCalendarState({
+ ...props,
+ locale,
+ createCalendar,
+ });
+
+ const ref = useRef<HTMLDivElement>(null);
+ const { calendarProps, prevButtonProps, nextButtonProps, title } =
+ useCalendar(props, state);
+
+ return (
+ <div {...calendarProps} ref={ref}>
+ <Box display="flex" alignItems="center" paddingBottom="4">
+ <CalendarButton {...prevButtonProps}>
+ <Icon as={BiChevronLeft} w={6} h={6} />
+ </CalendarButton>
+ <Heading as="h2" size="md" flex="1" textAlign="center">
+ {title}
+ </Heading>
+ <CalendarButton {...nextButtonProps}>
+ <Icon as={BiChevronRight} w={6} h={6} />
+ </CalendarButton>
+ </Box>
+ <CalendarGrid state={state} />
+ </div>
+ );
+};
diff --git a/packages/carbon-react/src/Inputs/Date/components/CalendarCell.tsx b/packages/carbon-react/src/Inputs/Date/components/CalendarCell.tsx
new file mode 100644
index 0000000000..c5adf0fce6
--- /dev/null
+++ b/packages/carbon-react/src/Inputs/Date/components/CalendarCell.tsx
@@ -0,0 +1,41 @@
+import { useRef } from "react";
+import { useCalendarCell } from "@react-aria/calendar";
+import type { CalendarDate } from "@internationalized/date";
+import { isSameMonth } from "@internationalized/date";
+import { Button, Box } from "@chakra-ui/react";
+import type {
+ CalendarState,
+ RangeCalendarState,
+} from "@react-stately/calendar";
+
+export const CalendarCell = ({
+ state,
+ date,
+ currentMonth,
+}: {
+ state: CalendarState | RangeCalendarState;
+ date: CalendarDate;
+ currentMonth: CalendarDate;
+}) => {
+ const ref = useRef<HTMLButtonElement>(null);
+ const { cellProps, buttonProps, isSelected, isInvalid, formattedDate } =
+ useCalendarCell({ date }, state, ref);
+
+ const isOutsideMonth = !isSameMonth(currentMonth, date);
+
+ return (
+ <Box as="td" {...cellProps} textAlign="center">
+ <Button
+ {...buttonProps}
+ ref={ref}
+ hidden={isOutsideMonth}
+ size="sm"
+ colorScheme={isInvalid ? "red" : "blackAlpha"}
+ variant={isSelected ? "solid" : "ghost"}
+ width="100%"
+ >
+ {formattedDate}
+ </Button>
+ </Box>
+ );
+};
diff --git a/packages/carbon-react/src/Inputs/Date/components/CalendarGrid.tsx b/packages/carbon-react/src/Inputs/Date/components/CalendarGrid.tsx
new file mode 100644
index 0000000000..3aebe16730
--- /dev/null
+++ b/packages/carbon-react/src/Inputs/Date/components/CalendarGrid.tsx
@@ -0,0 +1,63 @@
+import { useCalendarGrid } from "@react-aria/calendar";
+import { getWeeksInMonth, endOfMonth } from "@internationalized/date";
+import type { DateDuration } from "@internationalized/date";
+import { CalendarCell } from "./CalendarCell";
+import type {
+ CalendarState,
+ RangeCalendarState,
+} from "@react-stately/calendar";
+
+const locale = "en-US"; // TODO use user's locale
+
+export const CalendarGrid = ({
+ state,
+ offset = {},
+}: {
+ state: CalendarState | RangeCalendarState;
+ offset?: DateDuration;
+}) => {
+ const startDate = state.visibleRange.start.add(offset);
+ const endDate = endOfMonth(startDate);
+ const { gridProps, headerProps, weekDays } = useCalendarGrid(
+ {
+ startDate,
+ endDate,
+ },
+ state
+ );
+
+ // Get the number of weeks in the month so we can render the proper number of rows.
+ const weeksInMonth = getWeeksInMonth(state.visibleRange.start, locale);
+
+ return (
+ <table {...gridProps}>
+ <thead {...headerProps}>
+ <tr>
+ {weekDays.map((day, index) => (
+ <th key={index}>{day}</th>
+ ))}
+ </tr>
+ </thead>
+ <tbody>
+ {[...new Array(weeksInMonth).keys()].map((weekIndex) => (
+ <tr key={weekIndex}>
+ {state
+ .getDatesInWeek(weekIndex, startDate)
+ .map((date, i) =>
+ date ? (
+ <CalendarCell
+ key={i}
+ state={state}
+ date={date}
+ currentMonth={startDate}
+ />
+ ) : (
+ <td key={i} />
+ )
+ )}
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ );
+};
diff --git a/packages/carbon-react/src/Inputs/Date/components/DateField.tsx b/packages/carbon-react/src/Inputs/Date/components/DateField.tsx
new file mode 100644
index 0000000000..67dc9c9bed
--- /dev/null
+++ b/packages/carbon-react/src/Inputs/Date/components/DateField.tsx
@@ -0,0 +1,31 @@
+import { useRef } from "react";
+import { useDateFieldState } from "@react-stately/datepicker";
+import type { AriaDateFieldProps } from "@react-aria/datepicker";
+import { useDateField } from "@react-aria/datepicker";
+import { createCalendar } from "@internationalized/date";
+import type { DateValue } from "@internationalized/date";
+import { Box } from "@chakra-ui/react";
+import { DateSegment } from "./DateSegment";
+
+const locale = "en-US"; // TODO use user's locale;
+
+const DateField = (props: AriaDateFieldProps<DateValue>) => {
+ const state = useDateFieldState({
+ ...props,
+ locale,
+ createCalendar,
+ });
+
+ const ref = useRef<HTMLDivElement>(null);
+ const { fieldProps } = useDateField(props, state, ref);
+
+ return (
+ <Box {...fieldProps} ref={ref} display="flex">
+ {state.segments.map((segment, i) => (
+ <DateSegment key={i} segment={segment} state={state} />
+ ))}
+ </Box>
+ );
+};
+
+export default DateField;
diff --git a/packages/carbon-react/src/Inputs/Date/components/DateSegment.tsx b/packages/carbon-react/src/Inputs/Date/components/DateSegment.tsx
new file mode 100644
index 0000000000..8775ed80f1
--- /dev/null
+++ b/packages/carbon-react/src/Inputs/Date/components/DateSegment.tsx
@@ -0,0 +1,53 @@
+import { Box } from "@chakra-ui/react";
+import { useDateSegment } from "@react-aria/datepicker";
+import type {
+ DateSegment as DateSegmentType,
+ useDateFieldState,
+} from "@react-stately/datepicker";
+import { useRef } from "react";
+import { useColor } from "../../../hooks";
+
+export const DateSegment = ({
+ segment,
+ state,
+}: {
+ segment: DateSegmentType;
+ state: ReturnType<typeof useDateFieldState>;
+}) => {
+ const ref = useRef<HTMLDivElement>(null);
+ const { segmentProps } = useDateSegment(segment, state, ref);
+
+ const lighter = useColor("gray.500");
+ const light = useColor("gray.600");
+ const black = useColor("black");
+
+ return (
+ <Box
+ {...segmentProps}
+ ref={ref}
+ style={{
+ ...segmentProps.style,
+ fontVariantNumeric: "tabular-nums",
+ boxSizing: "content-box",
+ }}
+ minWidth={
+ segment.maxValue !== undefined
+ ? String(segment.maxValue).length + "ch"
+ : undefined
+ }
+ paddingX="0.5"
+ textAlign="end"
+ outline="none"
+ rounded="md"
+ color={
+ segment.isPlaceholder ? lighter : !segment.isEditable ? light : black
+ }
+ _focus={{
+ background: "gray.500",
+ color: "white",
+ }}
+ >
+ {segment.text}
+ </Box>
+ );
+};
diff --git a/packages/carbon-react/src/Inputs/Date/components/Popover.tsx b/packages/carbon-react/src/Inputs/Date/components/Popover.tsx
new file mode 100644
index 0000000000..fcf9540150
--- /dev/null
+++ b/packages/carbon-react/src/Inputs/Date/components/Popover.tsx
@@ -0,0 +1,32 @@
+import { useRef } from "react";
+import { Box, useColorModeValue, useOutsideClick } from "@chakra-ui/react";
+import { useEscape } from "../../../hooks";
+
+export function Popover(props: any) {
+ const ref = useRef();
+ const { popoverRef = ref, onClose, children, ...rest } = props;
+
+ useEscape(onClose);
+ useOutsideClick({
+ ref: popoverRef,
+ handler: onClose,
+ });
+
+ return (
+ <Box
+ ref={popoverRef}
+ background={useColorModeValue("white", "gray.900")}
+ borderRadius="md"
+ position="absolute"
+ zIndex="10"
+ top="100%"
+ boxShadow="lg"
+ marginTop="1"
+ padding="6"
+ outline="none"
+ {...rest}
+ >
+ {children}
+ </Box>
+ );
+}
diff --git a/packages/carbon-react/src/Inputs/Date/components/RangeCalendar.tsx b/packages/carbon-react/src/Inputs/Date/components/RangeCalendar.tsx
new file mode 100644
index 0000000000..22350b517c
--- /dev/null
+++ b/packages/carbon-react/src/Inputs/Date/components/RangeCalendar.tsx
@@ -0,0 +1,46 @@
+import { useRef } from "react";
+import { useRangeCalendarState } from "@react-stately/calendar";
+import type { RangeCalendarProps } from "@react-aria/calendar";
+import { useRangeCalendar } from "@react-aria/calendar";
+import { useLocale } from "@react-aria/i18n";
+import { createCalendar } from "@internationalized/date";
+import type { DateValue } from "@internationalized/date";
+import { FaAngleLeft, FaAngleRight } from "react-icons/fa";
+import { Box, Icon, Heading } from "@chakra-ui/react";
+
+import { CalendarButton } from "./Button";
+import { CalendarGrid } from "./CalendarGrid";
+
+export function RangeCalendar(props: RangeCalendarProps<DateValue>) {
+ const { locale } = useLocale();
+ const state = useRangeCalendarState({
+ ...props,
+ visibleDuration: { months: 2 },
+ locale,
+ createCalendar,
+ });
+
+ const ref = useRef<HTMLDivElement>(null);
+ const { calendarProps, prevButtonProps, nextButtonProps, title } =
+ useRangeCalendar(props, state, ref);
+
+ return (
+ <div {...calendarProps} ref={ref}>
+ <Box display="flex" alignItems="center" paddingBottom="4">
+ <CalendarButton {...prevButtonProps}>
+ <Icon as={FaAngleLeft} w={6} h={6} />
+ </CalendarButton>
+ <Heading as="h2" size="md" flex="1" textAlign="center">
+ {title}
+ </Heading>
+ <CalendarButton {...nextButtonProps}>
+ <Icon as={FaAngleRight} w={6} h={6} />
+ </CalendarButton>
+ </Box>
+ <Box display="flex" gap="8">
+ <CalendarGrid state={state} />
+ <CalendarGrid state={state} offset={{ months: 1 }} />
+ </Box>
+ </div>
+ );
+}
diff --git a/packages/carbon-react/src/Inputs/Date/components/StyledField.tsx b/packages/carbon-react/src/Inputs/Date/components/StyledField.tsx
new file mode 100644
index 0000000000..efd4b158b2
--- /dev/null
+++ b/packages/carbon-react/src/Inputs/Date/components/StyledField.tsx
@@ -0,0 +1,36 @@
+import { Box, useColorModeValue } from "@chakra-ui/react";
+import { forwardRef } from "react";
+import type { HTMLAttributes } from "react";
+
+export type StyledFieldProps = HTMLAttributes<HTMLElement> & {
+ pr: number | string;
+};
+
+export const StyledField = forwardRef<HTMLDivElement, StyledFieldProps>(
+ function Field({ children, ...otherProps }, ref) {
+ return (
+ <Box
+ position="relative"
+ border="1px solid"
+ borderColor={useColorModeValue("gray.300", "gray.600")}
+ rounded="md"
+ transition="all 200ms"
+ display="flex"
+ alignItems="center"
+ px="1"
+ py=".4rem"
+ _hover={{
+ borderColor: "gray.400",
+ }}
+ _focusWithin={{
+ borderColor: "gray.500",
+ boxShadow: "0 0 0 1px var(--chakra-colors-blue-500)",
+ }}
+ {...otherProps}
+ ref={ref}
+ >
+ {children}
+ </Box>
+ );
+ }
+);
diff --git a/packages/carbon-react/src/Inputs/Date/index.ts b/packages/carbon-react/src/Inputs/Date/index.ts
new file mode 100644
index 0000000000..cf2a947339
--- /dev/null
+++ b/packages/carbon-react/src/Inputs/Date/index.ts
@@ -0,0 +1,6 @@
+import TimePicker from "./TimePicker";
+import DatePicker from "./DatePicker";
+import DateTimePicker from "./DateTimePicker";
+import DateRangePicker from "./DateRangePicker";
+
+export { DatePicker, DateTimePicker, DateRangePicker, TimePicker };
diff --git a/packages/carbon-react/src/Inputs/Select/useSelect.ts b/packages/carbon-react/src/Inputs/Select/useSelect.ts
index 0568f73938..68f93a241e 100644
--- a/packages/carbon-react/src/Inputs/Select/useSelect.ts
+++ b/packages/carbon-react/src/Inputs/Select/useSelect.ts
@@ -25,7 +25,7 @@ const useSelect = <
tagVariant,
theme,
selectedOptionStyle = "color",
- selectedOptionColor = "blue",
+ selectedOptionColor = "blackAlpha",
size = "md",
variant = "outline",
onFocus,
@@ -81,7 +81,7 @@ const useSelect = <
/** Ensure that the color used for the selected options is a string */
let realSelectedOptionColor: string = selectedOptionColor;
if (typeof selectedOptionColor !== "string") {
- realSelectedOptionColor = "blue";
+ realSelectedOptionColor = "blackAlpha";
}
let realVariant: Variant = variant;
diff --git a/packages/carbon-react/src/Inputs/index.ts b/packages/carbon-react/src/Inputs/index.ts
index 38857e2adf..783f116581 100644
--- a/packages/carbon-react/src/Inputs/index.ts
+++ b/packages/carbon-react/src/Inputs/index.ts
@@ -1,6 +1,12 @@
-import type { GroupBase } from "react-select";
+import type { GroupBase, OptionProps } from "react-select";
+import {
+ DatePicker,
+ DateTimePicker,
+ DateRangePicker,
+ TimePicker,
+} from "./Date";
import Select from "./Select";
import type { OptionBase } from "./Select/types";
-export type { OptionBase, GroupBase };
-export { Select };
+export type { OptionBase, OptionProps, GroupBase };
+export { DatePicker, DateTimePicker, DateRangePicker, TimePicker, Select };
diff --git a/packages/carbon-react/src/Theme/theme.ts b/packages/carbon-react/src/Theme/theme.ts
index e84702bf62..d3e916bb58 100644
--- a/packages/carbon-react/src/Theme/theme.ts
+++ b/packages/carbon-react/src/Theme/theme.ts
@@ -36,19 +36,30 @@ export const theme = {
borderRadius: "md",
},
},
+ Checkbox: {
+ defaultProps: {
+ colorScheme: "blackAlpha",
+ },
+ },
Input: {
defaultProps: {
borderRadius: "md",
},
},
+ Radio: {
+ defaultProps: {
+ colorScheme: "blackAlpha",
+ },
+ },
Select: {
defaultProps: {
borderRadius: "md",
},
},
- Checkbox: {
- baseStyle: {},
- defaultProps: {},
+ Switch: {
+ defaultProps: {
+ colorScheme: "green",
+ },
},
},
defaultProps: {
diff --git a/packages/carbon-react/src/hooks/index.ts b/packages/carbon-react/src/hooks/index.ts
index 66440ca647..0415f44507 100644
--- a/packages/carbon-react/src/hooks/index.ts
+++ b/packages/carbon-react/src/hooks/index.ts
@@ -1,6 +1,7 @@
import useColor from "./useColor";
import useDebounce from "./useDebounce";
+import useEscape from "./useEscape";
import useHydrated from "./useHydrated";
import useInterval from "./useInterval";
-export { useColor, useDebounce, useHydrated, useInterval };
+export { useColor, useDebounce, useEscape, useHydrated, useInterval };
diff --git a/packages/carbon-react/src/hooks/useEscape.tsx b/packages/carbon-react/src/hooks/useEscape.tsx
new file mode 100644
index 0000000000..eb578910dd
--- /dev/null
+++ b/packages/carbon-react/src/hooks/useEscape.tsx
@@ -0,0 +1,17 @@
+import { useEffect } from "react";
+
+export default function useEscape(
+ callback: ((e?: KeyboardEvent) => void) | (() => void)
+) {
+ useEffect(() => {
+ const listener = (e: KeyboardEvent) => {
+ if (e.key === "Escape") {
+ callback(e);
+ }
+ };
+ document.addEventListener("keydown", listener);
+ return () => {
+ document.removeEventListener("keydown", listener);
+ };
+ }, [callback]);
+}
diff --git a/packages/carbon-react/src/index.tsx b/packages/carbon-react/src/index.tsx
index 44611388f4..7bc84ea855 100644
--- a/packages/carbon-react/src/index.tsx
+++ b/packages/carbon-react/src/index.tsx
@@ -1,5 +1,11 @@
-import type { OptionBase, GroupBase } from "./Inputs";
-import { Select } from "./Inputs";
+import type { OptionBase, OptionProps, GroupBase } from "./Inputs";
+import {
+ DatePicker,
+ DateTimePicker,
+ DateRangePicker,
+ TimePicker,
+ Select,
+} from "./Inputs";
import Loading from "./Loading";
import { ActionMenu } from "./Overlay";
import { useNotification } from "./Message";
@@ -7,14 +13,18 @@ import ThemeProvider, { theme } from "./Theme";
import { ClientOnly } from "./SSR";
import { useColor, useDebounce, useInterval, useHydrated } from "./hooks";
-export type { OptionBase, GroupBase };
+export type { OptionBase, OptionProps, GroupBase };
export {
ActionMenu,
ClientOnly,
+ DatePicker,
+ DateTimePicker,
+ DateRangePicker,
Loading,
Select,
ThemeProvider,
+ TimePicker,
theme,
useColor,
useDebounce,
diff --git a/yarn.lock b/yarn.lock
index a79389919f..bbad51cee6 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1657,10 +1657,10 @@
"@chakra-ui/media-query" "3.2.8"
"@chakra-ui/react-use-previous" "2.0.3"
-"@chakra-ui/skip-nav@^2.0.12":
- version "2.0.12"
- resolved "https://registry.yarnpkg.com/@chakra-ui/skip-nav/-/skip-nav-2.0.12.tgz#f76e2c7646ba45606b5d681c0799d23866201021"
- integrity sha512-4p1rVml+3hVc87BlXxVCEnf1r9cLzUR6DAVC+s7n857pLQBdC2HsMhlt4NwgoJGchDdZz/lnr7sMS0HzTRV45g==
+"@chakra-ui/skip-nav@^2.0.13":
+ version "2.0.13"
+ resolved "https://registry.yarnpkg.com/@chakra-ui/skip-nav/-/skip-nav-2.0.13.tgz#bd84d035c1ecd8c7c728c5bc368d9b03fe11d6d4"
+ integrity sha512-UmFjGlZhSDkFz7OizweG27bs+Ch9dDiibmXQ20lH6qW8k7aZ9IkdIJz9vsFzpbeECsVC6V5D461BoMGjiok/7A==
"@chakra-ui/[email protected]":
version "2.0.13"
@@ -2078,6 +2078,45 @@
dependencies:
"@floating-ui/core" "^1.0.1"
+"@formatjs/[email protected]":
+ version "1.14.3"
+ resolved "https://registry.yarnpkg.com/@formatjs/ecma402-abstract/-/ecma402-abstract-1.14.3.tgz#6428f243538a11126180d121ce8d4b2f17465738"
+ integrity sha512-SlsbRC/RX+/zg4AApWIFNDdkLtFbkq3LNoZWXZCE/nHVKqoIJyaoQyge/I0Y38vLxowUn9KTtXgusLD91+orbg==
+ dependencies:
+ "@formatjs/intl-localematcher" "0.2.32"
+ tslib "^2.4.0"
+
+"@formatjs/[email protected]":
+ version "1.2.7"
+ resolved "https://registry.yarnpkg.com/@formatjs/fast-memoize/-/fast-memoize-1.2.7.tgz#90d5de031fc80e0027b2d4e8a3197b0df4a94457"
+ integrity sha512-hPeM5LXUUjtCKPybWOUAWpv8lpja8Xz+uKprFPJcg5F2Rd+/bf1E0UUsLRpaAgOReAf5HMRtoIgv/UcyPICrTQ==
+ dependencies:
+ tslib "^2.4.0"
+
+"@formatjs/[email protected]":
+ version "2.1.14"
+ resolved "https://registry.yarnpkg.com/@formatjs/icu-messageformat-parser/-/icu-messageformat-parser-2.1.14.tgz#d7bc8c82bfce1eb8e3232e6d7e3d6ea92ba390cc"
+ integrity sha512-0KqeVOb72losEhUW+59vhZGGd14s1f35uThfEMVKZHKLEObvJdFTiI3ZQwvTMUCzLEMxnS6mtnYPmG4mTvwd3Q==
+ dependencies:
+ "@formatjs/ecma402-abstract" "1.14.3"
+ "@formatjs/icu-skeleton-parser" "1.3.18"
+ tslib "^2.4.0"
+
+"@formatjs/[email protected]":
+ version "1.3.18"
+ resolved "https://registry.yarnpkg.com/@formatjs/icu-skeleton-parser/-/icu-skeleton-parser-1.3.18.tgz#7aed3d60e718c8ad6b0e64820be44daa1e29eeeb"
+ integrity sha512-ND1ZkZfmLPcHjAH1sVpkpQxA+QYfOX3py3SjKWMUVGDow18gZ0WPqz3F+pJLYQMpS2LnnQ5zYR2jPVYTbRwMpg==
+ dependencies:
+ "@formatjs/ecma402-abstract" "1.14.3"
+ tslib "^2.4.0"
+
+"@formatjs/[email protected]":
+ version "0.2.32"
+ resolved "https://registry.yarnpkg.com/@formatjs/intl-localematcher/-/intl-localematcher-0.2.32.tgz#00d4d307cd7d514b298e15a11a369b86c8933ec1"
+ integrity sha512-k/MEBstff4sttohyEpXxCmC3MqbUn9VvHGlZ8fauLzkbwXmVrEeyzS+4uhrvAk9DWU9/7otYWxyDox4nT/KVLQ==
+ dependencies:
+ tslib "^2.4.0"
+
"@gar/promisify@^1.0.1":
version "1.1.3"
resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6"
@@ -2111,6 +2150,35 @@
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45"
integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==
+"@internationalized/date@^3.0.2":
+ version "3.0.2"
+ resolved "https://registry.yarnpkg.com/@internationalized/date/-/date-3.0.2.tgz#1566a0bcbd82dce4dd54a5b26456bb701068cb89"
+ integrity sha512-9V1IxesP6ASZj/hYyOXOC4yPJvidbbStyWQKLCQSqhhKACMOXoo+BddXZJy47ju9mqOMpWdrJ2rTx4yTxK9oag==
+ dependencies:
+ "@swc/helpers" "^0.4.14"
+
+"@internationalized/message@^3.0.10":
+ version "3.0.10"
+ resolved "https://registry.yarnpkg.com/@internationalized/message/-/message-3.0.10.tgz#340dcfd14ace37234e09419427c991a0c466b96e"
+ integrity sha512-vfLqEop/NH68IgqMcXJNSDqZ5Leg3EEgCxhuuSefU7vvdbptD3pwpUWXaK9igYPa+aZfUU0eqv86yqm76obtsw==
+ dependencies:
+ "@swc/helpers" "^0.4.14"
+ intl-messageformat "^10.1.0"
+
+"@internationalized/number@^3.1.2":
+ version "3.1.2"
+ resolved "https://registry.yarnpkg.com/@internationalized/number/-/number-3.1.2.tgz#4482a6ac573acfb18efd354a42008af20da6c89c"
+ integrity sha512-Mbys8SGsn0ApXz3hJLNU+d95B8luoUbwnmCpBwl7d63UmYAlcT6TRDyvaS/vwdbElXLcsQJjQCu0gox2cv/Tig==
+ dependencies:
+ "@swc/helpers" "^0.4.14"
+
+"@internationalized/string@^3.0.1":
+ version "3.0.1"
+ resolved "https://registry.yarnpkg.com/@internationalized/string/-/string-3.0.1.tgz#2c70a81ae5eb84f156f40330369c2469bad6d504"
+ integrity sha512-2+rHfXZ56YgsC6i3fKvBue/xatnSm0Jv+C/x4+n3wg5xAcLh4LPW3GvZ/9ifxNAz9+IWplgZHa1FRIbSuUvNWg==
+ dependencies:
+ "@swc/helpers" "^0.4.14"
+
"@ioredis/commands@^1.1.1":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@ioredis/commands/-/commands-1.2.0.tgz#6d61b3097470af1fdbbe622795b8921d42018e11"
@@ -2511,6 +2579,247 @@
resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-4.6.1.tgz#ae31309cc0f600f2da22708697b3be4eb1e46f9e"
integrity sha512-3u2/XxvxB+Q7cMXHnKU0CpBiUK1QWqpgiBv28YDo1zOIJE3FCF8DI2vrp6vuwjGt5h0JGXDSvmSf4D4maVjJdw==
+"@react-aria/button@^3.6.4":
+ version "3.6.4"
+ resolved "https://registry.yarnpkg.com/@react-aria/button/-/button-3.6.4.tgz#51927c9d968d0c1f741ee2081ca7f2e244abbc12"
+ integrity sha512-OEs5fNGiuZzyC5y0cNl96+6pRf/3ZhI1i2m6LlRYhJLsWXPhHt21UHEnlSchE/XGtgKojJEeTsXottoBFTBi5w==
+ dependencies:
+ "@react-aria/focus" "^3.10.1"
+ "@react-aria/interactions" "^3.13.1"
+ "@react-aria/utils" "^3.14.2"
+ "@react-stately/toggle" "^3.4.4"
+ "@react-types/button" "^3.7.0"
+ "@react-types/shared" "^3.16.0"
+ "@swc/helpers" "^0.4.14"
+
+"@react-aria/calendar@^3.0.5":
+ version "3.0.5"
+ resolved "https://registry.yarnpkg.com/@react-aria/calendar/-/calendar-3.0.5.tgz#78b4138688d325a3c3f8dc0be3e45291b3e8670b"
+ integrity sha512-RIOwGYIwMizN/MAF5RkTb2ic9OJ0rJyR2VqqgtV3c7ADHNejzyLYMQmaalEFDUHS+AbvaXM1LCXdFBhSB8nf5w==
+ dependencies:
+ "@internationalized/date" "^3.0.2"
+ "@react-aria/i18n" "^3.6.3"
+ "@react-aria/interactions" "^3.13.1"
+ "@react-aria/live-announcer" "^3.1.2"
+ "@react-aria/utils" "^3.14.2"
+ "@react-stately/calendar" "^3.0.5"
+ "@react-types/button" "^3.7.0"
+ "@react-types/calendar" "^3.0.5"
+ "@react-types/shared" "^3.16.0"
+ "@swc/helpers" "^0.4.14"
+
+"@react-aria/datepicker@^3.4.0":
+ version "3.2.1"
+ resolved "https://registry.yarnpkg.com/@react-aria/datepicker/-/datepicker-3.2.1.tgz#56a222c4b1c9c65b9b9371d3066611134f537ab7"
+ integrity sha512-NnW9VgX/YjxkgjcIaxmOhzpfiQmTQpCXjpPJ1+3nPhKzPKpcjtPxIYTDMkm/R+6i5FRukEGtjhg3QY9amLK6hQ==
+ dependencies:
+ "@internationalized/date" "^3.0.2"
+ "@internationalized/number" "^3.1.2"
+ "@internationalized/string" "^3.0.1"
+ "@react-aria/focus" "^3.10.1"
+ "@react-aria/i18n" "^3.6.3"
+ "@react-aria/interactions" "^3.13.1"
+ "@react-aria/label" "^3.4.4"
+ "@react-aria/spinbutton" "^3.2.1"
+ "@react-aria/utils" "^3.14.2"
+ "@react-stately/datepicker" "^3.2.1"
+ "@react-types/button" "^3.7.0"
+ "@react-types/calendar" "^3.0.5"
+ "@react-types/datepicker" "^3.1.4"
+ "@react-types/dialog" "^3.4.5"
+ "@react-types/shared" "^3.16.0"
+ "@swc/helpers" "^0.4.14"
+
+"@react-aria/focus@^3.10.1":
+ version "3.10.1"
+ resolved "https://registry.yarnpkg.com/@react-aria/focus/-/focus-3.10.1.tgz#624d02d2565151030a4156aeb17685d87f18ad58"
+ integrity sha512-HjgFUC1CznuYC7CxtBIFML6bOBxW3M3cSNtvmXU9QWlrPSwwOLkXCnfY6+UkjCc5huP4v7co4PoRDX8Vbe/cVQ==
+ dependencies:
+ "@react-aria/interactions" "^3.13.1"
+ "@react-aria/utils" "^3.14.2"
+ "@react-types/shared" "^3.16.0"
+ "@swc/helpers" "^0.4.14"
+ clsx "^1.1.1"
+
+"@react-aria/i18n@^3.6.3":
+ version "3.6.3"
+ resolved "https://registry.yarnpkg.com/@react-aria/i18n/-/i18n-3.6.3.tgz#2b4d72d0baf07b514d2c35eb6ac356d0247ea84a"
+ integrity sha512-cDWl8FXJIXsw/raWcThywBueCJ5ncoogq81wYVS6hfZVmSyncONIB3bwUL12cojmjX1VEP31sN0ujT/83QP95Q==
+ dependencies:
+ "@internationalized/date" "^3.0.2"
+ "@internationalized/message" "^3.0.10"
+ "@internationalized/number" "^3.1.2"
+ "@internationalized/string" "^3.0.1"
+ "@react-aria/ssr" "^3.4.1"
+ "@react-aria/utils" "^3.14.2"
+ "@react-types/shared" "^3.16.0"
+ "@swc/helpers" "^0.4.14"
+
+"@react-aria/interactions@^3.13.1":
+ version "3.13.1"
+ resolved "https://registry.yarnpkg.com/@react-aria/interactions/-/interactions-3.13.1.tgz#75e102c50a5c1d002cad4ee8d59677aee226186b"
+ integrity sha512-WCvfZOi1hhussVTHxVq76OR48ry13Zvp9U5hmuQufyxIUlf4hOvDk4/cbK4o4JiCs8X7C7SRzcwFM34M4NHzmg==
+ dependencies:
+ "@react-aria/utils" "^3.14.2"
+ "@react-types/shared" "^3.16.0"
+ "@swc/helpers" "^0.4.14"
+
+"@react-aria/label@^3.4.4":
+ version "3.4.4"
+ resolved "https://registry.yarnpkg.com/@react-aria/label/-/label-3.4.4.tgz#b891d3cebeeffc7a1413a492d8a694083dc3253e"
+ integrity sha512-1fuYf2UctNhBy31uYN7OhdcrwzlB5GS0+C49gDkwWzccB7yr+CoOJ5UQUoVB7WBmzrc+CuzwWxSDd4OupSYIZQ==
+ dependencies:
+ "@react-aria/utils" "^3.14.2"
+ "@react-types/label" "^3.7.1"
+ "@react-types/shared" "^3.16.0"
+ "@swc/helpers" "^0.4.14"
+
+"@react-aria/live-announcer@^3.1.2":
+ version "3.1.2"
+ resolved "https://registry.yarnpkg.com/@react-aria/live-announcer/-/live-announcer-3.1.2.tgz#a492c7ec1e664c8f41a572368cdbc53e22241a0c"
+ integrity sha512-BqtVLPWU10sZssoOJF1lJiRvZe5zqZ5BM39PsFyO7dWhVkR/9O9bZviqvKXnC1oXCnypfa+85gUshbK9unFcWA==
+ dependencies:
+ "@swc/helpers" "^0.4.14"
+
+"@react-aria/spinbutton@^3.2.1":
+ version "3.2.1"
+ resolved "https://registry.yarnpkg.com/@react-aria/spinbutton/-/spinbutton-3.2.1.tgz#8e9fff341deef3e14109c69f2b52fffa8a878a5b"
+ integrity sha512-y9QZ0VzWL7qzbWSPOCsAdvZhVlQrnHLRGc8bkRa2jmWrnCqS0iua/TRuLGgazIf2Rb7GmdbKBJJuPSScytVDUw==
+ dependencies:
+ "@react-aria/i18n" "^3.6.3"
+ "@react-aria/live-announcer" "^3.1.2"
+ "@react-aria/utils" "^3.14.2"
+ "@react-types/button" "^3.7.0"
+ "@react-types/shared" "^3.16.0"
+ "@swc/helpers" "^0.4.14"
+
+"@react-aria/ssr@^3.4.1":
+ version "3.4.1"
+ resolved "https://registry.yarnpkg.com/@react-aria/ssr/-/ssr-3.4.1.tgz#79e8bb621487e8f52890c917d3c734f448ba95e7"
+ integrity sha512-NmhoilMDyIfQiOSdQgxpVH2tC2u85Y0mVijtBNbI9kcDYLEiW/r6vKYVKtkyU+C4qobXhGMPfZ70PTc0lysSVA==
+ dependencies:
+ "@swc/helpers" "^0.4.14"
+
+"@react-aria/utils@^3.14.2":
+ version "3.14.2"
+ resolved "https://registry.yarnpkg.com/@react-aria/utils/-/utils-3.14.2.tgz#3a8d0d14abab4bb1095e101ee44dc5e3e43e6217"
+ integrity sha512-3nr5gsAf/J/W+6Tu4NF3Q7m+1mXjfpXESh7TPa6UR6v3tVDTsJVMrITg2BkHN1jM8xELcl2ZxyUffOWqOXzWuA==
+ dependencies:
+ "@react-aria/ssr" "^3.4.1"
+ "@react-stately/utils" "^3.5.2"
+ "@react-types/shared" "^3.16.0"
+ "@swc/helpers" "^0.4.14"
+ clsx "^1.1.1"
+
+"@react-stately/calendar@^3.0.5":
+ version "3.0.5"
+ resolved "https://registry.yarnpkg.com/@react-stately/calendar/-/calendar-3.0.5.tgz#78decc870ddf33ce1f7b7c8da57d2639e9a46c30"
+ integrity sha512-vu5hKsiA8edqNtsqBTGi8QR38qZ+uHDjuq3vp2m0f6TZSnp0kg8fkPNHEOuBTQ8ZXFFbGUZKhL/1B+ZWwLHwMQ==
+ dependencies:
+ "@internationalized/date" "^3.0.2"
+ "@react-stately/utils" "^3.5.2"
+ "@react-types/calendar" "^3.0.5"
+ "@react-types/datepicker" "^3.1.4"
+ "@react-types/shared" "^3.16.0"
+ "@swc/helpers" "^0.4.14"
+
+"@react-stately/datepicker@^3.2.1", "@react-stately/datepicker@^3.4.0":
+ version "3.2.1"
+ resolved "https://registry.yarnpkg.com/@react-stately/datepicker/-/datepicker-3.2.1.tgz#4c545981f73771bff76885e50014b4274fa4b554"
+ integrity sha512-nd6thX2Z+rOLDHduB3EgMKA0n5U83lrwn3IUfjRGrcE21zFaFmhTPsHyvol5jHy3eSyjWSN9kGpKFzOxES+uoA==
+ dependencies:
+ "@internationalized/date" "^3.0.2"
+ "@internationalized/string" "^3.0.1"
+ "@react-stately/overlays" "^3.4.4"
+ "@react-stately/utils" "^3.5.2"
+ "@react-types/datepicker" "^3.1.4"
+ "@react-types/shared" "^3.16.0"
+ "@swc/helpers" "^0.4.14"
+
+"@react-stately/overlays@^3.4.4":
+ version "3.4.4"
+ resolved "https://registry.yarnpkg.com/@react-stately/overlays/-/overlays-3.4.4.tgz#a228a230f46f0d593ffb7bc8f836439bbc08e9ed"
+ integrity sha512-IIlx+VXtXS4snDXrocUOls8QZ5XBQ4SNonaz1ox8/5W7Nsvq4VtdKsIaXsUP4agOudswaimlpj3pTDO/KuF5tQ==
+ dependencies:
+ "@react-stately/utils" "^3.5.2"
+ "@react-types/overlays" "^3.6.5"
+ "@swc/helpers" "^0.4.14"
+
+"@react-stately/toggle@^3.4.4":
+ version "3.4.4"
+ resolved "https://registry.yarnpkg.com/@react-stately/toggle/-/toggle-3.4.4.tgz#b7825bf900725dcee0444fe6132b06948be36b44"
+ integrity sha512-OwVJpd2M7P7fekTWpl3TUdD3Brq+Z/xElOCJYP5QuVytXCa5seKsk40YPld8JQnA5dRKojpbUxMDOJpb6hOOfw==
+ dependencies:
+ "@react-stately/utils" "^3.5.2"
+ "@react-types/checkbox" "^3.4.1"
+ "@react-types/shared" "^3.16.0"
+ "@swc/helpers" "^0.4.14"
+
+"@react-stately/utils@^3.5.2":
+ version "3.5.2"
+ resolved "https://registry.yarnpkg.com/@react-stately/utils/-/utils-3.5.2.tgz#9b5f3bb9ad500bf9c5b636a42988dba60a221669"
+ integrity sha512-639gSKqamPHIEPaApb9ahVJS0HgAqNdVF3tQRoh+Ky6759Mbk6i3HqG4zk4IGQ1tVlYSYZvCckwehF7b2zndMg==
+ dependencies:
+ "@swc/helpers" "^0.4.14"
+
+"@react-types/button@^3.7.0":
+ version "3.7.0"
+ resolved "https://registry.yarnpkg.com/@react-types/button/-/button-3.7.0.tgz#774c043d8090a505e60fdf26f026d5f0cc968f0f"
+ integrity sha512-81BQO3QxSgF9PTXsVozNdNCKxBOB1lpbCWocV99dN1ws9s8uaYw8pmJJZ0LJKLiOsIECQ/3QrhQjmWTDW/qTug==
+ dependencies:
+ "@react-types/shared" "^3.16.0"
+
+"@react-types/calendar@^3.0.5", "@react-types/calendar@^3.4.0":
+ version "3.0.5"
+ resolved "https://registry.yarnpkg.com/@react-types/calendar/-/calendar-3.0.5.tgz#a91fca7d5a2bbbd554748471f9920600cb364d18"
+ integrity sha512-Kx00132hFEVvqay/Ub7q2oZEA1AzksirAuCsjakamn4LAXvitlo3PZxqBdEsyRc3nP5NR48KJj8yo276mXY8kQ==
+ dependencies:
+ "@internationalized/date" "^3.0.2"
+ "@react-types/shared" "^3.16.0"
+
+"@react-types/checkbox@^3.4.1":
+ version "3.4.1"
+ resolved "https://registry.yarnpkg.com/@react-types/checkbox/-/checkbox-3.4.1.tgz#75a78b3f21f4cc72d2382761ba4c326aefd699db"
+ integrity sha512-kDMpy9SntjGQ7x00m5zmW8GENPouOtyiDgiEDKsPXUr2iYqHsNtricqVyG9S9+6hqpzuu8BzTcvZamc/xYjzlg==
+ dependencies:
+ "@react-types/shared" "^3.16.0"
+
+"@react-types/datepicker@^3.1.4", "@react-types/datepicker@^3.4.0":
+ version "3.1.4"
+ resolved "https://registry.yarnpkg.com/@react-types/datepicker/-/datepicker-3.1.4.tgz#46fd291d8acd40fdd304c4c0bf1a47e71eaa1801"
+ integrity sha512-NBCXBCe3YZqeA/JrVKy0IAvJ2XSnXaVpR9iAlUwKu7V8P81CtnXHsVCrd/0HSH8QZWsGdIV5E23z0TctvW8trA==
+ dependencies:
+ "@internationalized/date" "^3.0.2"
+ "@react-types/overlays" "^3.6.5"
+ "@react-types/shared" "^3.16.0"
+
+"@react-types/dialog@^3.4.5":
+ version "3.4.5"
+ resolved "https://registry.yarnpkg.com/@react-types/dialog/-/dialog-3.4.5.tgz#a12c4e6d69dd7f098eb8b1534107ae6d970f734b"
+ integrity sha512-FkxZAYNRWkZVH5rjlw6qyQ/SpoGcYtNI/JQvn1H/xtZy/OJh2b2ERxGWv5x0RItGSeyATdSwFO1Qnf1Kl2K02A==
+ dependencies:
+ "@react-types/overlays" "^3.6.5"
+ "@react-types/shared" "^3.16.0"
+
+"@react-types/label@^3.7.1":
+ version "3.7.1"
+ resolved "https://registry.yarnpkg.com/@react-types/label/-/label-3.7.1.tgz#ad4d3d7a6b5ea6aca70f89661d7c358cf2ab5f94"
+ integrity sha512-wFpdtjSDBWO4xQQGF57V3PqvVVyE9TPj9ELWLs1yzL09fpXosycuEl5d79RywVlC9aF9dQYUfES09q/DZhRhMQ==
+ dependencies:
+ "@react-types/shared" "^3.16.0"
+
+"@react-types/overlays@^3.6.5":
+ version "3.6.5"
+ resolved "https://registry.yarnpkg.com/@react-types/overlays/-/overlays-3.6.5.tgz#466b325d9be51f67beb98b7bec3fd9295c72efac"
+ integrity sha512-IeWcF+YTucCYYHagNh8fZLH6R4YUONO1VHY57WJyIHwMy0qgEaKSQCwq72VO1fQJ0ySZgOgm31FniOyKkg6+eQ==
+ dependencies:
+ "@react-types/shared" "^3.16.0"
+
+"@react-types/shared@^3.16.0":
+ version "3.16.0"
+ resolved "https://registry.yarnpkg.com/@react-types/shared/-/shared-3.16.0.tgz#cab7bf0376969d1773480ecb2d6da5aa91391db5"
+ integrity sha512-IQgU4oAEvMwylEvaTsr2XB1G/mAoMe1JFYLD6G78v++oAR9l8o9MQxZ0YSeANDkqTamb2gKezGoT1RxvSKjVxw==
+
"@reactflow/[email protected]":
version "11.0.7"
resolved "https://registry.yarnpkg.com/@reactflow/background/-/background-11.0.7.tgz#e9f41e3794bb2b9d52af78647254857085e38cee"
@@ -2864,6 +3173,13 @@
"@supabase/storage-js" "^2.1.0"
cross-fetch "^3.1.5"
+"@swc/helpers@^0.4.14":
+ version "0.4.14"
+ resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.4.14.tgz#1352ac6d95e3617ccb7c1498ff019654f1e12a74"
+ integrity sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==
+ dependencies:
+ tslib "^2.4.0"
+
"@szmarczak/http-timer@^4.0.5":
version "4.0.6"
resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-4.0.6.tgz#b4a914bb62e7c272d4e5989fe4440f812ab1d807"
@@ -4465,6 +4781,11 @@ clone@^1.0.2:
resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e"
integrity sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==
+clsx@^1.1.1:
+ version "1.2.1"
+ resolved "https://registry.yarnpkg.com/clsx/-/clsx-1.2.1.tgz#0ddc4a20a549b59c93a4116bb26f5294ca17dc12"
+ integrity sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==
+
cluster-key-slot@^1.1.0:
version "1.1.2"
resolved "https://registry.yarnpkg.com/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz#88ddaa46906e303b5de30d3153b7d9fe0a0c19ac"
@@ -7099,6 +7420,16 @@ internal-slot@^1.0.3:
has "^1.0.3"
side-channel "^1.0.4"
+intl-messageformat@^10.1.0:
+ version "10.2.5"
+ resolved "https://registry.yarnpkg.com/intl-messageformat/-/intl-messageformat-10.2.5.tgz#a51e6e2700d82b5b7ccd7a9f3bd45d967d95afc0"
+ integrity sha512-AievYMN6WLLHwBeCTv4aRKG+w3ZNyZtkObwgsKk3Q7GNTq8zDRvDbJSBQkb2OPeVCcAKcIXvak9FF/bRNavoww==
+ dependencies:
+ "@formatjs/ecma402-abstract" "1.14.3"
+ "@formatjs/fast-memoize" "1.2.7"
+ "@formatjs/icu-messageformat-parser" "2.1.14"
+ tslib "^2.4.0"
+
invariant@^2.2.4:
version "2.2.4"
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6"
@@ -10277,17 +10608,17 @@ remeda@^1.2.0:
resolved "https://registry.yarnpkg.com/remeda/-/remeda-1.3.0.tgz#6dc642187e08ead2265e8c7f8517a16a69e325ce"
integrity sha512-DJkLBUzi0dEigDuyPtVe50aNzQq8EBQOintPaxvzwSNreXOGsRnvfGiK+cTsY+nUgGCBrcFxcvH8MIg2skfIZA==
-remix-flat-routes@^0.4.8:
- version "0.4.8"
- resolved "https://registry.yarnpkg.com/remix-flat-routes/-/remix-flat-routes-0.4.8.tgz#227c8962612c437fd1c0f87a65a71e1c26be1713"
- integrity sha512-ApHjsrdO/vmCC2TMsl2rYd+M2vscljmKLD1JJXcZE9zlmhbT5pS2sM0NrFor7ecqLxX+kHT9xwNsvU1XaDcmmA==
+remix-flat-routes@^0.5.4:
+ version "0.5.4"
+ resolved "https://registry.yarnpkg.com/remix-flat-routes/-/remix-flat-routes-0.5.4.tgz#13614b75e1cce7f0394b04df0c932eebdf2ba4d7"
+ integrity sha512-4Rw3CwWvP/jUx9IkEOEbiNbzxwc/nb4wE9mk1Q1fO3yz46CLUOOoqUCn1+0nwlKqOdyYb0iw3Q8FV7d6X2fAjw==
dependencies:
minimatch "^5.1.0"
-remix-validated-form@^4.6.4:
- version "4.6.4"
- resolved "https://registry.yarnpkg.com/remix-validated-form/-/remix-validated-form-4.6.4.tgz#8c43d4a6294a3673742934c81668c4ff61f3a25a"
- integrity sha512-HYIaKYnig3e1aEPlUNl5aPFOSY77AjoViReXjKdoYJNNNRR4zUTqBtp1sm12EC6gM99aymLikz3vd0Vs2Dse/Q==
+remix-validated-form@^4.6.5:
+ version "4.6.5"
+ resolved "https://registry.yarnpkg.com/remix-validated-form/-/remix-validated-form-4.6.5.tgz#0ce7943af82cf7dac67ac8688ef49ca92ac9e8b3"
+ integrity sha512-pf6048rqhsT0lJGDvK8vapAuCITz0L05SyjSvkPNu+2t5DZAlUQaZaR1NMPu7se9RbRh1WeEUa7JWvv8HE9NrQ==
dependencies:
immer "^9.0.12"
remeda "^1.2.0"
@@ -12268,10 +12599,15 @@ yocto-queue@^0.1.0:
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==
-zod@^3.19.1:
- version "3.19.1"
- resolved "https://registry.yarnpkg.com/zod/-/zod-3.19.1.tgz#112f074a97b50bfc4772d4ad1576814bd8ac4473"
- integrity sha512-LYjZsEDhCdYET9ikFu6dVPGp2YH9DegXjdJToSzD9rO6fy4qiRYFoyEYwps88OseJlPyl2NOe2iJuhEhL7IpEA==
+ version "1.2.4"
+ resolved "https://registry.yarnpkg.com/zod-form-data/-/zod-form-data-1.2.4.tgz#161967a60d351cc4e5e6af248e074b93ac74ec94"
+ integrity sha512-mI/rgItfvYQpvzEqGuBda/nuTHrMNoFZJ5cpiGLC5O3ZaVwI0XVo3/yTY2RreVMu57wGcDrfQcTRe5aMq2ijYA==
+
+zod@^3.20.2:
+ version "3.20.2"
+ resolved "https://registry.yarnpkg.com/zod/-/zod-3.20.2.tgz#068606642c8f51b3333981f91c0a8ab37dfc2807"
+ integrity sha512-1MzNQdAvO+54H+EaK5YpyEy0T+Ejo/7YLHS93G3RnYWh5gaotGHwGeN/ZO687qEDU2y4CdStQYXVHIgrUl5UVQ==
zustand@^4.0.0-rc.1, zustand@^4.1.1:
version "4.1.4"