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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
refactor: separate people and resources modules
Brad Barbinb5a797f536fe
diff --git a/apps/carbon/app/components/Form/Abilities.tsx b/apps/carbon/app/components/Form/Abilities.tsxindex fe9de803f3..4bd3600ffe 100644--- a/apps/carbon/app/components/Form/Abilities.tsx+++ b/apps/carbon/app/components/Form/Abilities.tsx@@ -1,7 +1,7 @@import { useMount } from "@carbon/react";import { useFetcher } from "@remix-run/react";import { useMemo } from "react";-import type { getAbilitiesList } from "~/modules/resources";+import type { getAbilitiesList } from "~/modules/people";import { path } from "~/utils/path";import type { MultiSelectProps } from "./MultiSelect";import MultiSelect from "./MultiSelect";diff --git a/apps/carbon/app/components/Form/Ability.tsx b/apps/carbon/app/components/Form/Ability.tsxindex 425ee6264d..58cabb7f47 100644--- a/apps/carbon/app/components/Form/Ability.tsx+++ b/apps/carbon/app/components/Form/Ability.tsx@@ -2,7 +2,7 @@ import { useMount } from "@carbon/react";import { useFetcher } from "@remix-run/react";import { useMemo } from "react";-import type { getAbilitiesList } from "~/modules/resources";+import type { getAbilitiesList } from "~/modules/people";import { path } from "~/utils/path";import type { ComboboxProps } from "./Combobox";diff --git a/apps/carbon/app/components/Form/Department.tsx b/apps/carbon/app/components/Form/Department.tsxindex 9613c67147..3a7ad6dc90 100644--- a/apps/carbon/app/components/Form/Department.tsx+++ b/apps/carbon/app/components/Form/Department.tsx@@ -1,8 +1,8 @@import { useDisclosure, useMount } from "@carbon/react";import { useFetcher } from "@remix-run/react";import { useMemo, useRef, useState } from "react";-import type { getDepartmentsList } from "~/modules/resources";-import { DepartmentForm } from "~/modules/resources";+import type { getDepartmentsList } from "~/modules/people";+import { DepartmentForm } from "~/modules/people";import { path } from "~/utils/path";import type { ComboboxProps } from "./Combobox";import CreatableCombobox from "./CreatableCombobox";diff --git a/apps/carbon/app/components/Form/Shift.tsx b/apps/carbon/app/components/Form/Shift.tsxindex 1fab8a9736..4ce99cebbf 100644--- a/apps/carbon/app/components/Form/Shift.tsx+++ b/apps/carbon/app/components/Form/Shift.tsx@@ -2,7 +2,7 @@ import { useFetcher } from "@remix-run/react";import { useEffect, useMemo } from "react";import { path } from "~/utils/path";-import type { getShiftsList } from "~/modules/resources";+import type { getShiftsList } from "~/modules/people";import type { SelectProps } from "./Select";import Select from "./Select";diff --git a/apps/carbon/app/components/Layout/Navigation/useModules.tsx b/apps/carbon/app/components/Layout/Navigation/useModules.tsxindex 2b1572f0ff..211466af45 100644--- a/apps/carbon/app/components/Layout/Navigation/useModules.tsx+++ b/apps/carbon/app/components/Layout/Navigation/useModules.tsx@@ -3,6 +3,7 @@ import {LuComponent,LuCreditCard,LuCrown,+ LuFactory,LuFiles,LuLandmark,LuSettings,@@ -85,11 +86,17 @@ export function useModules() {icon: LuCreditCard,},{- permission: "resources",- name: "Resources",+ permission: "people",+ name: "People",to: path.to.people,icon: LuUsers,},+ {+ permission: "resources",+ name: "Resources",+ to: path.to.resources,+ icon: LuFactory,+ },{permission: "users",name: "Users",diff --git a/apps/carbon/app/components/Search/Search/Search.tsx b/apps/carbon/app/components/Search/Search/Search.tsxindex 48b4f441d1..fc535fa317 100644--- a/apps/carbon/app/components/Search/Search/Search.tsx+++ b/apps/carbon/app/components/Search/Search/Search.tsx@@ -44,6 +44,7 @@ import { useDocumentsSubmodules } from "~/modules/documents";import { useInventorySubmodules } from "~/modules/inventory";import { useInvoicingSubmodules } from "~/modules/invoicing";import { useItemsSubmodules } from "~/modules/items";+import { usePeopleSubmodules } from "~/modules/people";import { usePurchasingSubmodules } from "~/modules/purchasing";import { useResourcesSubmodules } from "~/modules/resources";import { useSalesSubmodules } from "~/modules/sales";@@ -317,6 +318,7 @@ function useGroupedSubmodules() {const invoicing = useInvoicingSubmodules();const users = useUsersSubmodules();const settings = useSettingsSubmodules();+ const people = usePeopleSubmodules();const resources = useResourcesSubmodules();const account = useAccountSubmodules();@@ -336,6 +338,7 @@ function useGroupedSubmodules() {purchasing,accounting,invoicing,+ people,resources,settings,users,diff --git a/apps/carbon/app/modules/account/ui/useAccountSubmodules.tsx b/apps/carbon/app/modules/account/ui/useAccountSubmodules.tsxindex 2ce0ac35fb..f692e2ea92 100644--- a/apps/carbon/app/modules/account/ui/useAccountSubmodules.tsx+++ b/apps/carbon/app/modules/account/ui/useAccountSubmodules.tsx@@ -1,4 +1,4 @@-import { BsKeyFill, BsPaletteFill, BsShieldLock } from "react-icons/bs";+import { BsKeyFill, BsPaletteFill } from "react-icons/bs";import { CgProfile } from "react-icons/cg";import type { Route } from "~/types";import { path } from "~/utils/path";@@ -9,11 +9,6 @@ const accountRoutes: Route[] = [to: path.to.profile,icon: <CgProfile />,},- {- name: "Personal",- to: path.to.accountPersonal,- icon: <BsShieldLock />,- },{name: "Password",to: path.to.accountPassword,diff --git a/apps/carbon/app/modules/people/index.ts b/apps/carbon/app/modules/people/index.tsnew file mode 100644index 0000000000..6fa3871f93--- /dev/null+++ b/apps/carbon/app/modules/people/index.ts@@ -0,0 +1,4 @@+export * from "./people.models";+export * from "./people.service";+export * from "./types";+export * from "./ui";diff --git a/apps/carbon/app/modules/people/people.models.ts b/apps/carbon/app/modules/people/people.models.tsnew file mode 100644index 0000000000..d56de2e06a--- /dev/null+++ b/apps/carbon/app/modules/people/people.models.ts@@ -0,0 +1,66 @@+import { z } from "zod";+import { zfd } from "zod-form-data";+import { DataType } from "~/modules/shared";++export const attributeValidator = z+ .object({+ id: zfd.text(z.string().optional()),+ name: z.string().min(1, { message: "Name is required" }),+ userAttributeCategoryId: z.string().min(20),+ 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 = z.object({+ id: zfd.text(z.string().optional()),+ name: z.string().min(1, { message: "Name is required" }),+ isPublic: zfd.checkbox(),+});++export const departmentValidator = z.object({+ id: zfd.text(z.string().optional()),+ name: z.string().min(1, { message: "Name is required" }),+ parentDepartmentId: zfd.text(z.string().optional()),+});++export const employeeJobValidator = z.object({+ title: zfd.text(z.string().optional()),+ startDate: zfd.text(z.string().optional()),+ locationId: zfd.text(z.string().optional()),+ shiftId: zfd.text(z.string().optional()),+ managerId: zfd.text(z.string().optional()),+});++export const holidayValidator = z.object({+ id: zfd.text(z.string().optional()),+ name: z.string().min(1, { message: "Name is required" }),+ date: z.string().min(1, { message: "Date is required" }),+});++export const shiftValidator = z.object({+ id: zfd.text(z.string().optional()),+ name: z.string().min(1, { message: "Name is required" }),+ startTime: z.string().min(1, { message: "Start time is required" }),+ endTime: z.string().min(1, { message: "End time is required" }),+ locationId: z.string().min(1, { message: "Location is required" }),+ monday: zfd.checkbox(),+ tuesday: zfd.checkbox(),+ wednesday: zfd.checkbox(),+ thursday: zfd.checkbox(),+ friday: zfd.checkbox(),+ saturday: zfd.checkbox(),+ sunday: zfd.checkbox(),+});diff --git a/apps/carbon/app/modules/people/people.service.ts b/apps/carbon/app/modules/people/people.service.tsnew file mode 100644index 0000000000..5b4356862e--- /dev/null+++ b/apps/carbon/app/modules/people/people.service.ts@@ -0,0 +1,586 @@+import type { Database, Json } from "@carbon/database";+import type { SupabaseClient } from "@supabase/supabase-js";+import type { z } from "zod";+import type { DataType } from "~/modules/shared";+import type { Employee } from "~/modules/users";+import { getEmployees } from "~/modules/users";+import type { GenericQueryFilters } from "~/utils/query";+import { setGenericQueryFilters } from "~/utils/query";+import { sanitize } from "~/utils/supabase";+import type {+ departmentValidator,+ employeeJobValidator,+ holidayValidator,+ shiftValidator,+} from "./people.models";++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+) {+ return client+ .from("userAttributeCategory")+ .update({ active: false })+ .eq("id", attributeCategoryId);+}++export async function deleteDepartment(+ client: SupabaseClient<Database>,+ departmentId: string+) {+ return client.from("department").delete().eq("id", departmentId);+}++export async function deleteHoliday(+ client: SupabaseClient<Database>,+ holidayId: string+) {+ return client.from("holiday").delete().eq("id", holidayId);+}++export async function deleteShift(+ client: SupabaseClient<Database>,+ shiftId: string+) {+ // TODO: Set all employeeShifts to null+ return client.from("shift").update({ active: false }).eq("id", shiftId);+}++export async function getAttribute(+ client: SupabaseClient<Database>,+ attributeId: string+) {+ return client+ .from("userAttribute")+ .select("*, userAttributeCategory(name)")+ .eq("id", attributeId)+ .eq("active", true)+ .single();+}++async function getAttributes(+ client: SupabaseClient<Database>,+ companyId: string,+ userIds: string[]+) {+ return client+ .from("userAttributeCategory")+ .select(+ `*,+ userAttribute(id, name, listOptions, canSelfManage,+ attributeDataType(id, isBoolean, isDate, isNumeric, isText, isUser),+ userAttributeValue(+ id, userId, valueBoolean, valueDate, valueNumeric, valueText, valueUser, user!userAttributeValue_userId_fkey(id, fullName, avatarUrl)+ )+ )`+ )+ .eq("companyId", companyId)+ .eq("userAttribute.active", true)+ .in("userAttribute.userAttributeValue.userId", [userIds])+ .order("sortOrder", { foreignTable: "userAttribute", ascending: true });+}++export async function getAttributeCategories(+ client: SupabaseClient<Database>,+ companyId: string,+ args?: { search: string | null } & GenericQueryFilters+) {+ let query = client+ .from("userAttributeCategory")+ .select("*, userAttribute(id, name, attributeDataType(id))", {+ count: "exact",+ })+ .eq("companyId", companyId)+ .eq("active", true)+ .eq("userAttribute.active", true);++ if (args?.search) {+ query = query.ilike("name", `%${args.search}%`);+ }++ if (args) {+ query = setGenericQueryFilters(query, args, [+ { column: "name", ascending: true },+ ]);+ }++ return query;+}++export async function getAttributeCategory(+ client: SupabaseClient<Database>,+ id: string+) {+ return client+ .from("userAttributeCategory")+ .select(+ `*,+ 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 getDepartment(+ client: SupabaseClient<Database>,+ departmentId: string+) {+ return client.from("department").select("*").eq("id", departmentId).single();+}++export async function getDepartments(+ client: SupabaseClient<Database>,+ companyId: string,+ args?: GenericQueryFilters & { search: string | null }+) {+ let query = client+ .from("department")+ .select(`*, department(id, name)`, {+ count: "exact",+ })+ .eq("companyId", companyId);++ if (args?.search) {+ query = query.ilike("name", `%${args.search}%`);+ }++ if (args) {+ query = setGenericQueryFilters(query, args, [+ { column: "name", ascending: true },+ ]);+ }++ return query;+}++export async function getDepartmentsList(+ client: SupabaseClient<Database>,+ companyId: string+) {+ return client+ .from("department")+ .select(`id, name`)+ .eq("companyId", companyId)+ .order("name");+}++export async function getEmployeeJob(+ client: SupabaseClient<Database>,+ employeeId: string,+ companyId: string+) {+ return client+ .from("employeeJob")+ .select("*")+ .eq("id", employeeId)+ .eq("companyId", companyId)+ .single();+}++export async function getEmployeeSummary(+ client: SupabaseClient<Database>,+ employeeId: string,+ companyId: string+) {+ return client+ .from("employeeSummary")+ .select("*")+ .eq("id", employeeId)+ .eq("companyId", companyId)+ .single();+}++export async function getHoliday(+ client: SupabaseClient<Database>,+ holidayId: string+) {+ return client.from("holiday").select("*").eq("id", holidayId).single();+}++export async function getHolidays(+ client: SupabaseClient<Database>,+ companyId: string,+ args?: GenericQueryFilters & { search: string | null }+) {+ let query = client+ .from("holiday")+ .select("*", {+ count: "exact",+ })+ .eq("companyId", companyId);++ if (args?.search) {+ query = query.ilike("name", `%${args.search}%`);+ }++ if (args) {+ query = setGenericQueryFilters(query, args, [+ { column: "date", ascending: true },+ ]);+ }++ return query;+}++export function getHolidayYears(+ client: SupabaseClient<Database>,+ companyId: string+) {+ return client.from("holidayYears").select("year").eq("companyId", companyId);+}++type UserAttributeId = string;++export type PersonAttributeValue = {+ userAttributeValueId: string;+ value: boolean | string | number;+ dataType?: DataType;+ user?: {+ id: string;+ fullName: string | null;+ avatarUrl: string | null;+ } | null;+};++type PersonAttributes = Record<UserAttributeId, PersonAttributeValue>;++type Person = Employee & {+ attributes: PersonAttributes;+};++export async function getPeople(+ client: SupabaseClient<Database>,+ companyId: string,+ args: GenericQueryFilters & {+ search: string | null;+ }+) {+ const employees = await getEmployees(client, companyId, args);+ if (employees.error) return employees;++ if (!employees.data) throw new Error("Failed to get employee data");++ const userIds = employees.data.reduce<string[]>((acc, employee) => {+ if (employee.id) acc.push(employee.id);+ return acc;+ }, []);++ const attributeCategories = await getAttributes(client, companyId, userIds);+ if (attributeCategories.error) return attributeCategories;++ const people: Person[] = employees.data.map((employee) => {+ const userId = employee.id;++ const employeeAttributes =+ attributeCategories.data.reduce<PersonAttributes>((acc, category) => {+ if (!category.userAttribute || !Array.isArray(category.userAttribute))+ return acc;+ category.userAttribute.forEach(+ // @ts-ignore+ (attribute) => {+ if (+ attribute.userAttributeValue &&+ Array.isArray(attribute.userAttributeValue) &&+ !Array.isArray(attribute.attributeDataType)+ ) {+ const userAttributeId = attribute.id;+ const userAttributeValue = attribute.userAttributeValue.find(+ // @ts-ignore+ (attributeValue) => attributeValue.userId === userId+ );+ const value =+ typeof userAttributeValue?.valueBoolean === "boolean"+ ? userAttributeValue.valueBoolean+ : userAttributeValue?.valueDate ||+ userAttributeValue?.valueNumeric ||+ userAttributeValue?.valueText ||+ userAttributeValue?.valueUser;++ if (value && userAttributeValue?.id) {+ acc[userAttributeId] = {+ userAttributeValueId: userAttributeValue.id,+ // @ts-ignore+ dataType: attribute.attributeDataType?.id as DataType,+ value,+ user: !Array.isArray(userAttributeValue.user)+ ? userAttributeValue.user+ : undefined,+ };+ }+ }+ }+ );+ return acc;+ }, {});++ return {+ ...employee,+ attributes: employeeAttributes,+ };+ });++ return {+ count: employees.count,+ data: people,+ error: null,+ };+}++export async function getShift(+ client: SupabaseClient<Database>,+ shiftId: string+) {+ return client+ .from("shifts")+ .select("*")+ .eq("id", shiftId)+ .eq("active", true)+ .single();+}++export async function getShifts(+ client: SupabaseClient<Database>,+ companyId: string,+ args: GenericQueryFilters & { search: string | null }+) {+ let query = client+ .from("shifts")+ .select("*", {+ count: "exact",+ })+ .eq("companyId", companyId)+ .eq("active", true);++ if (args?.search) {+ query = query.ilike("name", `%${args.search}%`);+ }++ query = setGenericQueryFilters(query, args, [+ { column: "locationId", ascending: true },+ ]);+ return query;+}++export async function getShiftsList(+ client: SupabaseClient<Database>,+ locationId: string | null+) {+ let query = client.from("shift").select(`id, name`).eq("active", true);++ if (locationId) {+ query = query.eq("locationId", locationId);+ }++ return query.order("name");+}++export async function insertAttribute(+ client: SupabaseClient<Database>,+ attribute: {+ name: string;+ attributeDataTypeId: number;+ userAttributeCategoryId: string;+ 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")+ .single();+}++export async function insertAttributeCategory(+ client: SupabaseClient<Database>,+ attributeCategory: {+ name: string;+ public: boolean;+ companyId: string;+ createdBy: string;+ }+) {+ return client+ .from("userAttributeCategory")+ .upsert([attributeCategory])+ .select("id")+ .single();+}++export async function insertEmployeeJob(+ client: SupabaseClient<Database>,+ job: {+ id: string;+ companyId: string;+ locationId?: string;+ }+) {+ return client.from("employeeJob").insert(job).select("*").single();+}++export async function updateAttribute(+ client: SupabaseClient<Database>,+ attribute: {+ id?: string;+ name: string;+ listOptions?: string[];+ canSelfManage: boolean;+ updatedBy: string;+ }+) {+ if (!attribute.id) throw new Error("id is required");+ return client+ .from("userAttribute")+ .update(+ sanitize({+ 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: string;+ name: string;+ public: boolean;+ updatedBy: string;+ }+) {+ const { id, ...update } = attributeCategory;+ return client+ .from("userAttributeCategory")+ .update(sanitize(update))+ .eq("id", id);+}++export async function updateAttributeSortOrder(+ client: SupabaseClient<Database>,+ updates: {+ id: string;+ 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 updateEmployeeJob(+ client: SupabaseClient<Database>,+ employeeId: string,+ employeeJob: z.infer<typeof employeeJobValidator> & {+ companyId: string;+ updatedBy: string;+ customFields?: Json;+ }+) {+ return client+ .from("employeeJob")+ .update(sanitize(employeeJob))+ .eq("id", employeeId)+ .eq("companyId", employeeJob.companyId);+}++export async function upsertDepartment(+ client: SupabaseClient<Database>,+ department:+ | (Omit<z.infer<typeof departmentValidator>, "id"> & {+ companyId: string;+ createdBy: string;+ customFields?: Json;+ })+ | (Omit<z.infer<typeof departmentValidator>, "id"> & {+ id: string;+ updatedBy: string;+ customFields?: Json;+ })+) {+ if ("id" in department) {+ return client+ .from("department")+ .update(sanitize(department))+ .eq("id", department.id);+ }+ return client.from("department").insert(department).select("*").single();+}++export async function upsertHoliday(+ client: SupabaseClient<Database>,+ holiday:+ | (Omit<z.infer<typeof holidayValidator>, "id"> & {+ companyId: string;+ createdBy: string;+ customFields?: Json;+ })+ | (Omit<z.infer<typeof holidayValidator>, "id"> & {+ id: string;+ updatedBy: string;+ customFields?: Json;+ })+) {+ if ("createdBy" in holiday) {+ return client.from("holiday").insert(holiday).select("*").single();+ }+ return client.from("holiday").update(sanitize(holiday)).eq("id", holiday.id);+}++export async function upsertShift(+ client: SupabaseClient<Database>,+ shift:+ | (Omit<z.infer<typeof shiftValidator>, "id"> & {+ createdBy: string;+ companyId: string;+ customFields?: Json;+ })+ | (Omit<z.infer<typeof shiftValidator>, "id"> & {+ id: string;+ updatedBy: string;+ customFields?: Json;+ })+) {+ if ("createdBy" in shift) {+ return client.from("shift").insert([shift]).select("*").single();+ }+ return client.from("shift").update(sanitize(shift)).eq("id", shift.id);+}diff --git a/apps/carbon/app/modules/people/types.ts b/apps/carbon/app/modules/people/types.tsnew file mode 100644index 0000000000..6c3381bac7--- /dev/null+++ b/apps/carbon/app/modules/people/types.ts@@ -0,0 +1,58 @@+import type {+ getAttribute,+ getAttributeCategories,+ getAttributeCategory,+ getDepartments,+ getEmployeeJob,+ getEmployeeSummary,+ getHolidays,+ getPeople,+ getShifts,+} from "./people.service";++export type Attribute = NonNullable<+ Awaited<ReturnType<typeof getAttribute>>["data"]+>;++export type AttributeCategory = NonNullable<+ Awaited<ReturnType<typeof getAttributeCategories>>["data"]+>[number];++export type AttributeCategoryDetailType = NonNullable<+ Awaited<ReturnType<typeof getAttributeCategory>>["data"]+>;++export type AttributeDataType = {+ id: number;+ label: string;+ isBoolean: boolean;+ isDate: boolean;+ isList: boolean;+ isNumeric: boolean;+ isText: boolean;+ isUser: boolean;+};++export type Department = NonNullable<+ Awaited<ReturnType<typeof getDepartments>>["data"]+>[number];++export type EmployeeJob = NonNullable<+ Awaited<ReturnType<typeof getEmployeeJob>>["data"]+>;++export type EmployeeSummary = NonNullable<+ Awaited<ReturnType<typeof getEmployeeSummary>>["data"]+>;++export type Holiday = NonNullable<+ Awaited<ReturnType<typeof getHolidays>>["data"]+>[number];++export type Person = NonNullable<+ Awaited<ReturnType<typeof getPeople>>["data"]+>[number];++export type Shift = NonNullable<+ Awaited<ReturnType<typeof getShifts>>["data"]+>[number];diff --git a/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoriesTable.tsx b/apps/carbon/app/modules/people/ui/Attributes/AttributeCategoriesTable.tsxsimilarity index 97%rename from apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoriesTable.tsxrename to apps/carbon/app/modules/people/ui/Attributes/AttributeCategoriesTable.tsxindex ed54061ba6..94eab84426 100644--- a/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoriesTable.tsx+++ b/apps/carbon/app/modules/people/ui/Attributes/AttributeCategoriesTable.tsx@@ -14,8 +14,9 @@ import { LuPencil, LuTrash } from "react-icons/lu";import { Hyperlink, New, Table } from "~/components";import { ConfirmDelete } from "~/components/Modals";import { usePermissions, useUrlParams } from "~/hooks";-import type { AttributeCategory } from "~/modules/resources";+import { path } from "~/utils/path";+import type { AttributeCategory } from "../../types";type AttributeCategoriesTableProps = {data: AttributeCategory[];@@ -153,7 +154,7 @@ const AttributeCategoriesTable = memo(columns={columns}count={count ?? 0}primaryAction={- permissions.can("update", "resources") && (+ permissions.can("update", "people") && (<New label="Attribute Category" to={`new?${params.toString()}`} />)}diff --git a/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoryDetail.tsx b/apps/carbon/app/modules/people/ui/Attributes/AttributeCategoryDetail.tsxsimilarity index 98%rename from apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoryDetail.tsxrename to apps/carbon/app/modules/people/ui/Attributes/AttributeCategoryDetail.tsxindex 7338c4f6f4..34423a2347 100644--- a/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoryDetail.tsx+++ b/apps/carbon/app/modules/people/ui/Attributes/AttributeCategoryDetail.tsx@@ -27,11 +27,9 @@ import { MdOutlineDragIndicator } from "react-icons/md";import { New } from "~/components";import { ConfirmDelete } from "~/components/Modals";import { useUrlParams } from "~/hooks";-import type {- Attribute,- AttributeCategoryDetailType,-} from "~/modules/resources";+import { path } from "~/utils/path";+import type { Attribute, AttributeCategoryDetailType } from "../../types";type AttributeCategoryDetailProps = {attributeCategory: AttributeCategoryDetailType;diff --git a/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoryForm.tsx b/apps/carbon/app/modules/people/ui/Attributes/AttributeCategoryForm.tsxsimilarity index 93%rename from apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoryForm.tsxrename to apps/carbon/app/modules/people/ui/Attributes/AttributeCategoryForm.tsxindex ac637b1b99..73513d7c75 100644--- a/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoryForm.tsx+++ b/apps/carbon/app/modules/people/ui/Attributes/AttributeCategoryForm.tsx@@ -13,8 +13,9 @@ import { ValidatedForm } from "@carbon/remix-validated-form";import type { z } from "zod";import { Boolean, Hidden, Input, Submit } from "~/components/Form";import { usePermissions } from "~/hooks";-import { attributeCategoryValidator } from "~/modules/resources";+import { path } from "~/utils/path";+import { attributeCategoryValidator } from "../../people.models";type AttributeCategoryFormProps = {initialValues: z.infer<typeof attributeCategoryValidator>;@@ -28,8 +29,8 @@ const AttributeCategoryForm = ({const permissions = usePermissions();const isEditing = initialValues.id !== undefined;const isDisabled = isEditing- ? !permissions.can("update", "resources")- : !permissions.can("create", "resources");+ ? !permissions.can("update", "people")+ : !permissions.can("create", "people");return (<Drawerdiff --git a/apps/carbon/app/modules/resources/ui/Attributes/AttributeForm.tsx b/apps/carbon/app/modules/people/ui/Attributes/AttributeForm.tsxsimilarity index 95%rename from apps/carbon/app/modules/resources/ui/Attributes/AttributeForm.tsxrename to apps/carbon/app/modules/people/ui/Attributes/AttributeForm.tsxindex 046fcc8625..f9c1623416 100644--- a/apps/carbon/app/modules/resources/ui/Attributes/AttributeForm.tsx+++ b/apps/carbon/app/modules/people/ui/Attributes/AttributeForm.tsx@@ -22,9 +22,9 @@ import {Submit,} from "~/components/Form";import { usePermissions } from "~/hooks";-import { attributeValidator } from "~/modules/resources";import { DataType } from "~/modules/shared";import { path } from "~/utils/path";+import { attributeValidator } from "../../people.models";type AttributeFormProps = {initialValues: z.infer<typeof attributeValidator>;@@ -55,8 +55,8 @@ const AttributeForm = ({const isEditing = initialValues.id !== undefined;const isDisabled = isEditing- ? !permissions.can("update", "resources")- : !permissions.can("create", "resources");+ ? !permissions.can("update", "people")+ : !permissions.can("create", "people");const [isList, setIsList] = useState(initialValues.attributeDataTypeId === DataType.Listdiff --git a/apps/carbon/app/modules/resources/ui/Attributes/index.ts b/apps/carbon/app/modules/people/ui/Attributes/index.tssimilarity index 100%rename from apps/carbon/app/modules/resources/ui/Attributes/index.tsrename to apps/carbon/app/modules/people/ui/Attributes/index.tsdiff --git a/apps/carbon/app/modules/resources/ui/Departments/DepartmentForm.tsx b/apps/carbon/app/modules/people/ui/Departments/DepartmentForm.tsxsimilarity index 95%rename from apps/carbon/app/modules/resources/ui/Departments/DepartmentForm.tsxrename to apps/carbon/app/modules/people/ui/Departments/DepartmentForm.tsxindex be2dfa36c6..f6365d0169 100644--- a/apps/carbon/app/modules/resources/ui/Departments/DepartmentForm.tsx+++ b/apps/carbon/app/modules/people/ui/Departments/DepartmentForm.tsx@@ -24,8 +24,8 @@ import {Submit,} from "~/components/Form";import { usePermissions } from "~/hooks";-import { departmentValidator } from "~/modules/resources";import { path } from "~/utils/path";+import { departmentValidator } from "../../people.models";type DepartmentFormProps = {initialValues: z.infer<typeof departmentValidator>;@@ -56,8 +56,8 @@ const DepartmentForm = ({const isEditing = initialValues.id !== undefined;const isDisabled = isEditing- ? !permissions.can("update", "resources")- : !permissions.can("create", "resources");+ ? !permissions.can("update", "people")+ : !permissions.can("create", "people");return (<ModalDrawerProvider type={type}>diff --git a/apps/carbon/app/modules/resources/ui/Departments/DepartmentsTable.tsx b/apps/carbon/app/modules/people/ui/Departments/DepartmentsTable.tsxsimilarity index 94%rename from apps/carbon/app/modules/resources/ui/Departments/DepartmentsTable.tsxrename to apps/carbon/app/modules/people/ui/Departments/DepartmentsTable.tsxindex 40760cf0be..d6c0bf54cd 100644--- a/apps/carbon/app/modules/resources/ui/Departments/DepartmentsTable.tsx+++ b/apps/carbon/app/modules/people/ui/Departments/DepartmentsTable.tsx@@ -6,8 +6,8 @@ import { LuPencil, LuTrash } from "react-icons/lu";import { New, Table } from "~/components";import { usePermissions, useUrlParams } from "~/hooks";import { useCustomColumns } from "~/hooks/useCustomColumns";-import type { Department } from "~/modules/resources";import { path } from "~/utils/path";+import type { Department } from "../../types";type DepartmentsTableProps = {data: Department[];@@ -68,7 +68,7 @@ const DepartmentsTable = memo(({ data, count }: DepartmentsTableProps) => {Edit Department</MenuItem><MenuItem- disabled={!permissions.can("delete", "resources")}+ disabled={!permissions.can("delete", "people")}onClick={() => {navigate(`${path.to.deleteDepartment(row.id)}?${params.toString()}`@@ -90,7 +90,7 @@ const DepartmentsTable = memo(({ data, count }: DepartmentsTableProps) => {count={count}columns={columns}primaryAction={- permissions.can("create", "resources") && (+ permissions.can("create", "people") && (<New label="Department" to={`new?${params.toString()}`} />)}diff --git a/apps/carbon/app/modules/resources/ui/Departments/index.ts b/apps/carbon/app/modules/people/ui/Departments/index.tssimilarity index 100%rename from apps/carbon/app/modules/resources/ui/Departments/index.tsrename to apps/carbon/app/modules/people/ui/Departments/index.tsdiff --git a/apps/carbon/app/modules/resources/ui/Holidays/HolidayForm.tsx b/apps/carbon/app/modules/people/ui/Holidays/HolidayForm.tsxsimilarity index 93%rename from apps/carbon/app/modules/resources/ui/Holidays/HolidayForm.tsxrename to apps/carbon/app/modules/people/ui/Holidays/HolidayForm.tsxindex 65fd9ac631..a561b61041 100644--- a/apps/carbon/app/modules/resources/ui/Holidays/HolidayForm.tsx+++ b/apps/carbon/app/modules/people/ui/Holidays/HolidayForm.tsx@@ -20,8 +20,8 @@ import {Submit,} from "~/components/Form";import { usePermissions } from "~/hooks";-import { holidayValidator } from "~/modules/resources";import { path } from "~/utils/path";+import { holidayValidator } from "../../people.models";type HolidayFormProps = {initialValues: z.infer<typeof holidayValidator>;@@ -34,8 +34,8 @@ const HolidayForm = ({ initialValues }: HolidayFormProps) => {const isEditing = initialValues.id !== undefined;const isDisabled = isEditing- ? !permissions.can("update", "resources")- : !permissions.can("create", "resources");+ ? !permissions.can("update", "people")+ : !permissions.can("create", "people");return (<Drawerdiff --git a/apps/carbon/app/modules/resources/ui/Holidays/HolidaysTable.tsx b/apps/carbon/app/modules/people/ui/Holidays/HolidaysTable.tsxsimilarity index 91%rename from apps/carbon/app/modules/resources/ui/Holidays/HolidaysTable.tsxrename to apps/carbon/app/modules/people/ui/Holidays/HolidaysTable.tsxindex ccf7a70f47..531cd60acb 100644--- a/apps/carbon/app/modules/resources/ui/Holidays/HolidaysTable.tsx+++ b/apps/carbon/app/modules/people/ui/Holidays/HolidaysTable.tsx@@ -1,5 +1,4 @@import { Enumerable, MenuIcon, MenuItem } from "@carbon/react";-import { formatDate } from "@carbon/utils";import { useNavigate } from "@remix-run/react";import type { ColumnDef } from "@tanstack/react-table";import { memo, useCallback, useMemo } from "react";@@ -8,8 +7,8 @@ import { IoMdTrash } from "react-icons/io";import { Hyperlink, New, Table } from "~/components";import { usePermissions, useUrlParams } from "~/hooks";import { useCustomColumns } from "~/hooks/useCustomColumns";-import type { Holiday } from "~/modules/resources";import { path } from "~/utils/path";+import type { Holiday } from "../../types";type HolidaysTableProps = {data: Holiday[];@@ -52,7 +51,7 @@ const HolidaysTable = memo(({ data, count, years }: HolidaysTableProps) => {{accessorKey: "date",header: "Date",- cell: (item) => formatDate(item.getValue<string>()),+ cell: (item) => item.getValue<string>(),},];return [...defaultColumns, ...customColumns];@@ -71,7 +70,7 @@ const HolidaysTable = memo(({ data, count, years }: HolidaysTableProps) => {Edit Holiday</MenuItem><MenuItem- disabled={!permissions.can("delete", "resources")}+ disabled={!permissions.can("delete", "people")}onClick={() => {navigate(`${path.to.deleteHoliday(row.id)}?${params.toString()}`);}}@@ -91,7 +90,7 @@ const HolidaysTable = memo(({ data, count, years }: HolidaysTableProps) => {count={count}columns={columns}primaryAction={- permissions.can("create", "resources") && (+ permissions.can("create", "people") && (<New label="Holiday" to={`new?${params.toString()}`} />)}diff --git a/apps/carbon/app/modules/resources/ui/Holidays/index.ts b/apps/carbon/app/modules/people/ui/Holidays/index.tssimilarity index 100%rename from apps/carbon/app/modules/resources/ui/Holidays/index.tsrename to apps/carbon/app/modules/people/ui/Holidays/index.tsdiff --git a/apps/carbon/app/modules/resources/ui/People/PeopleTable.tsx b/apps/carbon/app/modules/people/ui/People/PeopleTable.tsxsimilarity index 98%rename from apps/carbon/app/modules/resources/ui/People/PeopleTable.tsxrename to apps/carbon/app/modules/people/ui/People/PeopleTable.tsxindex cb3617c913..93bb3a43ff 100644--- a/apps/carbon/app/modules/resources/ui/People/PeopleTable.tsx+++ b/apps/carbon/app/modules/people/ui/People/PeopleTable.tsx@@ -11,10 +11,10 @@ import { memo, useCallback, useMemo } from "react";import { LuPencil } from "react-icons/lu";import { Avatar, Hyperlink, New, Table } from "~/components";import { usePermissions, useUrlParams } from "~/hooks";-import type { AttributeCategory, Person } from "~/modules/resources";import { DataType } from "~/modules/shared";import type { EmployeeType } from "~/modules/users";import { path } from "~/utils/path";+import type { AttributeCategory, Person } from "../../types";type PeopleTableProps = {attributeCategories: AttributeCategory[];@@ -186,7 +186,7 @@ const PeopleTable = memo(]);const renderContextMenu = useMemo(() => {- return permissions.can("update", "resources")+ return permissions.can("update", "people")? (row: (typeof data)[number]) => {return (<MenuItemdiff --git a/apps/carbon/app/modules/resources/ui/People/index.ts b/apps/carbon/app/modules/people/ui/People/index.tssimilarity index 100%rename from apps/carbon/app/modules/resources/ui/People/index.tsrename to apps/carbon/app/modules/people/ui/People/index.tsdiff --git a/apps/carbon/app/modules/resources/ui/Person/PersonAbilities.tsx b/apps/carbon/app/modules/people/ui/Person/PersonAbilities.tsxsimilarity index 100%rename from apps/carbon/app/modules/resources/ui/Person/PersonAbilities.tsxrename to apps/carbon/app/modules/people/ui/Person/PersonAbilities.tsxdiff --git a/apps/carbon/app/modules/resources/ui/Person/PersonDaysOff.tsx b/apps/carbon/app/modules/people/ui/Person/PersonDaysOff.tsxsimilarity index 100%rename from apps/carbon/app/modules/resources/ui/Person/PersonDaysOff.tsxrename to apps/carbon/app/modules/people/ui/Person/PersonDaysOff.tsxdiff --git a/apps/carbon/app/modules/resources/ui/Person/PersonJob.tsx b/apps/carbon/app/modules/people/ui/Person/PersonJob.tsxsimilarity index 96%rename from apps/carbon/app/modules/resources/ui/Person/PersonJob.tsxrename to apps/carbon/app/modules/people/ui/Person/PersonJob.tsxindex b08ed8d266..ddcfcb489c 100644--- a/apps/carbon/app/modules/resources/ui/Person/PersonJob.tsx+++ b/apps/carbon/app/modules/people/ui/Person/PersonJob.tsx@@ -19,7 +19,7 @@ import {Shift,Submit,} from "~/components/Form";-import { employeeJobValidator } from "~/modules/resources";+import { employeeJobValidator } from "../../people.models";type PersonJobProps = {initialValues: z.infer<typeof employeeJobValidator>;diff --git a/apps/carbon/app/modules/resources/ui/Person/PersonOvertime.tsx b/apps/carbon/app/modules/people/ui/Person/PersonOvertime.tsxsimilarity index 100%rename from apps/carbon/app/modules/resources/ui/Person/PersonOvertime.tsxrename to apps/carbon/app/modules/people/ui/Person/PersonOvertime.tsxdiff --git a/apps/carbon/app/modules/resources/ui/Person/PersonPreview.tsx b/apps/carbon/app/modules/people/ui/Person/PersonPreview.tsxsimilarity index 97%rename from apps/carbon/app/modules/resources/ui/Person/PersonPreview.tsxrename to apps/carbon/app/modules/people/ui/Person/PersonPreview.tsxindex b85b012058..a4f1862811 100644--- a/apps/carbon/app/modules/resources/ui/Person/PersonPreview.tsx+++ b/apps/carbon/app/modules/people/ui/Person/PersonPreview.tsx@@ -13,8 +13,8 @@ import {import { useParams } from "@remix-run/react";import { Avatar } from "~/components";import { useRouteData } from "~/hooks";-import type { EmployeeSummary } from "~/modules/resources";import { path } from "~/utils/path";+import type { EmployeeSummary } from "../../types";const PersonHeader = () => {const { personId } = useParams();diff --git a/apps/carbon/app/modules/resources/ui/Person/PersonSidebar/PersonSidebar.tsx b/apps/carbon/app/modules/people/ui/Person/PersonSidebar/PersonSidebar.tsxsimilarity index 100%rename from apps/carbon/app/modules/resources/ui/Person/PersonSidebar/PersonSidebar.tsxrename to apps/carbon/app/modules/people/ui/Person/PersonSidebar/PersonSidebar.tsxdiff --git a/apps/carbon/app/modules/resources/ui/Person/PersonSidebar/index.ts b/apps/carbon/app/modules/people/ui/Person/PersonSidebar/index.tssimilarity index 100%rename from apps/carbon/app/modules/resources/ui/Person/PersonSidebar/index.tsrename to apps/carbon/app/modules/people/ui/Person/PersonSidebar/index.tsdiff --git a/apps/carbon/app/modules/resources/ui/Person/PersonSidebar/usePersonSidebar.tsx b/apps/carbon/app/modules/people/ui/Person/PersonSidebar/usePersonSidebar.tsxsimilarity index 63%rename from apps/carbon/app/modules/resources/ui/Person/PersonSidebar/usePersonSidebar.tsxrename to apps/carbon/app/modules/people/ui/Person/PersonSidebar/usePersonSidebar.tsxindex 774f9da188..6681117e16 100644--- a/apps/carbon/app/modules/resources/ui/Person/PersonSidebar/usePersonSidebar.tsx+++ b/apps/carbon/app/modules/people/ui/Person/PersonSidebar/usePersonSidebar.tsx@@ -1,6 +1,6 @@import { BiSolidUserDetail } from "react-icons/bi";import { CgProfile } from "react-icons/cg";-import { MdNote, MdPublic, MdPublicOff } from "react-icons/md";+import { MdNote } from "react-icons/md";export function usePersonSidebar() {return [@@ -14,16 +14,6 @@ export function usePersonSidebar() {to: "job",icon: BiSolidUserDetail,},- {- name: "Public",- to: "public",- icon: MdPublic,- },- {- name: "Private",- to: "private",- icon: MdPublicOff,- },{name: "Notes",to: "notes",diff --git a/apps/carbon/app/modules/resources/ui/Person/index.ts b/apps/carbon/app/modules/people/ui/Person/index.tssimilarity index 100%rename from apps/carbon/app/modules/resources/ui/Person/index.tsrename to apps/carbon/app/modules/people/ui/Person/index.tsdiff --git a/apps/carbon/app/modules/resources/ui/Shifts/ShiftForm.tsx b/apps/carbon/app/modules/people/ui/Shifts/ShiftForm.tsxsimilarity index 95%rename from apps/carbon/app/modules/resources/ui/Shifts/ShiftForm.tsxrename to apps/carbon/app/modules/people/ui/Shifts/ShiftForm.tsxindex 2d2de72dde..3ff4211c94 100644--- a/apps/carbon/app/modules/resources/ui/Shifts/ShiftForm.tsx+++ b/apps/carbon/app/modules/people/ui/Shifts/ShiftForm.tsx@@ -24,8 +24,8 @@ import {TimePicker,} from "~/components/Form";import { usePermissions } from "~/hooks";-import { shiftValidator } from "~/modules/resources";import { path } from "~/utils/path";+import { shiftValidator } from "../../people.models";type ShiftFormProps = {initialValues: z.infer<typeof shiftValidator>;@@ -38,8 +38,8 @@ const ShiftForm = ({ initialValues }: ShiftFormProps) => {const isEditing = initialValues.id !== undefined;const isDisabled = isEditing- ? !permissions.can("update", "resources")- : !permissions.can("create", "resources");+ ? !permissions.can("update", "people")+ : !permissions.can("create", "people");return (<Drawerdiff --git a/apps/carbon/app/modules/resources/ui/Shifts/ShiftsTable.tsx b/apps/carbon/app/modules/people/ui/Shifts/ShiftsTable.tsxsimilarity index 94%rename from apps/carbon/app/modules/resources/ui/Shifts/ShiftsTable.tsxrename to apps/carbon/app/modules/people/ui/Shifts/ShiftsTable.tsxindex 9ff740a98d..3d02cb0ec2 100644--- a/apps/carbon/app/modules/resources/ui/Shifts/ShiftsTable.tsx+++ b/apps/carbon/app/modules/people/ui/Shifts/ShiftsTable.tsx@@ -6,8 +6,9 @@ import { LuPencil, LuTrash } from "react-icons/lu";import { Hyperlink, New, Table } from "~/components";import { usePermissions, useUrlParams } from "~/hooks";import { useCustomColumns } from "~/hooks/useCustomColumns";-import type { Shift, ShiftLocation } from "~/modules/resources";+import type { ShiftLocation } from "~/modules/resources/types";import { path } from "~/utils/path";+import type { Shift } from "../../types";type ShiftsTableProps = {data: Shift[];@@ -97,7 +98,7 @@ const ShiftsTable = memo(({ data, count, locations }: ShiftsTableProps) => {Edit Shift</MenuItem><MenuItem- disabled={!permissions.can("delete", "resources")}+ disabled={!permissions.can("delete", "people")}onClick={() => {navigate(`${path.to.deleteShift(row.id!)}?${params.toString()}`);}}@@ -117,7 +118,7 @@ const ShiftsTable = memo(({ data, count, locations }: ShiftsTableProps) => {count={count}columns={columns}primaryAction={- permissions.can("create", "resources") && (+ permissions.can("create", "people") && (<New label="Shift" to={`new?${params.toString()}`} />)}diff --git a/apps/carbon/app/modules/resources/ui/Shifts/index.ts b/apps/carbon/app/modules/people/ui/Shifts/index.tssimilarity index 100%rename from apps/carbon/app/modules/resources/ui/Shifts/index.tsrename to apps/carbon/app/modules/people/ui/Shifts/index.tsdiff --git a/apps/carbon/app/modules/people/ui/index.ts b/apps/carbon/app/modules/people/ui/index.tsnew file mode 100644index 0000000000..8b9ce51ad2--- /dev/null+++ b/apps/carbon/app/modules/people/ui/index.ts@@ -0,0 +1,9 @@+import usePeopleSubmodules from "./usePeopleSubmodules";++export * from "./Attributes";+export * from "./Departments";+export * from "./Holidays";+export * from "./People";+export * from "./Person";+export * from "./Shifts";+export { usePeopleSubmodules };diff --git a/apps/carbon/app/modules/people/ui/usePeopleSubmodules.tsx b/apps/carbon/app/modules/people/ui/usePeopleSubmodules.tsxnew file mode 100644index 0000000000..f3552ca575--- /dev/null+++ b/apps/carbon/app/modules/people/ui/usePeopleSubmodules.tsx@@ -0,0 +1,50 @@+import {+ LuCalendarClock,+ LuCalendarHeart,+ LuNetwork,+ LuUsers,+} from "react-icons/lu";+import type { RouteGroup } from "~/types";+import { path } from "~/utils/path";++const peopleRoutes: RouteGroup[] = [+ {+ name: "Manage",+ routes: [+ {+ name: "People",+ to: path.to.people,+ icon: <LuUsers />,+ },+ ],+ },+ {+ name: "Configure",+ routes: [+ // {+ // name: "Attributes",+ // to: path.to.attributes,+ // icon: <LuListChecks />,+ // },+ {+ name: "Departments",+ to: path.to.departments,+ icon: <LuNetwork />,+ },+ {+ name: "Holidays",+ to: path.to.holidays,+ icon: <LuCalendarHeart />,+ },+ {+ name: "Shifts",+ to: path.to.shifts,+ icon: <LuCalendarClock />,+ },+ ],+ },+];++export default function usePeopleSubmodules() {+ return { groups: peopleRoutes };+}diff --git a/apps/carbon/app/modules/purchasing/purchasing.service.ts b/apps/carbon/app/modules/purchasing/purchasing.service.tsindex 009ab7c933..1d25d80a14 100644--- a/apps/carbon/app/modules/purchasing/purchasing.service.ts+++ b/apps/carbon/app/modules/purchasing/purchasing.service.ts@@ -2,7 +2,7 @@ import type { Database, Json } from "@carbon/database";import { getLocalTimeZone, today } from "@internationalized/date";import type { SupabaseClient } from "@supabase/supabase-js";import type { z } from "zod";-import { getEmployeeJob } from "~/modules/resources";+import { getEmployeeJob } from "~/modules/people";import type { GenericQueryFilters } from "~/utils/query";import { setGenericQueryFilters } from "~/utils/query";import { sanitize } from "~/utils/supabase";diff --git a/apps/carbon/app/modules/resources/resources.models.ts b/apps/carbon/app/modules/resources/resources.models.tsindex b2a40425af..a41830260c 100644--- a/apps/carbon/app/modules/resources/resources.models.ts+++ b/apps/carbon/app/modules/resources/resources.models.ts@@ -1,6 +1,5 @@import { z } from "zod";import { zfd } from "zod-form-data";-import { DataType } from "~/modules/shared";export const standardFactorType = ["Hours/Piece",@@ -49,34 +48,6 @@ export const abilityNameValidator = z.object({name: z.string().min(1, { message: "Name is required" }),});-export const attributeValidator = z- .object({- id: zfd.text(z.string().optional()),- name: z.string().min(1, { message: "Name is required" }),- userAttributeCategoryId: z.string().min(20),- 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 = z.object({- id: zfd.text(z.string().optional()),- name: z.string().min(1, { message: "Name is required" }),- isPublic: zfd.checkbox(),-});-export const contractorValidator = z.object({id: z.string().min(20, { message: "Supplier Contact is required" }),supplierId: z.string().min(20, { message: "Supplier is required" }),@@ -89,12 +60,6 @@ export const contractorValidator = z.object({assignee: zfd.text(z.string().optional()),});-export const departmentValidator = z.object({- id: zfd.text(z.string().optional()),- name: z.string().min(1, { message: "Name is required" }),- parentDepartmentId: zfd.text(z.string().optional()),-});-export const employeeAbilityValidator = z.object({employeeId: z.string().min(36, { message: "Employee is required" }),trainingStatus: z.string().min(1, { message: "Status is required" }),@@ -102,14 +67,6 @@ export const employeeAbilityValidator = z.object({trainingDays: zfd.numeric(z.number().optional()),});-export const employeeJobValidator = z.object({- title: zfd.text(z.string().optional()),- startDate: zfd.text(z.string().optional()),- locationId: zfd.text(z.string().optional()),- shiftId: zfd.text(z.string().optional()),- managerId: zfd.text(z.string().optional()),-});-export const equipmentValidator = z.object({id: zfd.text(z.string().optional()),name: z.string().min(1, { message: "Name is required" }),@@ -132,12 +89,6 @@ export const equipmentTypeValidator = z.object({),});-export const holidayValidator = z.object({- id: zfd.text(z.string().optional()),- name: z.string().min(1, { message: "Name is required" }),- date: z.string().min(1, { message: "Date is required" }),-});-export const locationValidator = z.object({id: zfd.text(z.string().optional()),@@ -170,21 +121,6 @@ export const partnerValidator = z.object({abilityId: z.string().min(20, { message: "Invalid ability" }),});-export const shiftValidator = z.object({- id: zfd.text(z.string().optional()),- name: z.string().min(1, { message: "Name is required" }),- startTime: z.string().min(1, { message: "Start time is required" }),- endTime: z.string().min(1, { message: "End time is required" }),- locationId: z.string().min(1, { message: "Location is required" }),- monday: zfd.checkbox(),- tuesday: zfd.checkbox(),- wednesday: zfd.checkbox(),- thursday: zfd.checkbox(),- friday: zfd.checkbox(),- saturday: zfd.checkbox(),- sunday: zfd.checkbox(),-});-export const workCellValidator = z.object({id: zfd.text(z.string().optional()),name: z.string().min(1, { message: "Name is required" }),diff --git a/apps/carbon/app/modules/resources/resources.service.ts b/apps/carbon/app/modules/resources/resources.service.tsindex 7762e0299e..3b699932ac 100644--- a/apps/carbon/app/modules/resources/resources.service.ts+++ b/apps/carbon/app/modules/resources/resources.service.ts@@ -1,21 +1,14 @@import type { Database, Json } from "@carbon/database";import type { SupabaseClient } from "@supabase/supabase-js";import type { z } from "zod";-import type { DataType } from "~/modules/shared";-import type { Employee } from "~/modules/users";-import { getEmployees } from "~/modules/users";import type { GenericQueryFilters } from "~/utils/query";import { setGenericQueryFilters } from "~/utils/query";import { sanitize } from "~/utils/supabase";import type {- departmentValidator,- employeeJobValidator,equipmentTypeValidator,equipmentValidator,- holidayValidator,locationValidator,partnerValidator,- shiftValidator,workCellTypeValidator,workCellValidator,} from "./resources.models";@@ -30,26 +23,6 @@ export async function deleteAbility(: client.from("ability").update({ active: false }).eq("id", abilityId);}-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-) {- return client- .from("userAttributeCategory")- .update({ active: false })- .eq("id", attributeCategoryId);-}-export async function deleteContractor(client: SupabaseClient<Database>,contractorId: string@@ -57,13 +30,6 @@ export async function deleteContractor(return client.from("contractor").delete().eq("id", contractorId);}-export async function deleteDepartment(- client: SupabaseClient<Database>,- departmentId: string-) {- return client.from("department").delete().eq("id", departmentId);-}-export async function deleteEmployeeAbility(client: SupabaseClient<Database>,employeeAbilityId: string@@ -94,13 +60,6 @@ export async function deleteEquipmentType(.eq("id", equipmentTypeId);}-export async function deleteHoliday(- client: SupabaseClient<Database>,- holidayId: string-) {- return client.from("holiday").delete().eq("id", holidayId);-}-export async function deleteLocation(client: SupabaseClient<Database>,locationId: string@@ -195,93 +154,6 @@ export async function getAbility(.single();}-export async function getAttribute(- client: SupabaseClient<Database>,- attributeId: string-) {- return client- .from("userAttribute")- .select("*, userAttributeCategory(name)")- .eq("id", attributeId)- .eq("active", true)- .single();-}--async function getAttributes(- client: SupabaseClient<Database>,- companyId: string,- userIds: string[]-) {- return client- .from("userAttributeCategory")- .select(- `*,- userAttribute(id, name, listOptions, canSelfManage,- attributeDataType(id, isBoolean, isDate, isNumeric, isText, isUser),- userAttributeValue(- id, userId, valueBoolean, valueDate, valueNumeric, valueText, valueUser, user!userAttributeValue_userId_fkey(id, fullName, avatarUrl)- )- )`- )- .eq("companyId", companyId)- .eq("userAttribute.active", true)- .in("userAttribute.userAttributeValue.userId", [userIds])- .order("sortOrder", { foreignTable: "userAttribute", ascending: true });-}--export async function getAttributeCategories(- client: SupabaseClient<Database>,- companyId: string,- args?: { search: string | null } & GenericQueryFilters-) {- let query = client- .from("userAttributeCategory")- .select("*, userAttribute(id, name, attributeDataType(id))", {- count: "exact",- })- .eq("companyId", companyId)- .eq("active", true)- .eq("userAttribute.active", true);-- if (args?.search) {- query = query.ilike("name", `%${args.search}%`);- }-- if (args) {- query = setGenericQueryFilters(query, args, [- { column: "name", ascending: true },- ]);- }-- return query;-}--export async function getAttributeCategory(- client: SupabaseClient<Database>,- id: string-) {- return client- .from("userAttributeCategory")- .select(- `*,- 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 getContractor(client: SupabaseClient<Database>,contractorId: string@@ -319,49 +191,6 @@ export async function getContractors(return query;}-export async function getDepartment(- client: SupabaseClient<Database>,- departmentId: string-) {- return client.from("department").select("*").eq("id", departmentId).single();-}--export async function getDepartments(- client: SupabaseClient<Database>,- companyId: string,- args?: GenericQueryFilters & { search: string | null }-) {- let query = client- .from("department")- .select(`*, department(id, name)`, {- count: "exact",- })- .eq("companyId", companyId);-- if (args?.search) {- query = query.ilike("name", `%${args.search}%`);- }-- if (args) {- query = setGenericQueryFilters(query, args, [- { column: "name", ascending: true },- ]);- }-- return query;-}--export async function getDepartmentsList(- client: SupabaseClient<Database>,- companyId: string-) {- return client- .from("department")- .select(`id, name`)- .eq("companyId", companyId)- .order("name");-}-export async function getEmployeeAbility(client: SupabaseClient<Database>,abilityId: string,@@ -387,32 +216,6 @@ export async function getEmployeeAbilities(.eq("active", true);}-export async function getEmployeeJob(- client: SupabaseClient<Database>,- employeeId: string,- companyId: string-) {- return client- .from("employeeJob")- .select("*")- .eq("id", employeeId)- .eq("companyId", companyId)- .single();-}--export async function getEmployeeSummary(- client: SupabaseClient<Database>,- employeeId: string,- companyId: string-) {- return client- .from("employeeSummary")- .select("*")- .eq("id", employeeId)- .eq("companyId", companyId)- .single();-}-export async function getEquipment(client: SupabaseClient<Database>,equipmentId: string@@ -479,45 +282,6 @@ export async function getEquipmentTypesList(.order("name");}-export async function getHoliday(- client: SupabaseClient<Database>,- holidayId: string-) {- return client.from("holiday").select("*").eq("id", holidayId).single();-}--export async function getHolidays(- client: SupabaseClient<Database>,- companyId: string,- args?: GenericQueryFilters & { search: string | null }-) {- let query = client- .from("holiday")- .select("*", {- count: "exact",- })- .eq("companyId", companyId);-- if (args?.search) {- query = query.ilike("name", `%${args.search}%`);- }-- if (args) {- query = setGenericQueryFilters(query, args, [- { column: "date", ascending: true },- ]);- }-- return query;-}--export function getHolidayYears(- client: SupabaseClient<Database>,- companyId: string-) {- return client.from("holidayYears").select("year").eq("companyId", companyId);-}-export async function getLocation(client: SupabaseClient<Database>,locationId: string@@ -607,151 +371,6 @@ export async function getPartners(return query;}-type UserAttributeId = string;--export type PersonAttributeValue = {- userAttributeValueId: string;- value: boolean | string | number;- dataType?: DataType;- user?: {- id: string;- fullName: string | null;- avatarUrl: string | null;- } | null;-};--type PersonAttributes = Record<UserAttributeId, PersonAttributeValue>;--type Person = Employee & {- attributes: PersonAttributes;-};--export async function getPeople(- client: SupabaseClient<Database>,- companyId: string,- args: GenericQueryFilters & {- search: string | null;- }-) {- const employees = await getEmployees(client, companyId, args);- if (employees.error) return employees;-- if (!employees.data) throw new Error("Failed to get employee data");-- const userIds = employees.data.reduce<string[]>((acc, employee) => {- if (employee.id) acc.push(employee.id);- return acc;- }, []);-- const attributeCategories = await getAttributes(client, companyId, userIds);- if (attributeCategories.error) return attributeCategories;-- const people: Person[] = employees.data.map((employee) => {- const userId = employee.id;-- const employeeAttributes =- attributeCategories.data.reduce<PersonAttributes>((acc, category) => {- if (!category.userAttribute || !Array.isArray(category.userAttribute))- return acc;- category.userAttribute.forEach(- // @ts-ignore- (attribute) => {- if (- attribute.userAttributeValue &&- Array.isArray(attribute.userAttributeValue) &&- !Array.isArray(attribute.attributeDataType)- ) {- const userAttributeId = attribute.id;- const userAttributeValue = attribute.userAttributeValue.find(- // @ts-ignore- (attributeValue) => attributeValue.userId === userId- );- const value =- typeof userAttributeValue?.valueBoolean === "boolean"- ? userAttributeValue.valueBoolean- : userAttributeValue?.valueDate ||- userAttributeValue?.valueNumeric ||- userAttributeValue?.valueText ||- userAttributeValue?.valueUser;-- if (value && userAttributeValue?.id) {- acc[userAttributeId] = {- userAttributeValueId: userAttributeValue.id,- // @ts-ignore- dataType: attribute.attributeDataType?.id as DataType,- value,- user: !Array.isArray(userAttributeValue.user)- ? userAttributeValue.user- : undefined,- };- }- }- }- );- return acc;- }, {});-- return {- ...employee,- attributes: employeeAttributes,- };- });-- return {- count: employees.count,- data: people,- error: null,- };-}--export async function getShift(- client: SupabaseClient<Database>,- shiftId: string-) {- return client- .from("shifts")- .select("*")- .eq("id", shiftId)- .eq("active", true)- .single();-}--export async function getShifts(- client: SupabaseClient<Database>,- companyId: string,- args: GenericQueryFilters & { search: string | null }-) {- let query = client- .from("shifts")- .select("*", {- count: "exact",- })- .eq("companyId", companyId)- .eq("active", true);-- if (args?.search) {- query = query.ilike("name", `%${args.search}%`);- }-- query = setGenericQueryFilters(query, args, [- { column: "locationId", ascending: true },- ]);- return query;-}--export async function getShiftsList(- client: SupabaseClient<Database>,- locationId: string | null-) {- let query = client.from("shift").select(`id, name`).eq("active", true);-- if (locationId) {- query = query.eq("locationId", locationId);- }-- return query.order("name");-}-export async function getWorkCell(client: SupabaseClient<Database>,workCellId: string@@ -870,62 +489,6 @@ export async function insertEmployeeAbilities(.single();}-export async function insertAttribute(- client: SupabaseClient<Database>,- attribute: {- name: string;- attributeDataTypeId: number;- userAttributeCategoryId: string;- 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")- .single();-}--export async function insertAttributeCategory(- client: SupabaseClient<Database>,- attributeCategory: {- name: string;- public: boolean;- companyId: string;- createdBy: string;- }-) {- return client- .from("userAttributeCategory")- .upsert([attributeCategory])- .select("id")- .single();-}--export async function insertEmployeeJob(- client: SupabaseClient<Database>,- job: {- id: string;- companyId: string;- locationId?: string;- }-) {- return client.from("employeeJob").insert(job).select("*").single();-}-export async function updateAbility(client: SupabaseClient<Database>,id: string,@@ -943,76 +506,6 @@ export async function updateAbility(return client.from("ability").update(sanitize(ability)).eq("id", id);}-export async function updateAttribute(- client: SupabaseClient<Database>,- attribute: {- id?: string;- name: string;- listOptions?: string[];- canSelfManage: boolean;- updatedBy: string;- }-) {- if (!attribute.id) throw new Error("id is required");- return client- .from("userAttribute")- .update(- sanitize({- 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: string;- name: string;- public: boolean;- updatedBy: string;- }-) {- const { id, ...update } = attributeCategory;- return client- .from("userAttributeCategory")- .update(sanitize(update))- .eq("id", id);-}--export async function updateAttributeSortOrder(- client: SupabaseClient<Database>,- updates: {- id: string;- 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 updateEmployeeJob(- client: SupabaseClient<Database>,- employeeId: string,- employeeJob: z.infer<typeof employeeJobValidator> & {- companyId: string;- updatedBy: string;- customFields?: Json;- }-) {- return client- .from("employeeJob")- .update(sanitize(employeeJob))- .eq("id", employeeId)- .eq("companyId", employeeJob.companyId);-}-export async function upsertContractor(client: SupabaseClient<Database>,contractorWithAbilities:@@ -1069,29 +562,6 @@ export async function upsertContractor(return client.from("contractorAbility").insert(contractorAbilities);}-export async function upsertDepartment(- client: SupabaseClient<Database>,- department:- | (Omit<z.infer<typeof departmentValidator>, "id"> & {- companyId: string;- createdBy: string;- customFields?: Json;- })- | (Omit<z.infer<typeof departmentValidator>, "id"> & {- id: string;- updatedBy: string;- customFields?: Json;- })-) {- if ("id" in department) {- return client- .from("department")- .update(sanitize(department))- .eq("id", department.id);- }- return client.from("department").insert(department).select("*").single();-}-export async function upsertEmployeeAbility(client: SupabaseClient<Database>,employeeAbility: {@@ -1176,26 +646,6 @@ export async function upsertEquipmentType(.single();}-export async function upsertHoliday(- client: SupabaseClient<Database>,- holiday:- | (Omit<z.infer<typeof holidayValidator>, "id"> & {- companyId: string;- createdBy: string;- customFields?: Json;- })- | (Omit<z.infer<typeof holidayValidator>, "id"> & {- id: string;- updatedBy: string;- customFields?: Json;- })-) {- if ("createdBy" in holiday) {- return client.from("holiday").insert(holiday).select("*").single();- }- return client.from("holiday").update(sanitize(holiday)).eq("id", holiday.id);-}-export async function upsertLocation(client: SupabaseClient<Database>,location:@@ -1243,26 +693,6 @@ export async function upsertPartner(}}-export async function upsertShift(- client: SupabaseClient<Database>,- shift:- | (Omit<z.infer<typeof shiftValidator>, "id"> & {- createdBy: string;- companyId: string;- customFields?: Json;- })- | (Omit<z.infer<typeof shiftValidator>, "id"> & {- id: string;- updatedBy: string;- customFields?: Json;- })-) {- if ("createdBy" in shift) {- return client.from("shift").insert([shift]).select("*").single();- }- return client.from("shift").update(sanitize(shift)).eq("id", shift.id);-}-export async function upsertWorkCell(client: SupabaseClient<Database>,workCell:diff --git a/apps/carbon/app/modules/resources/types.ts b/apps/carbon/app/modules/resources/types.tsindex aae07998b2..041f8742bb 100644--- a/apps/carbon/app/modules/resources/types.ts+++ b/apps/carbon/app/modules/resources/types.ts@@ -1,22 +1,13 @@import type {getAbilities,getAbility,- getAttribute,- getAttributeCategories,- getAttributeCategory,getContractors,- getDepartments,getEmployeeAbilities,- getEmployeeJob,- getEmployeeSummary,getEquipment,getEquipmentType,getEquipmentTypes,- getHolidays,getLocations,getPartners,- getPeople,- getShifts,getWorkCellType,getWorkCellTypes,} from "./resources.service";@@ -57,49 +48,14 @@ export function getTrainingStatus(return AbilityEmployeeStatus.NotStarted;}-export type Attribute = NonNullable<- Awaited<ReturnType<typeof getAttribute>>["data"]->;--export type AttributeCategory = NonNullable<- Awaited<ReturnType<typeof getAttributeCategories>>["data"]->[number];--export type AttributeCategoryDetailType = NonNullable<- Awaited<ReturnType<typeof getAttributeCategory>>["data"]->;--export type AttributeDataType = {- id: number;- label: string;- isBoolean: boolean;- isDate: boolean;- isList: boolean;- isNumeric: boolean;- isText: boolean;- isUser: boolean;-};-export type Contractor = NonNullable<Awaited<ReturnType<typeof getContractors>>["data"]>[number];-export type Department = NonNullable<- Awaited<ReturnType<typeof getDepartments>>["data"]->[number];-export type EmployeeAbility = NonNullable<Awaited<ReturnType<typeof getEmployeeAbilities>>["data"]>[number];-export type EmployeeJob = NonNullable<- Awaited<ReturnType<typeof getEmployeeJob>>["data"]->;--export type EmployeeSummary = NonNullable<- Awaited<ReturnType<typeof getEmployeeSummary>>["data"]->;-export type Equipment = NonNullable<Awaited<ReturnType<typeof getEquipment>>["data"]>;@@ -112,10 +68,6 @@ export type EquipmentTypeDetailType = NonNullable<Awaited<ReturnType<typeof getEquipmentType>>["data"]>;-export type Holiday = NonNullable<- Awaited<ReturnType<typeof getHolidays>>["data"]->[number];-export type Location = NonNullable<Awaited<ReturnType<typeof getLocations>>["data"]>[number];@@ -124,14 +76,6 @@ export type Partner = NonNullable<Awaited<ReturnType<typeof getPartners>>["data"]>[number];-export type Person = NonNullable<- Awaited<ReturnType<typeof getPeople>>["data"]->[number];--export type Shift = NonNullable<- Awaited<ReturnType<typeof getShifts>>["data"]->[number];-export type ShiftLocation = NonNullable<Awaited<ReturnType<typeof getLocations>>["data"]>[number];diff --git a/apps/carbon/app/modules/resources/ui/Abilities/AbilitiesTable.tsx b/apps/carbon/app/modules/resources/ui/Abilities/AbilitiesTable.tsxindex 89f7486b4e..7d93dfea8b 100644--- a/apps/carbon/app/modules/resources/ui/Abilities/AbilitiesTable.tsx+++ b/apps/carbon/app/modules/resources/ui/Abilities/AbilitiesTable.tsx@@ -12,8 +12,8 @@ import { memo, useCallback, useMemo } from "react";import { LuPencil, LuTrash } from "react-icons/lu";import { Avatar, New, Table } from "~/components";import { usePermissions, useUrlParams } from "~/hooks";-import type { Abilities, AbilityDatum } from "~/modules/resources";import { path } from "~/utils/path";+import type { Abilities, AbilityDatum } from "../../types";import AbilityChart from "./AbilityChart";type AbilitiesTableProps = {diff --git a/apps/carbon/app/modules/resources/ui/Abilities/AbilityChart.tsx b/apps/carbon/app/modules/resources/ui/Abilities/AbilityChart.tsxindex 27263f5fbd..21fb72de77 100644--- a/apps/carbon/app/modules/resources/ui/Abilities/AbilityChart.tsx+++ b/apps/carbon/app/modules/resources/ui/Abilities/AbilityChart.tsx@@ -8,7 +8,7 @@ import { PatternLines } from "@visx/pattern";import { scaleLinear } from "@visx/scale";import { AreaClosed, LinePath } from "@visx/shape";import { useRef } from "react";-import type { AbilityDatum } from "~/modules/resources";+import type { AbilityDatum } from "../../types";type AbilityChartProps = {data: AbilityDatum[];diff --git a/apps/carbon/app/modules/resources/ui/Abilities/AbilityEmployeesTable.tsx b/apps/carbon/app/modules/resources/ui/Abilities/AbilityEmployeesTable.tsxindex fa374c5330..c5de82231d 100644--- a/apps/carbon/app/modules/resources/ui/Abilities/AbilityEmployeesTable.tsx+++ b/apps/carbon/app/modules/resources/ui/Abilities/AbilityEmployeesTable.tsx@@ -11,8 +11,8 @@ import { useCallback, useMemo } from "react";import { LuPencil, LuTrash } from "react-icons/lu";import { Avatar, New, Table } from "~/components";import { usePermissions } from "~/hooks";-import type { AbilityEmployees } from "~/modules/resources";-import { AbilityEmployeeStatus } from "~/modules/resources";+import { AbilityEmployeeStatus, type AbilityEmployees } from "../../types";+import { path } from "~/utils/path";type AbilityEmployeeTableProps = {diff --git a/apps/carbon/app/modules/resources/ui/Abilities/AbilityForm.tsx b/apps/carbon/app/modules/resources/ui/Abilities/AbilityForm.tsxindex c1ae279cb8..8ba718bc4a 100644--- a/apps/carbon/app/modules/resources/ui/Abilities/AbilityForm.tsx+++ b/apps/carbon/app/modules/resources/ui/Abilities/AbilityForm.tsx@@ -23,8 +23,8 @@ import {Submit,} from "~/components/Form";import { usePermissions } from "~/hooks";-import { abilityValidator } from "~/modules/resources";import { path } from "~/utils/path";+import { abilityValidator } from "../../resources.models";type AbilityFormProps = {initialValues: z.infer<typeof abilityValidator>;diff --git a/apps/carbon/app/modules/resources/ui/Abilities/EmployeeAbilityForm.tsx b/apps/carbon/app/modules/resources/ui/Abilities/EmployeeAbilityForm.tsxindex 4a64820e2e..c2a90f00fa 100644--- a/apps/carbon/app/modules/resources/ui/Abilities/EmployeeAbilityForm.tsx+++ b/apps/carbon/app/modules/resources/ui/Abilities/EmployeeAbilityForm.tsx@@ -23,12 +23,10 @@ import {Submit,} from "~/components/Form";import { usePermissions } from "~/hooks";-import type { Ability } from "~/modules/resources";-import {- AbilityEmployeeStatus,- employeeAbilityValidator,-} from "~/modules/resources";+import { AbilityEmployeeStatus, type Ability } from "../../types";+import { path } from "~/utils/path";+import { employeeAbilityValidator } from "../../resources.models";type EmployeeAbilityFormProps = {ability?: Ability;@@ -47,7 +45,7 @@ const EmployeeAbilityForm = ({}: EmployeeAbilityFormProps) => {const { id } = useParams();const permissions = usePermissions();- const isEditing = initialValues.employeeId !== undefined;+ const isEditing = !!initialValues.employeeId;const isDisabled = isEditing? !permissions.can("update", "resources"): !permissions.can("create", "resources");@@ -66,6 +64,8 @@ const EmployeeAbilityForm = ({if (!ability) return null;+ console.log({ isEditing });+return (<Draweropendiff --git a/apps/carbon/app/modules/resources/ui/index.ts b/apps/carbon/app/modules/resources/ui/index.tsindex 984cdc61e0..4dce5bb036 100644--- a/apps/carbon/app/modules/resources/ui/index.ts+++ b/apps/carbon/app/modules/resources/ui/index.ts@@ -1,15 +1,9 @@import useResourcesSubmodules from "./useResourcesSubmodules";export * from "./Abilities";-export * from "./Attributes";export * from "./Contractors";-export * from "./Departments";export * from "./Equipment";-export * from "./Holidays";export * from "./Locations";export * from "./Partners";-export * from "./People";-export * from "./Person";-export * from "./Shifts";export * from "./WorkCells";export { useResourcesSubmodules };diff --git a/apps/carbon/app/modules/resources/ui/useResourcesSubmodules.tsx b/apps/carbon/app/modules/resources/ui/useResourcesSubmodules.tsxindex 71cc5f855a..3599d92e57 100644--- a/apps/carbon/app/modules/resources/ui/useResourcesSubmodules.tsx+++ b/apps/carbon/app/modules/resources/ui/useResourcesSubmodules.tsx@@ -1,14 +1,4 @@-import {- LuCalendarClock,- LuCalendarHeart,- LuGroup,- LuHammer,- LuListChecks,- LuMapPin,- LuNetwork,- LuShapes,- LuUsers,-} from "react-icons/lu";+import { LuGroup, LuHammer, LuMapPin, LuShapes } from "react-icons/lu";import type { RouteGroup } from "~/types";import { path } from "~/utils/path";@@ -16,11 +6,6 @@ const resourcesRoutes: RouteGroup[] = [{name: "Manage",routes: [- {- name: "People",- to: path.to.people,- icon: <LuUsers />,- },// {// name: "Contractors",// to: path.to.contractors,@@ -31,6 +16,11 @@ const resourcesRoutes: RouteGroup[] = [// to: path.to.partners,// icon: <FaPeopleArrows />,// },+ {+ name: "Abilities",+ to: path.to.abilities,+ icon: <LuHammer />,+ },{name: "Work Cells",to: path.to.workCells,@@ -46,36 +36,11 @@ const resourcesRoutes: RouteGroup[] = [{name: "Configure",routes: [- {- name: "Abilities",- to: path.to.abilities,- icon: <LuHammer />,- },- {- name: "Attributes",- to: path.to.attributes,- icon: <LuListChecks />,- },- {- name: "Departments",- to: path.to.departments,- icon: <LuNetwork />,- },- {- name: "Holidays",- to: path.to.holidays,- icon: <LuCalendarHeart />,- },{name: "Locations",to: path.to.locations,icon: <LuMapPin />,},- {- name: "Shifts",- to: path.to.shifts,- icon: <LuCalendarClock />,- },],},];diff --git a/apps/carbon/app/modules/sales/sales.service.ts b/apps/carbon/app/modules/sales/sales.service.tsindex 06201f8f8c..b8efd2f57d 100644--- a/apps/carbon/app/modules/sales/sales.service.ts+++ b/apps/carbon/app/modules/sales/sales.service.ts@@ -2,7 +2,7 @@ import type { Database, Json } from "@carbon/database";import { getLocalTimeZone, today } from "@internationalized/date";import type { PostgrestError, SupabaseClient } from "@supabase/supabase-js";import type { z } from "zod";-import { getEmployeeJob } from "~/modules/resources";+import { getEmployeeJob } from "~/modules/people";import type { GenericQueryFilters } from "~/utils/query";import { setGenericQueryFilters } from "~/utils/query";import { sanitize } from "~/utils/supabase";diff --git a/apps/carbon/app/modules/users/ui/components/Permission.tsx b/apps/carbon/app/modules/users/ui/components/Permission.tsxindex 32a00806af..777b45c3f6 100644--- a/apps/carbon/app/modules/users/ui/components/Permission.tsx+++ b/apps/carbon/app/modules/users/ui/components/Permission.tsx@@ -25,6 +25,10 @@ const PermissionCheckboxes = ({updatePermissions(module, newPermissions);};+ if (["messaging", "items", "timecards"].includes(module)) {+ return null;+ }+return (<div><HStack>diff --git a/apps/carbon/app/modules/users/users.server.ts b/apps/carbon/app/modules/users/users.server.tsindex 7641dc515e..ec39e3d3a3 100644--- a/apps/carbon/app/modules/users/users.server.ts+++ b/apps/carbon/app/modules/users/users.server.ts@@ -25,7 +25,7 @@ import { flash, requireAuthSession } from "~/services/session.server";import type { Result } from "~/types";import { path } from "~/utils/path";import { error, success } from "~/utils/result";-import { insertEmployeeJob } from "../resources";+import { insertEmployeeJob } from "../people/people.service";export async function addUserToCompany(client: SupabaseClient<Database>,diff --git a/apps/carbon/app/routes/api+/resources.abilities.ts b/apps/carbon/app/routes/api+/people.abilities.tssimilarity index 82%rename from apps/carbon/app/routes/api+/resources.abilities.tsrename to apps/carbon/app/routes/api+/people.abilities.tsindex 47d6ee504b..f72585e72a 100644--- a/apps/carbon/app/routes/api+/resources.abilities.ts+++ b/apps/carbon/app/routes/api+/people.abilities.ts@@ -1,11 +1,11 @@import type { LoaderFunctionArgs } from "@remix-run/node";import { json } from "@remix-run/node";-import { getAbilitiesList } from "~/modules/resources";+import { getAbilitiesList } from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";export async function loader({ request }: LoaderFunctionArgs) {const { client, companyId } = await requirePermissions(request, {- view: "resources",+ view: "people",});return json(await getAbilitiesList(client, companyId));diff --git a/apps/carbon/app/routes/api+/resources.departments.ts b/apps/carbon/app/routes/api+/people.departments.tssimilarity index 86%rename from apps/carbon/app/routes/api+/resources.departments.tsrename to apps/carbon/app/routes/api+/people.departments.tsindex b4dbca19e9..f9f95f7e01 100644--- a/apps/carbon/app/routes/api+/resources.departments.ts+++ b/apps/carbon/app/routes/api+/people.departments.ts@@ -1,6 +1,6 @@import type { LoaderFunctionArgs } from "@remix-run/node";import { json } from "@remix-run/node";-import { getDepartmentsList } from "~/modules/resources";+import { getDepartmentsList } from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";export async function loader({ request }: LoaderFunctionArgs) {diff --git a/apps/carbon/app/routes/api+/resources.shifts.ts b/apps/carbon/app/routes/api+/people.shifts.tssimilarity index 89%rename from apps/carbon/app/routes/api+/resources.shifts.tsrename to apps/carbon/app/routes/api+/people.shifts.tsindex 348219a4c1..07f18f22d4 100644--- a/apps/carbon/app/routes/api+/resources.shifts.ts+++ b/apps/carbon/app/routes/api+/people.shifts.ts@@ -1,6 +1,6 @@import type { LoaderFunctionArgs } from "@remix-run/node";import { json } from "@remix-run/node";-import { getShiftsList } from "~/modules/resources";+import { getShiftsList } from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";export async function loader({ request }: LoaderFunctionArgs) {diff --git a/apps/carbon/app/routes/onboarding+/company.tsx b/apps/carbon/app/routes/onboarding+/company.tsxindex 94be927b73..6deb2c7a11 100644--- a/apps/carbon/app/routes/onboarding+/company.tsx+++ b/apps/carbon/app/routes/onboarding+/company.tsx@@ -21,11 +21,8 @@ import { Hidden, Input, Submit } from "~/components/Form";import { useOnboarding } from "~/hooks";import logger from "~/lib/logger";import { getSupabaseServiceRole } from "~/lib/supabase";-import {- getLocationsList,- insertEmployeeJob,- upsertLocation,-} from "~/modules/resources";+import { insertEmployeeJob } from "~/modules/people";+import { getLocationsList, upsertLocation } from "~/modules/resources";import {getCompanies,getCompany,diff --git a/apps/carbon/app/routes/x+/account+/personal.tsx b/apps/carbon/app/routes/x+/account+/personal.tsxdeleted file mode 100644index 1089cdf385..0000000000--- a/apps/carbon/app/routes/x+/account+/personal.tsx+++ /dev/null@@ -1,68 +0,0 @@-import {- Card,- CardContent,- CardHeader,- CardTitle,- VStack,-} from "@carbon/react";-import type { LoaderFunctionArgs } from "@remix-run/node";-import { json, redirect } from "@remix-run/node";-import { useLoaderData } from "@remix-run/react";-import type { PrivateAttributes } from "~/modules/account";-import { UserAttributesForm, getPrivateAttributes } from "~/modules/account";-import { requirePermissions } from "~/services/auth/auth.server";-import { flash } from "~/services/session.server";-import type { Handle } from "~/utils/handle";-import { path } from "~/utils/path";-import { error } from "~/utils/result";--export const handle: Handle = {- breadcrumb: "Personal",- to: path.to.accountPersonal,-};--export async function loader({ request }: LoaderFunctionArgs) {- const { client, companyId, userId } = await requirePermissions(request, {});-- const [privateAttributes] = await Promise.all([- getPrivateAttributes(client, userId, companyId),- ]);-- if (privateAttributes.error) {- throw redirect(- path.to.authenticatedRoot,- 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 (- <VStack spacing={4}>- {attributes.length ? (- attributes.map((category: PrivateAttributes) => (- <Card key={category.id}>- <CardHeader>- <CardTitle>{category.name}</CardTitle>- </CardHeader>- <CardContent>- <UserAttributesForm attributeCategory={category} />- </CardContent>- </Card>- ))- ) : (- <Card>- <CardContent className="text-muted-foreground w-full py-8 text-center">- No private attributes- </CardContent>- </Card>- )}- </VStack>- );-}diff --git a/apps/carbon/app/routes/x+/account+/profile.tsx b/apps/carbon/app/routes/x+/account+/profile.tsxindex 0ddb992c62..6303da7903 100644--- a/apps/carbon/app/routes/x+/account+/profile.tsx+++ b/apps/carbon/app/routes/x+/account+/profile.tsx@@ -13,10 +13,8 @@ import { useLoaderData } from "@remix-run/react";import {ProfileForm,ProfilePhotoForm,- UserAttributesForm,accountProfileValidator,getAccount,- getPublicAttributes,updateAvatar,updatePublicAccount,} from "~/modules/account";@@ -35,10 +33,7 @@ export const handle: Handle = {export async function loader({ request }: LoaderFunctionArgs) {const { client, companyId, userId } = await requirePermissions(request, {});- const [user, publicAttributes] = await Promise.all([- getAccount(client, userId),- getPublicAttributes(client, userId, companyId),- ]);+ const [user] = await Promise.all([getAccount(client, userId)]);if (user.error || !user.data) {throw redirect(@@ -47,17 +42,7 @@ export async function loader({ request }: LoaderFunctionArgs) {);}- if (publicAttributes.error) {- throw redirect(- path.to.authenticatedRoot,- await flash(- request,- error(publicAttributes.error, "Failed to get user attributes")- )- );- }-- return json({ user: user.data, attributes: publicAttributes.data });+ return json({ user: user.data });}export async function action({ request }: ActionFunctionArgs) {@@ -127,7 +112,7 @@ export async function action({ request }: ActionFunctionArgs) {}export default function AccountProfile() {- const { user, attributes } = useLoaderData<typeof loader>();+ const { user } = useLoaderData<typeof loader>();return (<VStack spacing={4}>@@ -146,27 +131,6 @@ export default function AccountProfile() {</div></CardContent></Card>-- {attributes.length ? (- <>- {attributes.map((category) => (- <Card key={category.id}>- <CardHeader>- <CardTitle>{category.name}</CardTitle>- </CardHeader>- <CardContent>- <UserAttributesForm attributeCategory={category} />- </CardContent>- </Card>- ))}- </>- ) : (- <Card>- <CardContent className="text-muted-foreground w-full text-center py-8">- No public attributes- </CardContent>- </Card>- )}</VStack>);}diff --git a/apps/carbon/app/routes/x+/people+/_index.tsx b/apps/carbon/app/routes/x+/people+/_index.tsxnew file mode 100644index 0000000000..e9d928df18--- /dev/null+++ b/apps/carbon/app/routes/x+/people+/_index.tsx@@ -0,0 +1,6 @@+import { redirect } from "@remix-run/node";+import { path } from "~/utils/path";++export async function loader() {+ throw redirect(path.to.people);+}diff --git a/apps/carbon/app/routes/x+/people+/_layout.tsx b/apps/carbon/app/routes/x+/people+/_layout.tsxnew file mode 100644index 0000000000..c31d7d4cc5--- /dev/null+++ b/apps/carbon/app/routes/x+/people+/_layout.tsx@@ -0,0 +1,30 @@+import { VStack } from "@carbon/react";+import type { MetaFunction } from "@remix-run/node";+import { Outlet } from "@remix-run/react";+import { GroupedContentSidebar } from "~/components/Layout";+import { usePeopleSubmodules } from "~/modules/people";+import type { Handle } from "~/utils/handle";+import { path } from "~/utils/path";++export const meta: MetaFunction = () => {+ return [{ title: "Carbon | People" }];+};++export const handle: Handle = {+ breadcrumb: "People",+ to: path.to.people,+ module: "people",+};++export default function PeopleRoute() {+ const { groups } = usePeopleSubmodules();++ return (+ <div className="grid grid-cols-[auto_1fr] w-full h-full">+ <GroupedContentSidebar groups={groups} />+ <VStack spacing={0} className="h-full">+ <Outlet />+ </VStack>+ </div>+ );+}diff --git a/apps/carbon/app/routes/x+/resources+/attribute.$attributeId.tsx b/apps/carbon/app/routes/x+/people+/attribute.$attributeId.tsxsimilarity index 92%rename from apps/carbon/app/routes/x+/resources+/attribute.$attributeId.tsxrename to apps/carbon/app/routes/x+/people+/attribute.$attributeId.tsxindex a0070a23ae..7bd2620824 100644--- a/apps/carbon/app/routes/x+/resources+/attribute.$attributeId.tsx+++ b/apps/carbon/app/routes/x+/people+/attribute.$attributeId.tsx@@ -1,7 +1,7 @@import { validationError, validator } from "@carbon/remix-validated-form";import type { ActionFunctionArgs } from "@remix-run/node";import { redirect } from "@remix-run/node";-import { attributeValidator, updateAttribute } from "~/modules/resources";+import { attributeValidator, updateAttribute } from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { assertIsPost } from "~/utils/http";@@ -11,7 +11,7 @@ import { error, success } from "~/utils/result";export async function action({ request, params }: ActionFunctionArgs) {assertIsPost(request);const { client, userId } = await requirePermissions(request, {- update: "resources",+ update: "people",});const validation = await validator(attributeValidator).validate(diff --git a/apps/carbon/app/routes/x+/resources+/attribute.delete.$attributeId.tsx b/apps/carbon/app/routes/x+/people+/attribute.delete.$attributeId.tsxsimilarity index 92%rename from apps/carbon/app/routes/x+/resources+/attribute.delete.$attributeId.tsxrename to apps/carbon/app/routes/x+/people+/attribute.delete.$attributeId.tsxindex 667861e563..72749840a1 100644--- a/apps/carbon/app/routes/x+/resources+/attribute.delete.$attributeId.tsx+++ b/apps/carbon/app/routes/x+/people+/attribute.delete.$attributeId.tsx@@ -1,6 +1,6 @@import type { LoaderFunctionArgs } from "@remix-run/node";import { redirect } from "@remix-run/node";-import { deleteAttribute } from "~/modules/resources";+import { deleteAttribute } from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { path } from "~/utils/path";@@ -8,7 +8,7 @@ import { error, success } from "~/utils/result";export async function action({ request, params }: LoaderFunctionArgs) {const { client } = await requirePermissions(request, {- delete: "resources",+ delete: "people",});const { attributeId } = params;diff --git a/apps/carbon/app/routes/x+/resources+/attribute.new.tsx b/apps/carbon/app/routes/x+/people+/attribute.new.tsxsimilarity index 93%rename from apps/carbon/app/routes/x+/resources+/attribute.new.tsxrename to apps/carbon/app/routes/x+/people+/attribute.new.tsxindex 62f58b43e1..28425aa6f7 100644--- a/apps/carbon/app/routes/x+/resources+/attribute.new.tsx+++ b/apps/carbon/app/routes/x+/people+/attribute.new.tsx@@ -1,7 +1,7 @@import { validationError, validator } from "@carbon/remix-validated-form";import type { ActionFunctionArgs } from "@remix-run/node";import { json, redirect } from "@remix-run/node";-import { attributeValidator, insertAttribute } from "~/modules/resources";+import { attributeValidator, insertAttribute } from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { assertIsPost } from "~/utils/http";@@ -11,7 +11,7 @@ import { error } from "~/utils/result";export async function action({ request }: ActionFunctionArgs) {assertIsPost(request);const { client, userId } = await requirePermissions(request, {- create: "resources",+ create: "people",});const validation = await validator(attributeValidator).validate(diff --git a/apps/carbon/app/routes/x+/resources+/attributes.$categoryId.tsx b/apps/carbon/app/routes/x+/people+/attributes.$categoryId.tsxsimilarity index 97%rename from apps/carbon/app/routes/x+/resources+/attributes.$categoryId.tsxrename to apps/carbon/app/routes/x+/people+/attributes.$categoryId.tsxindex c8d18e0cce..87875346ca 100644--- a/apps/carbon/app/routes/x+/resources+/attributes.$categoryId.tsx+++ b/apps/carbon/app/routes/x+/people+/attributes.$categoryId.tsx@@ -7,7 +7,7 @@ import {attributeCategoryValidator,getAttributeCategory,updateAttributeCategory,-} from "~/modules/resources";+} from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { assertIsPost, notFound } from "~/utils/http";@@ -16,7 +16,7 @@ import { error, success } from "~/utils/result";export async function loader({ request, params }: LoaderFunctionArgs) {const { client } = await requirePermissions(request, {- view: "resources",+ view: "people",role: "employee",});@@ -40,7 +40,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {export async function action({ request }: ActionFunctionArgs) {assertIsPost(request);const { client, userId } = await requirePermissions(request, {- update: "resources",+ update: "people",});const validation = await validator(attributeCategoryValidator).validate(diff --git a/apps/carbon/app/routes/x+/resources+/attributes.delete.$categoryId.tsx b/apps/carbon/app/routes/x+/people+/attributes.delete.$categoryId.tsxsimilarity index 92%rename from apps/carbon/app/routes/x+/resources+/attributes.delete.$categoryId.tsxrename to apps/carbon/app/routes/x+/people+/attributes.delete.$categoryId.tsxindex 08588f1b1f..a216f7fedd 100644--- a/apps/carbon/app/routes/x+/resources+/attributes.delete.$categoryId.tsx+++ b/apps/carbon/app/routes/x+/people+/attributes.delete.$categoryId.tsx@@ -1,6 +1,6 @@import type { LoaderFunctionArgs } from "@remix-run/node";import { redirect } from "@remix-run/node";-import { deleteAttributeCategory } from "~/modules/resources";+import { deleteAttributeCategory } from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { path } from "~/utils/path";@@ -8,7 +8,7 @@ import { error, success } from "~/utils/result";export async function action({ request, params }: LoaderFunctionArgs) {const { client } = await requirePermissions(request, {- update: "resources",+ update: "people",});const { categoryId } = params;diff --git a/apps/carbon/app/routes/x+/resources+/attributes.list.$categoryId.$attributeId.tsx b/apps/carbon/app/routes/x+/people+/attributes.list.$categoryId.$attributeId.tsxsimilarity index 93%rename from apps/carbon/app/routes/x+/resources+/attributes.list.$categoryId.$attributeId.tsxrename to apps/carbon/app/routes/x+/people+/attributes.list.$categoryId.$attributeId.tsxindex 09753a1759..619d21e57f 100644--- a/apps/carbon/app/routes/x+/resources+/attributes.list.$categoryId.$attributeId.tsx+++ b/apps/carbon/app/routes/x+/people+/attributes.list.$categoryId.$attributeId.tsx@@ -2,8 +2,8 @@ import type { LoaderFunctionArgs } from "@remix-run/node";import { json, redirect } from "@remix-run/node";import { useLoaderData, useNavigate, useParams } from "@remix-run/react";import { useRouteData } from "~/hooks";-import type { AttributeDataType } from "~/modules/resources";-import { AttributeForm, getAttribute } from "~/modules/resources";+import type { AttributeDataType } from "~/modules/people";+import { AttributeForm, getAttribute } from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { notFound } from "~/utils/http";@@ -12,7 +12,7 @@ import { error } from "~/utils/result";export async function loader({ request, params }: LoaderFunctionArgs) {const { client } = await requirePermissions(request, {- view: "resources",+ view: "people",role: "employee",});diff --git a/apps/carbon/app/routes/x+/resources+/attributes.list.$categoryId.new.tsx b/apps/carbon/app/routes/x+/people+/attributes.list.$categoryId.new.tsxsimilarity index 87%rename from apps/carbon/app/routes/x+/resources+/attributes.list.$categoryId.new.tsxrename to apps/carbon/app/routes/x+/people+/attributes.list.$categoryId.new.tsxindex e6ae7910ef..1bfe1c1889 100644--- a/apps/carbon/app/routes/x+/resources+/attributes.list.$categoryId.new.tsx+++ b/apps/carbon/app/routes/x+/people+/attributes.list.$categoryId.new.tsx@@ -1,7 +1,7 @@import { useNavigate, useParams } from "@remix-run/react";import { useRouteData } from "~/hooks";-import type { AttributeDataType } from "~/modules/resources";-import { AttributeForm } from "~/modules/resources";+import type { AttributeDataType } from "~/modules/people";+import { AttributeForm } from "~/modules/people";import { DataType } from "~/modules/shared";import { path } from "~/utils/path";diff --git a/apps/carbon/app/routes/x+/resources+/attributes.list.$categoryId.tsx b/apps/carbon/app/routes/x+/people+/attributes.list.$categoryId.tsxsimilarity index 96%rename from apps/carbon/app/routes/x+/resources+/attributes.list.$categoryId.tsxrename to apps/carbon/app/routes/x+/people+/attributes.list.$categoryId.tsxindex e572dd2664..c386559134 100644--- a/apps/carbon/app/routes/x+/resources+/attributes.list.$categoryId.tsx+++ b/apps/carbon/app/routes/x+/people+/attributes.list.$categoryId.tsx@@ -6,7 +6,7 @@ import {AttributeCategoryDetail,getAttributeCategory,updateAttributeSortOrder,-} from "~/modules/resources";+} from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { assertIsPost, notFound } from "~/utils/http";@@ -15,7 +15,7 @@ import { error } from "~/utils/result";export async function loader({ request, params }: LoaderFunctionArgs) {const { client } = await requirePermissions(request, {- view: "resources",+ view: "people",role: "employee",});@@ -39,7 +39,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {export async function action({ request }: ActionFunctionArgs) {assertIsPost(request);const { client, userId } = await requirePermissions(request, {- update: "resources",+ update: "people",});const updateMap = (await request.formData()).get("updates") as string;diff --git a/apps/carbon/app/routes/x+/resources+/attributes.new.tsx b/apps/carbon/app/routes/x+/people+/attributes.new.tsxsimilarity index 96%rename from apps/carbon/app/routes/x+/resources+/attributes.new.tsxrename to apps/carbon/app/routes/x+/people+/attributes.new.tsxindex f0c564badc..8049661edb 100644--- a/apps/carbon/app/routes/x+/resources+/attributes.new.tsx+++ b/apps/carbon/app/routes/x+/people+/attributes.new.tsx@@ -6,7 +6,7 @@ import {AttributeCategoryForm,attributeCategoryValidator,insertAttributeCategory,-} from "~/modules/resources";+} from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { assertIsPost } from "~/utils/http";@@ -16,7 +16,7 @@ import { error } from "~/utils/result";export async function action({ request }: ActionFunctionArgs) {assertIsPost(request);const { client, companyId, userId } = await requirePermissions(request, {- update: "resources",+ update: "people",});const validation = await validator(attributeCategoryValidator).validate(diff --git a/apps/carbon/app/routes/x+/resources+/attributes.tsx b/apps/carbon/app/routes/x+/people+/attributes.tsxsimilarity index 97%rename from apps/carbon/app/routes/x+/resources+/attributes.tsxrename to apps/carbon/app/routes/x+/people+/attributes.tsxindex 4e3644115a..e26c31bac4 100644--- a/apps/carbon/app/routes/x+/resources+/attributes.tsx+++ b/apps/carbon/app/routes/x+/people+/attributes.tsx@@ -6,7 +6,7 @@ import {AttributeCategoriesTable,getAttributeCategories,getAttributeDataTypes,-} from "~/modules/resources";+} from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import type { Handle } from "~/utils/handle";@@ -21,7 +21,7 @@ export const handle: Handle = {export async function loader({ request }: LoaderFunctionArgs) {const { client, companyId } = await requirePermissions(request, {- view: "resources",+ view: "people",role: "employee",});diff --git a/apps/carbon/app/routes/x+/resources+/departments.$departmentId.tsx b/apps/carbon/app/routes/x+/people+/departments.$departmentId.tsxsimilarity index 97%rename from apps/carbon/app/routes/x+/resources+/departments.$departmentId.tsxrename to apps/carbon/app/routes/x+/people+/departments.$departmentId.tsxindex 276ef79569..2fc1c6807c 100644--- a/apps/carbon/app/routes/x+/resources+/departments.$departmentId.tsx+++ b/apps/carbon/app/routes/x+/people+/departments.$departmentId.tsx@@ -7,7 +7,7 @@ import {departmentValidator,getDepartment,upsertDepartment,-} from "~/modules/resources";+} from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { getCustomFields, setCustomFields } from "~/utils/form";@@ -17,7 +17,7 @@ import { error, success } from "~/utils/result";export async function loader({ request, params }: LoaderFunctionArgs) {const { client } = await requirePermissions(request, {- view: "resources",+ view: "people",});const { departmentId } = params;@@ -40,7 +40,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {export async function action({ request }: ActionFunctionArgs) {assertIsPost(request);const { client, userId } = await requirePermissions(request, {- create: "resources",+ create: "people",});const formData = await request.formData();diff --git a/apps/carbon/app/routes/x+/resources+/departments.delete.$departmentId.tsx b/apps/carbon/app/routes/x+/people+/departments.delete.$departmentId.tsxsimilarity index 95%rename from apps/carbon/app/routes/x+/resources+/departments.delete.$departmentId.tsxrename to apps/carbon/app/routes/x+/people+/departments.delete.$departmentId.tsxindex f3ebdbe098..c24caaae01 100644--- a/apps/carbon/app/routes/x+/resources+/departments.delete.$departmentId.tsx+++ b/apps/carbon/app/routes/x+/people+/departments.delete.$departmentId.tsx@@ -2,7 +2,7 @@ import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";import { json, redirect } from "@remix-run/node";import { useLoaderData, useNavigate, useParams } from "@remix-run/react";import { ConfirmDelete } from "~/components/Modals";-import { deleteDepartment, getDepartment } from "~/modules/resources";+import { deleteDepartment, getDepartment } from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { notFound } from "~/utils/http";@@ -11,7 +11,7 @@ import { error, success } from "~/utils/result";export async function loader({ request, params }: LoaderFunctionArgs) {const { client } = await requirePermissions(request, {- view: "resources",+ view: "people",role: "employee",});@@ -33,7 +33,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {export async function action({ request, params }: ActionFunctionArgs) {const { client } = await requirePermissions(request, {- delete: "resources",+ delete: "people",});const { departmentId } = params;diff --git a/apps/carbon/app/routes/x+/resources+/departments.new.tsx b/apps/carbon/app/routes/x+/people+/departments.new.tsxsimilarity index 97%rename from apps/carbon/app/routes/x+/resources+/departments.new.tsxrename to apps/carbon/app/routes/x+/people+/departments.new.tsxindex 41798f642a..bad8341386 100644--- a/apps/carbon/app/routes/x+/resources+/departments.new.tsx+++ b/apps/carbon/app/routes/x+/people+/departments.new.tsx@@ -6,7 +6,7 @@ import {DepartmentForm,departmentValidator,upsertDepartment,-} from "~/modules/resources";+} from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { setCustomFields } from "~/utils/form";@@ -17,7 +17,7 @@ import { error, success } from "~/utils/result";export async function action({ request }: ActionFunctionArgs) {assertIsPost(request);const { client, companyId, userId } = await requirePermissions(request, {- create: "resources",+ create: "people",});const formData = await request.formData();diff --git a/apps/carbon/app/routes/x+/resources+/departments.tsx b/apps/carbon/app/routes/x+/people+/departments.tsxsimilarity index 93%rename from apps/carbon/app/routes/x+/resources+/departments.tsxrename to apps/carbon/app/routes/x+/people+/departments.tsxindex 31f1c84bda..98d2872a30 100644--- a/apps/carbon/app/routes/x+/resources+/departments.tsx+++ b/apps/carbon/app/routes/x+/people+/departments.tsx@@ -2,7 +2,7 @@ import { VStack } from "@carbon/react";import type { LoaderFunctionArgs } from "@remix-run/node";import { json, redirect } from "@remix-run/node";import { Outlet, useLoaderData } from "@remix-run/react";-import { DepartmentsTable, getDepartments } from "~/modules/resources";+import { DepartmentsTable, getDepartments } from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import type { Handle } from "~/utils/handle";@@ -17,7 +17,7 @@ export const handle: Handle = {export async function loader({ request }: LoaderFunctionArgs) {const { client, companyId } = await requirePermissions(request, {- view: "resources",+ view: "people",role: "employee",});@@ -37,7 +37,7 @@ export async function loader({ request }: LoaderFunctionArgs) {if (departments.error) {throw redirect(- path.to.resources,+ path.to.people,await flash(request,error(departments.error, "Failed to load departments")diff --git a/apps/carbon/app/routes/x+/resources+/holidays.$holidayId.tsx b/apps/carbon/app/routes/x+/people+/holidays.$holidayId.tsxsimilarity index 96%rename from apps/carbon/app/routes/x+/resources+/holidays.$holidayId.tsxrename to apps/carbon/app/routes/x+/people+/holidays.$holidayId.tsxindex 5303d0ab84..9d06d8ae28 100644--- a/apps/carbon/app/routes/x+/resources+/holidays.$holidayId.tsx+++ b/apps/carbon/app/routes/x+/people+/holidays.$holidayId.tsx@@ -7,7 +7,7 @@ import {getHoliday,holidayValidator,upsertHoliday,-} from "~/modules/resources";+} from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { getCustomFields } from "~/utils/form";@@ -17,7 +17,7 @@ import { error, success } from "~/utils/result";export async function loader({ request, params }: LoaderFunctionArgs) {const { client } = await requirePermissions(request, {- view: "resources",+ view: "people",});const { holidayId } = params;@@ -40,7 +40,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {export async function action({ request }: ActionFunctionArgs) {assertIsPost(request);const { client, userId } = await requirePermissions(request, {- create: "resources",+ create: "people",});const formData = await request.formData();diff --git a/apps/carbon/app/routes/x+/resources+/holidays.delete.$holidayId.tsx b/apps/carbon/app/routes/x+/people+/holidays.delete.$holidayId.tsxsimilarity index 95%rename from apps/carbon/app/routes/x+/resources+/holidays.delete.$holidayId.tsxrename to apps/carbon/app/routes/x+/people+/holidays.delete.$holidayId.tsxindex 89928ebdbe..299343dc52 100644--- a/apps/carbon/app/routes/x+/resources+/holidays.delete.$holidayId.tsx+++ b/apps/carbon/app/routes/x+/people+/holidays.delete.$holidayId.tsx@@ -2,7 +2,7 @@ import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";import { json, redirect } from "@remix-run/node";import { useLoaderData, useNavigate, useParams } from "@remix-run/react";import { ConfirmDelete } from "~/components/Modals";-import { deleteHoliday, getHoliday } from "~/modules/resources";+import { deleteHoliday, getHoliday } from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { notFound } from "~/utils/http";@@ -11,7 +11,7 @@ import { error, success } from "~/utils/result";export async function loader({ request, params }: LoaderFunctionArgs) {const { client } = await requirePermissions(request, {- view: "resources",+ view: "people",role: "employee",});@@ -33,7 +33,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {export async function action({ request, params }: ActionFunctionArgs) {const { client } = await requirePermissions(request, {- delete: "resources",+ delete: "people",});const { holidayId } = params;diff --git a/apps/carbon/app/routes/x+/resources+/holidays.new.tsx b/apps/carbon/app/routes/x+/people+/holidays.new.tsxsimilarity index 92%rename from apps/carbon/app/routes/x+/resources+/holidays.new.tsxrename to apps/carbon/app/routes/x+/people+/holidays.new.tsxindex c38f2db72a..d6bf90c453 100644--- a/apps/carbon/app/routes/x+/resources+/holidays.new.tsx+++ b/apps/carbon/app/routes/x+/people+/holidays.new.tsx@@ -1,11 +1,7 @@import { validationError, validator } from "@carbon/remix-validated-form";import type { ActionFunctionArgs } from "@remix-run/node";import { redirect } from "@remix-run/node";-import {- HolidayForm,- holidayValidator,- upsertHoliday,-} from "~/modules/resources";+import { HolidayForm, holidayValidator, upsertHoliday } from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { setCustomFields } from "~/utils/form";@@ -16,7 +12,7 @@ import { error, success } from "~/utils/result";export async function action({ request }: ActionFunctionArgs) {assertIsPost(request);const { client, companyId, userId } = await requirePermissions(request, {- create: "resources",+ create: "people",});const formData = await request.formData();diff --git a/apps/carbon/app/routes/x+/resources+/holidays.tsx b/apps/carbon/app/routes/x+/people+/holidays.tsxsimilarity index 92%rename from apps/carbon/app/routes/x+/resources+/holidays.tsxrename to apps/carbon/app/routes/x+/people+/holidays.tsxindex 038dd72a28..bad72c2519 100644--- a/apps/carbon/app/routes/x+/resources+/holidays.tsx+++ b/apps/carbon/app/routes/x+/people+/holidays.tsx@@ -2,11 +2,7 @@ import { VStack } from "@carbon/react";import type { LoaderFunctionArgs } from "@remix-run/node";import { json, redirect } from "@remix-run/node";import { Outlet, useLoaderData } from "@remix-run/react";-import {- HolidaysTable,- getHolidayYears,- getHolidays,-} from "~/modules/resources";+import { HolidaysTable, getHolidayYears, getHolidays } from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import type { Handle } from "~/utils/handle";@@ -21,7 +17,7 @@ export const handle: Handle = {export async function loader({ request }: LoaderFunctionArgs) {const { client, companyId } = await requirePermissions(request, {- view: "resources",+ view: "people",role: "employee",});@@ -44,7 +40,7 @@ export async function loader({ request }: LoaderFunctionArgs) {if (holidays.error) {throw redirect(- path.to.resources,+ path.to.people,await flash(request, error(holidays.error, "Failed to load holidays")));}diff --git a/apps/carbon/app/routes/x+/resources+/people.tsx b/apps/carbon/app/routes/x+/people+/people.tsxsimilarity index 92%rename from apps/carbon/app/routes/x+/resources+/people.tsxrename to apps/carbon/app/routes/x+/people+/people.tsxindex e6944bd7fd..9553ee3e66 100644--- a/apps/carbon/app/routes/x+/resources+/people.tsx+++ b/apps/carbon/app/routes/x+/people+/people.tsx@@ -6,23 +6,17 @@ import {PeopleTable,getAttributeCategories,getPeople,-} from "~/modules/resources";+} from "~/modules/people";import { getEmployeeTypes } from "~/modules/users";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";-import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";import { getGenericQueryFilters } from "~/utils/query";import { error } from "~/utils/result";-export const handle: Handle = {- breadcrumb: "People",- to: path.to.people,-};-export async function loader({ request }: LoaderFunctionArgs) {const { client, companyId } = await requirePermissions(request, {- view: "resources",+ view: "people",role: "employee",});diff --git a/apps/carbon/app/routes/x+/resources+/shifts.$shiftId.tsx b/apps/carbon/app/routes/x+/people+/shifts.$shiftId.tsxsimilarity index 97%rename from apps/carbon/app/routes/x+/resources+/shifts.$shiftId.tsxrename to apps/carbon/app/routes/x+/people+/shifts.$shiftId.tsxindex 9fbe1336eb..91462acd24 100644--- a/apps/carbon/app/routes/x+/resources+/shifts.$shiftId.tsx+++ b/apps/carbon/app/routes/x+/people+/shifts.$shiftId.tsx@@ -7,7 +7,7 @@ import {getShift,shiftValidator,upsertShift,-} from "~/modules/resources";+} from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { getCustomFields, setCustomFields } from "~/utils/form";@@ -17,7 +17,7 @@ import { error, success } from "~/utils/result";export async function loader({ request, params }: LoaderFunctionArgs) {const { client } = await requirePermissions(request, {- view: "resources",+ view: "people",});const { shiftId } = params;@@ -40,7 +40,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {export async function action({ request }: ActionFunctionArgs) {assertIsPost(request);const { client, userId } = await requirePermissions(request, {- create: "resources",+ create: "people",});const formData = await request.formData();diff --git a/apps/carbon/app/routes/x+/resources+/shifts.delete.$shiftId.tsx b/apps/carbon/app/routes/x+/people+/shifts.delete.$shiftId.tsxsimilarity index 95%rename from apps/carbon/app/routes/x+/resources+/shifts.delete.$shiftId.tsxrename to apps/carbon/app/routes/x+/people+/shifts.delete.$shiftId.tsxindex ed9e5073f8..a37769cdb9 100644--- a/apps/carbon/app/routes/x+/resources+/shifts.delete.$shiftId.tsx+++ b/apps/carbon/app/routes/x+/people+/shifts.delete.$shiftId.tsx@@ -2,7 +2,7 @@ import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";import { json, redirect } from "@remix-run/node";import { useLoaderData, useNavigate, useParams } from "@remix-run/react";import { ConfirmDelete } from "~/components/Modals";-import { deleteShift, getShift } from "~/modules/resources";+import { deleteShift, getShift } from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { notFound } from "~/utils/http";@@ -11,7 +11,7 @@ import { error, success } from "~/utils/result";export async function loader({ request, params }: LoaderFunctionArgs) {const { client } = await requirePermissions(request, {- view: "resources",+ view: "people",role: "employee",});@@ -33,7 +33,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {export async function action({ request, params }: ActionFunctionArgs) {const { client } = await requirePermissions(request, {- delete: "resources",+ delete: "people",});const { shiftId } = params;diff --git a/apps/carbon/app/routes/x+/resources+/shifts.new.tsx b/apps/carbon/app/routes/x+/people+/shifts.new.tsxsimilarity index 97%rename from apps/carbon/app/routes/x+/resources+/shifts.new.tsxrename to apps/carbon/app/routes/x+/people+/shifts.new.tsxindex ffe87306e4..b6b2c5c588 100644--- a/apps/carbon/app/routes/x+/resources+/shifts.new.tsx+++ b/apps/carbon/app/routes/x+/people+/shifts.new.tsx@@ -1,7 +1,7 @@import { validationError, validator } from "@carbon/remix-validated-form";import type { ActionFunctionArgs } from "@remix-run/node";import { redirect } from "@remix-run/node";-import { ShiftForm, shiftValidator, upsertShift } from "~/modules/resources";+import { ShiftForm, shiftValidator, upsertShift } from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { setCustomFields } from "~/utils/form";@@ -12,7 +12,7 @@ import { error, success } from "~/utils/result";export async function action({ request }: ActionFunctionArgs) {assertIsPost(request);const { client, companyId, userId } = await requirePermissions(request, {- create: "resources",+ create: "people",});const formData = await request.formData();diff --git a/apps/carbon/app/routes/x+/resources+/shifts.tsx b/apps/carbon/app/routes/x+/people+/shifts.tsxsimilarity index 90%rename from apps/carbon/app/routes/x+/resources+/shifts.tsxrename to apps/carbon/app/routes/x+/people+/shifts.tsxindex 1a52cf115f..782bb4f6fe 100644--- a/apps/carbon/app/routes/x+/resources+/shifts.tsx+++ b/apps/carbon/app/routes/x+/people+/shifts.tsx@@ -2,7 +2,8 @@ import { VStack } from "@carbon/react";import type { LoaderFunctionArgs } from "@remix-run/node";import { json, redirect } from "@remix-run/node";import { Outlet, useLoaderData } from "@remix-run/react";-import { ShiftsTable, getLocations, getShifts } from "~/modules/resources";+import { ShiftsTable, getShifts } from "~/modules/people";+import { getLocations } from "~/modules/resources/resources.service";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import type { Handle } from "~/utils/handle";@@ -17,7 +18,7 @@ export const handle: Handle = {export async function loader({ request }: LoaderFunctionArgs) {const { client, companyId } = await requirePermissions(request, {- view: "resources",+ view: "people",role: "employee",});@@ -34,7 +35,7 @@ export async function loader({ request }: LoaderFunctionArgs) {if (shifts.error) {throw redirect(- path.to.resources,+ path.to.people,await flash(request, error(shifts.error, "Failed to load shifts")));}diff --git a/apps/carbon/app/routes/x+/person+/$personId.details.tsx b/apps/carbon/app/routes/x+/person+/$personId.details.tsxindex a3c494fcfe..f4cc133d83 100644--- a/apps/carbon/app/routes/x+/person+/$personId.details.tsx+++ b/apps/carbon/app/routes/x+/person+/$personId.details.tsx@@ -11,7 +11,7 @@ import { ProfileForm, getAccount } from "~/modules/account";export async function loader({ request, params }: LoaderFunctionArgs) {const { client } = await requirePermissions(request, {- view: "resources",+ view: "people",});const { personId } = params;diff --git a/apps/carbon/app/routes/x+/person+/$personId.job.tsx b/apps/carbon/app/routes/x+/person+/$personId.job.tsxindex d547d769c4..260c11e3dd 100644--- a/apps/carbon/app/routes/x+/person+/$personId.job.tsx+++ b/apps/carbon/app/routes/x+/person+/$personId.job.tsx@@ -12,13 +12,13 @@ import {employeeJobValidator,getEmployeeJob,updateEmployeeJob,-} from "~/modules/resources";+} from "~/modules/people";import { getCustomFields, setCustomFields } from "~/utils/form";import { assertIsPost } from "~/utils/http";export async function loader({ request, params }: LoaderFunctionArgs) {const { client, companyId } = await requirePermissions(request, {- view: "resources",+ view: "people",});const { personId } = params;@@ -40,7 +40,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {export async function action({ request, params }: ActionFunctionArgs) {assertIsPost(request);const { client, companyId, userId } = await requirePermissions(request, {- update: "resources",+ update: "people",});const { personId } = params;if (!personId) throw new Error("No person ID provided");diff --git a/apps/carbon/app/routes/x+/person+/$personId.notes.tsx b/apps/carbon/app/routes/x+/person+/$personId.notes.tsxindex b15d326209..a8f4552331 100644--- a/apps/carbon/app/routes/x+/person+/$personId.notes.tsx+++ b/apps/carbon/app/routes/x+/person+/$personId.notes.tsx@@ -11,7 +11,7 @@ import { error } from "~/utils/result";export async function loader({ request, params }: LoaderFunctionArgs) {const { client } = await requirePermissions(request, {- view: "resources",+ view: "people",});const { personId } = params;diff --git a/apps/carbon/app/routes/x+/person+/$personId.private.tsx b/apps/carbon/app/routes/x+/person+/$personId.private.tsxdeleted file mode 100644index 84cf3e373f..0000000000--- a/apps/carbon/app/routes/x+/person+/$personId.private.tsx+++ /dev/null@@ -1,103 +0,0 @@-import { Card, CardContent, CardHeader, CardTitle } from "@carbon/react";-import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";-import { json, redirect } from "@remix-run/node";-import { useLoaderData } from "@remix-run/react";--import { validationError, validator } from "@carbon/remix-validated-form";-import type { PrivateAttributes } from "~/modules/account";-import { UserAttributesForm, getPrivateAttributes } from "~/modules/account";-import { employeeJobValidator, updateEmployeeJob } from "~/modules/resources";-import { requirePermissions } from "~/services/auth/auth.server";-import { flash } from "~/services/session.server";-import { assertIsPost } from "~/utils/http";-import { path } from "~/utils/path";-import { error, success } from "~/utils/result";--export async function loader({ request, params }: LoaderFunctionArgs) {- const { client, companyId } = await requirePermissions(request, {- view: "resources",- });-- const { personId } = params;- if (!personId) throw new Error("Could not find personId");-- const privateAttributes = await getPrivateAttributes(- client,- personId,- companyId- );- if (privateAttributes.error) {- throw redirect(- path.to.people,- await flash(- request,- error(privateAttributes.error, "Failed to load private attributes")- )- );- }-- return json({- privateAttributes: privateAttributes.data,- });-}--export async function action({ request, params }: ActionFunctionArgs) {- assertIsPost(request);- const { client, companyId, userId } = await requirePermissions(request, {- update: "resources",- });- const { personId } = params;- if (!personId) throw new Error("No person ID provided");-- const validation = await validator(employeeJobValidator).validate(- await request.formData()- );-- if (validation.error) {- return validationError(validation.error);- }-- const updateJob = await updateEmployeeJob(client, personId, {- ...validation.data,- companyId,- updatedBy: userId,- });- if (updateJob.error) {- throw redirect(- path.to.personJob(personId),- await flash(request, error(updateJob.error, "Failed to update job"))- );- }-- throw redirect(- path.to.personJob(personId),- await flash(request, success("Successfully updated job"))- );-}--export default function PersonPrivateRoute() {- const { privateAttributes } = useLoaderData<typeof loader>();-- return (- <div className="flex flex-col space-y-8">- {privateAttributes.length ? (- privateAttributes.map((category: PrivateAttributes) => (- <Card key={category.id}>- <CardHeader>- <CardTitle>{category.name}</CardTitle>- </CardHeader>- <CardContent>- <UserAttributesForm attributeCategory={category} />- </CardContent>- </Card>- ))- ) : (- <Card>- <CardContent className="text-muted-foreground w-full text-center py-16">- No private attributes- </CardContent>- </Card>- )}- </div>- );-}diff --git a/apps/carbon/app/routes/x+/person+/$personId.public.tsx b/apps/carbon/app/routes/x+/person+/$personId.public.tsxdeleted file mode 100644index c6edfe9524..0000000000--- a/apps/carbon/app/routes/x+/person+/$personId.public.tsx+++ /dev/null@@ -1,103 +0,0 @@-import { Card, CardContent, CardHeader, CardTitle } from "@carbon/react";-import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";-import { json, redirect } from "@remix-run/node";-import { useLoaderData } from "@remix-run/react";--import { validationError, validator } from "@carbon/remix-validated-form";-import type { PublicAttributes } from "~/modules/account";-import { UserAttributesForm, getPublicAttributes } from "~/modules/account";-import { employeeJobValidator, updateEmployeeJob } from "~/modules/resources";-import { requirePermissions } from "~/services/auth/auth.server";-import { flash } from "~/services/session.server";-import { assertIsPost } from "~/utils/http";-import { path } from "~/utils/path";-import { error, success } from "~/utils/result";--export async function loader({ request, params }: LoaderFunctionArgs) {- const { client, companyId } = await requirePermissions(request, {- view: "resources",- });-- const { personId } = params;- if (!personId) throw new Error("Could not find personId");-- const publicAttributes = await getPublicAttributes(- client,- personId,- companyId- );- if (publicAttributes.error) {- throw redirect(- path.to.people,- await flash(- request,- error(publicAttributes.error, "Failed to load public attributes")- )- );- }-- return json({- publicAttributes: publicAttributes.data,- });-}--export async function action({ request, params }: ActionFunctionArgs) {- assertIsPost(request);- const { client, companyId, userId } = await requirePermissions(request, {- update: "resources",- });- const { personId } = params;- if (!personId) throw new Error("No person ID provided");-- const validation = await validator(employeeJobValidator).validate(- await request.formData()- );-- if (validation.error) {- return validationError(validation.error);- }-- const updateJob = await updateEmployeeJob(client, personId, {- ...validation.data,- companyId,- updatedBy: userId,- });- if (updateJob.error) {- throw redirect(- path.to.personJob(personId),- await flash(request, error(updateJob.error, "Failed to update job"))- );- }-- throw redirect(- path.to.personJob(personId),- await flash(request, success("Successfully updated job"))- );-}--export default function PersonPublicRoute() {- const { publicAttributes } = useLoaderData<typeof loader>();-- return (- <div className="flex flex-col space-y-8">- {publicAttributes.length ? (- publicAttributes.map((category: PublicAttributes) => (- <Card key={category.id}>- <CardHeader>- <CardTitle>{category.name}</CardTitle>- </CardHeader>- <CardContent>- <UserAttributesForm attributeCategory={category} />- </CardContent>- </Card>- ))- ) : (- <Card>- <CardContent className="text-muted-foreground w-full text-center py-16">- No public attributes- </CardContent>- </Card>- )}- </div>- );-}diff --git a/apps/carbon/app/routes/x+/person+/$personId.tsx b/apps/carbon/app/routes/x+/person+/$personId.tsxindex 30a88b7e7c..4b4fa05074 100644--- a/apps/carbon/app/routes/x+/person+/$personId.tsx+++ b/apps/carbon/app/routes/x+/person+/$personId.tsx@@ -10,7 +10,7 @@ import {PersonPreview,PersonSidebar,getEmployeeSummary,-} from "~/modules/resources";+} from "~/modules/people";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import type { Handle } from "~/utils/handle";@@ -25,7 +25,7 @@ export const handle: Handle = {export async function loader({ request, params }: LoaderFunctionArgs) {const { client, companyId } = await requirePermissions(request, {- view: "resources",+ view: "people",});const { personId } = params;@@ -53,7 +53,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {export async function action({ request, params }: ActionFunctionArgs) {assertIsPost(request);const { client } = await requirePermissions(request, {- update: "resources",+ update: "people",});const { personId } = params;if (!personId) throw new Error("No person ID provided");diff --git a/apps/carbon/app/routes/x+/person+/_layout.tsx b/apps/carbon/app/routes/x+/person+/_layout.tsxindex e753a98c95..6638dd9ecd 100644--- a/apps/carbon/app/routes/x+/person+/_layout.tsx+++ b/apps/carbon/app/routes/x+/person+/_layout.tsx@@ -2,22 +2,14 @@ import { VStack } from "@carbon/react";import { type LoaderFunctionArgs, type MetaFunction } from "@remix-run/node";import { Outlet } from "@remix-run/react";import { requirePermissions } from "~/services/auth/auth.server";-import type { Handle } from "~/utils/handle";-import { path } from "~/utils/path";export const meta: MetaFunction = () => {return [{ title: "Carbon | People" }];};-export const handle: Handle = {- breadcrumb: "Resources",- to: path.to.people,- module: "resources",-};-export async function loader({ request }: LoaderFunctionArgs) {await requirePermissions(request, {- view: "resources",+ view: "people",});return null;diff --git a/apps/carbon/app/routes/x+/resources+/_index.tsx b/apps/carbon/app/routes/x+/resources+/_index.tsxindex e9d928df18..0609d5daef 100644--- a/apps/carbon/app/routes/x+/resources+/_index.tsx+++ b/apps/carbon/app/routes/x+/resources+/_index.tsx@@ -2,5 +2,5 @@ import { redirect } from "@remix-run/node";import { path } from "~/utils/path";export async function loader() {- throw redirect(path.to.people);+ throw redirect(path.to.workCells);}diff --git a/apps/carbon/app/routes/x+/resources+/_layout.tsx b/apps/carbon/app/routes/x+/resources+/_layout.tsxindex 1adf4448d1..62f7d6d380 100644--- a/apps/carbon/app/routes/x+/resources+/_layout.tsx+++ b/apps/carbon/app/routes/x+/resources+/_layout.tsx@@ -12,7 +12,7 @@ export const meta: MetaFunction = () => {export const handle: Handle = {breadcrumb: "Resources",- to: path.to.people,+ to: path.to.resources,module: "resources",};diff --git a/apps/carbon/app/routes/x+/resources+/ability.$abilityId.employee.$id.tsx b/apps/carbon/app/routes/x+/resources+/ability.$abilityId.employee.$id.tsxindex 7a9b846855..dfbc67c88e 100644--- a/apps/carbon/app/routes/x+/resources+/ability.$abilityId.employee.$id.tsx+++ b/apps/carbon/app/routes/x+/resources+/ability.$abilityId.employee.$id.tsx@@ -6,12 +6,12 @@ import { useRouteData } from "~/hooks";import type { Ability } from "~/modules/resources";import {AbilityEmployeeStatus,+ EmployeeAbilityForm,employeeAbilityValidator,getEmployeeAbility,getTrainingStatus,upsertEmployeeAbility,} from "~/modules/resources";-import { EmployeeAbilityForm } from "~/modules/resources/ui/Abilities";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { path } from "~/utils/path";diff --git a/apps/carbon/app/routes/x+/resources+/ability.$abilityId.employee.new.tsx b/apps/carbon/app/routes/x+/resources+/ability.$abilityId.employee.new.tsxindex df05e4496b..7d065602a6 100644--- a/apps/carbon/app/routes/x+/resources+/ability.$abilityId.employee.new.tsx+++ b/apps/carbon/app/routes/x+/resources+/ability.$abilityId.employee.new.tsx@@ -6,10 +6,10 @@ import { useRouteData } from "~/hooks";import type { Ability } from "~/modules/resources";import {AbilityEmployeeStatus,+ EmployeeAbilityForm,employeeAbilityValidator,upsertEmployeeAbility,} from "~/modules/resources";-import { EmployeeAbilityForm } from "~/modules/resources/ui/Abilities";import { requirePermissions } from "~/services/auth/auth.server";import { flash } from "~/services/session.server";import { path } from "~/utils/path";diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.tsindex d5f55d8b1b..00dba04c9a 100644--- a/apps/carbon/app/utils/path.ts+++ b/apps/carbon/app/utils/path.ts@@ -24,7 +24,7 @@ export const path = {generatePath(`${api}/sales/customer-locations?customerId=${id}`),customerStatuses: `${api}/sales/customer-statuses`,customerTypes: `${api}/sales/customer-types`,- departments: `${api}/resources/departments`,+ departments: `${api}/people/departments`,employeeTypes: `${api}/users/employee-types`,emptyPermissions: `${api}/users/empty-permissions`,equipmentTypes: `${api}/resources/equipment-types`,@@ -42,7 +42,7 @@ export const path = {sequences: (table: string) => `${api}/settings/sequences?table=${table}`,services: `${api}/items/services`,shifts: (id: string) =>- generatePath(`${api}/resources/shifts?location=${id}`),+ generatePath(`${api}/people/shifts?location=${id}`),shelves: (id: string) =>generatePath(`${api}/items/shelf?locationId=${id}`),supplierContacts: (id: string) =>@@ -95,12 +95,12 @@ export const path = {accountingRoot: `${x}/accounting`,accountingSubcategory: (id: string) =>generatePath(`${x}/accounting/subcategory/${id}`),- attribute: (id: string) => generatePath(`${x}/resources/attribute/${id}`),- attributes: `${x}/resources/attributes`,+ attribute: (id: string) => generatePath(`${x}/people/attribute/${id}`),+ attributes: `${x}/people/attributes`,attributeCategory: (id: string) =>- generatePath(`${x}/resources/attributes/${id}`),+ generatePath(`${x}/people/attributes/${id}`),attributeCategoryList: (id: string) =>- generatePath(`${x}/resources/attributes/list/${id}`),+ generatePath(`${x}/people/attributes/list/${id}`),bulkEditPermissions: `${x}/users/bulk-edit-permissions`,chartOfAccount: (id: string) =>generatePath(`${x}/accounting/charts/${id}`),@@ -177,9 +177,9 @@ export const path = {deleteAccountingCharts: (id: string) =>generatePath(`${x}/accounting/charts/delete/${id}`),deleteAttribute: (id: string) =>- generatePath(`${x}/resources/attribute/delete/${id}`),+ generatePath(`${x}/people/attribute/delete/${id}`),deleteAttributeCategory: (id: string) =>- generatePath(`${x}/resources/attributes/delete/${id}`),+ generatePath(`${x}/people/attributes/delete/${id}`),deleteContractor: (id: string) =>generatePath(`${x}/resources/contractors/delete/${id}`),deleteCurrency: (id: string) =>@@ -195,7 +195,7 @@ export const path = {deleteCustomField: (tableId: string, id: string) =>generatePath(`${x}/settings/custom-fields/${tableId}/delete/${id}`),deleteDepartment: (id: string) =>- generatePath(`${x}/resources/departments/delete/${id}`),+ generatePath(`${x}/people/departments/delete/${id}`),deleteDocument: (id: string) => generatePath(`${x}/documents/${id}/trash`),deleteDocumentPermanently: (id: string) =>generatePath(`${x}/documents/${id}/delete`),@@ -209,7 +209,7 @@ export const path = {generatePath(`${x}/resources/equipment/delete/${id}`),deleteGroup: (id: string) => generatePath(`${x}/users/groups/delete/${id}`),deleteHoliday: (id: string) =>- generatePath(`${x}/resources/holidays/delete/${id}`),+ generatePath(`${x}/people/holidays/delete/${id}`),deleteLocation: (id: string) =>generatePath(`${x}/resources/locations/delete/${id}`),deleteItem: (id: string) => generatePath(`${x}/items/delete/${id}`),@@ -252,7 +252,7 @@ export const path = {deleteSalesRfqLine: (id: string, lineId: string) =>generatePath(`${x}/sales-rfq/${id}/${lineId}/delete`),deleteShift: (id: string) =>- generatePath(`${x}/resources/shifts/delete/${id}`),+ generatePath(`${x}/people/shifts/delete/${id}`),deleteShippingMethod: (id: string) =>generatePath(`${x}/inventory/shipping-methods/delete/${id}`),deleteSupplierContact: (supplierId: string, id: string) =>@@ -270,9 +270,8 @@ export const path = {generatePath(`${x}/resources/work-cells/cell/delete/${id}`),deleteWorkCellType: (id: string) =>generatePath(`${x}/resources/work-cells/delete/${id}`),- department: (id: string) =>- generatePath(`${x}/resources/departments/${id}`),- departments: `${x}/resources/departments`,+ department: (id: string) => generatePath(`${x}/people/departments/${id}`),+ departments: `${x}/people/departments`,document: (id: string) => generatePath(`${x}/documents/search/${id}`),documentView: (id: string) =>generatePath(`${x}/documents/search/view/${id}`),@@ -330,8 +329,8 @@ export const path = {forgotPassword: "/forgot-password",group: (id: string) => generatePath(`${x}/users/groups/${id}`),groups: `${x}/users/groups`,- holiday: (id: string) => generatePath(`${x}/resources/holidays/${id}`),- holidays: `${x}/resources/holidays`,+ holiday: (id: string) => generatePath(`${x}/people/holidays/${id}`),+ holidays: `${x}/people/holidays`,integration: (name: string) =>generatePath(`${x}/settings/integrations/${name}`),integrations: `${x}/settings/integrations`,@@ -384,10 +383,10 @@ export const path = {newAccountingCategory: `${x}/accounting/categories/new`,newAccountingSubcategory: (id: string) =>generatePath(`${x}/accounting/categories/list/${id}/new`),- newAttribute: `${x}/resources/attribute/new`,- newAttributeCategory: `${x}/resources/attributes/new`,+ newAttribute: `${x}/people/attribute/new`,+ newAttributeCategory: `${x}/people/attributes/new`,newAttributeForCategory: (id: string) =>- generatePath(`${x}/resources/attributes/list/${id}/new`),+ generatePath(`${x}/people/attributes/list/${id}/new`),newChartOfAccount: `${x}/accounting/charts/new`,newCompany: `${x}/settings/company/new`,newConsumable: `${x}/consumable/new`,@@ -405,7 +404,7 @@ export const path = {newCustomerType: `${x}/sales/customer-types/new`,newCustomField: (tableId: string) =>generatePath(`${x}/settings/custom-fields/${tableId}/new`),- newDepartment: `${x}/resources/departments/new`,+ newDepartment: `${x}/people/departments/new`,newDocument: `${x}/documents/new`,newEmployee: `${x}/users/employees/new`,newEmployeeAbility: (id: string) =>@@ -419,7 +418,7 @@ export const path = {newFixtureSupplier: (id: string) =>generatePath(`${x}/fixture/${id}/purchasing/new`),newGroup: `${x}/users/groups/new`,- newHoliday: `${x}/resources/holidays/new`,+ newHoliday: `${x}/people/holidays/new`,newLocation: `${x}/resources/locations/new`,newMaterial: `${x}/material/new`,newMethodMaterial: `${x}/items/methods/material/new`,@@ -455,7 +454,7 @@ export const path = {generatePath(`${x}/sales-order/${id}/lines/new`),newSalesRFQ: `${x}/sales-rfq/new`,newSalesRFQLine: (id: string) => generatePath(`${x}/sales-rfq/${id}/new`),- newShift: `${x}/resources/shifts/new`,+ newShift: `${x}/people/shifts/new`,newShippingMethod: `${x}/inventory/shipping-methods/new`,newService: `${x}/service/new`,newServiceSupplier: (id: string) =>@@ -510,7 +509,7 @@ export const path = {paymentTerm: (id: string) =>generatePath(`${x}/accounting/payment-terms/${id}`),paymentTerms: `${x}/accounting/payment-terms`,- people: `${x}/resources/people`,+ people: `${x}/people/people`,person: (id: string) => generatePath(`${x}/person/${id}`),personDetails: (id: string) => generatePath(`${x}/person/${id}/details`),personJob: (id: string) => generatePath(`${x}/person/${id}/job`),@@ -656,8 +655,8 @@ export const path = {generatePath(`${x}/service/${id}/suppliers`),settings: `${x}/settings`,sequences: `${x}/settings/sequences`,- shift: (id: string) => generatePath(`${x}/resources/shifts/${id}`),- shifts: `${x}/resources/shifts`,+ shift: (id: string) => generatePath(`${x}/people/shifts/${id}`),+ shifts: `${x}/people/shifts`,shipments: `${x}/inventory/shipments`,shippingMethod: (id: string) =>generatePath(`${x}/inventory/shipping-methods/${id}`),diff --git a/packages/database/src/types.ts b/packages/database/src/types.tsindex 42ef3cfa58..d89a465b6d 100644--- a/packages/database/src/types.ts+++ b/packages/database/src/types.ts@@ -26388,6 +26388,7 @@ export type Database = {| "Parts"| "Purchasing"| "Resources"+ | "People"| "Sales"| "Settings"| "Scheduling"diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.tsindex 42ef3cfa58..d89a465b6d 100644--- a/packages/database/supabase/functions/lib/types.ts+++ b/packages/database/supabase/functions/lib/types.ts@@ -26388,6 +26388,7 @@ export type Database = {| "Parts"| "Purchasing"| "Resources"+ | "People"| "Sales"| "Settings"| "Scheduling"diff --git a/packages/database/supabase/migrations/20240817021131_people-vs-resources.sql b/packages/database/supabase/migrations/20240817021131_people-vs-resources.sqlnew file mode 100644index 0000000000..4348a610eb--- /dev/null+++ b/packages/database/supabase/migrations/20240817021131_people-vs-resources.sql@@ -0,0 +1,136 @@+ALTER TYPE "module" ADD VALUE 'People' AFTER 'Resources';++++DROP POLICY "Employees with resources_create can insert employee jobs" ON "employeeJob";+CREATE POLICY "Employees with people_create can insert employee jobs" ON "employeeJob"+ FOR INSERT+ WITH CHECK (+ has_role('employee', "companyId") AND+ has_company_permission('people_create', "companyId")+);++DROP POLICY "Employees with resources_update can update employee jobs" ON "employeeJob";+CREATE POLICY "Employees with people_update can update employee jobs" ON "employeeJob"+ FOR UPDATE+ USING (+ has_role('employee', "companyId") AND+ has_company_permission('people_update', "companyId")+ );++DROP POLICY "Employees with resources_delete can delete employee jobs" ON "employeeJob";+CREATE POLICY "Employees with people_delete can delete employee jobs" ON "employeeJob"+ FOR DELETE+ USING (+ has_role('employee', "companyId") AND+ has_company_permission('people_delete', "companyId")+ );++DROP POLICY "Employees can view employee shifts" ON "employeeShift";+CREATE POLICY "Employees with people_view can view employee shifts" ON "employeeShift"+ FOR SELECT+ USING (+ has_role('employee', get_company_id_from_foreign_key("employeeId", 'employee')) AND+ has_company_permission('people_view', get_company_id_from_foreign_key("employeeId", 'employee'))+ );++DROP POLICY "Employees with resources_create can insert employee shifts" ON "employeeShift";+CREATE POLICY "Employees with people_create can insert employee shifts" ON "employeeShift"+ FOR INSERT+ WITH CHECK (+ has_role('employee', get_company_id_from_foreign_key("employeeId", 'employee')) AND+ has_company_permission('people_create', get_company_id_from_foreign_key("employeeId", 'employee'))+);++DROP POLICY "Employees with resources_update can update employee shifts" ON "employeeShift";+CREATE POLICY "Employees with people_update can update employee shifts" ON "employeeShift"+ FOR UPDATE+ USING (+ has_role('employee', get_company_id_from_foreign_key("employeeId", 'employee')) AND+ has_company_permission('people_update', get_company_id_from_foreign_key("employeeId", 'employee'))+ );++DROP POLICY "Employees with resources_delete can delete employee shifts" ON "employeeShift";+CREATE POLICY "Employees with people_delete can delete employee shifts" ON "employeeShift"+ FOR DELETE+ USING (+ has_role('employee', get_company_id_from_foreign_key("employeeId", 'employee')) AND+ has_company_permission('people_delete', get_company_id_from_foreign_key("employeeId", 'employee'))+ );+++DROP POLICY "Users can view other users attributes if the category is public" ON "userAttributeValue";+++DROP POLICY "Employees with resources_create can insert departments" ON "department";+CREATE POLICY "Employees with people_create can insert departments" ON "department"+ FOR INSERT+ WITH CHECK (+ has_role('employee', "companyId") AND+ has_company_permission('people_create', "companyId")+);++DROP POLICY "Employees with resources_update can update departments" ON "department";+CREATE POLICY "Employees with people_update can update departments" ON "department"+ FOR UPDATE+ USING (+ has_role('employee', "companyId") AND+ has_company_permission('people_update', "companyId")+ );++DROP POLICY "Employees with resources_delete can delete departments" ON "department";+CREATE POLICY "Employees with people_delete can delete departments" ON "department"+ FOR DELETE+ USING (+ has_role('employee', "companyId") AND+ has_company_permission('people_delete', "companyId")+ );++DROP POLICY "Employees with resources_create can insert shifts" ON "shift";+CREATE POLICY "Employees with people_create can insert shifts" ON "shift"+ FOR INSERT+ WITH CHECK (+ has_role('employee', "companyId") AND+ has_company_permission('people_create', "companyId")+);++DROP POLICY "Employees with resources_update can update shifts" ON "shift";+CREATE POLICY "Employees with people_update can update shifts" ON "shift"+ FOR UPDATE+ USING (+ has_role('employee', "companyId") AND+ has_company_permission('people_update', "companyId")+ );++DROP POLICY "Employees with resources_delete can delete shifts" ON "shift";+CREATE POLICY "Employees with people_delete can delete shifts" ON "shift"+ FOR DELETE+ USING (+ has_role('employee', "companyId") AND+ has_company_permission('people_delete', "companyId")+ );+++DROP POLICY "Employees with resources_create can insert holidays" ON "holiday";+CREATE POLICY "Employees with people_create can insert holidays" ON "holiday"+ FOR INSERT+ WITH CHECK (+ has_role('employee', "companyId") AND+ has_company_permission('people_create', "companyId")+);++DROP POLICY "Employees with resources_update can update holidays" ON "holiday";+CREATE POLICY "Employees with people_update can update holidays" ON "holiday"+ FOR UPDATE+ USING (+ has_role('employee', "companyId") AND+ has_company_permission('people_update', "companyId")+ );++DROP POLICY "Employees with resources_delete can delete holidays" ON "holiday";+CREATE POLICY "Employees with people_delete can delete holidays" ON "holiday"+ FOR DELETE+ USING (+ has_role('employee', "companyId") AND+ has_company_permission('people_delete', "companyId")+ );