Skip to content

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

feat: add assignee to sidebar

Brad Barbin8b1871ab7503
diff --git a/apps/carbon/app/components/Assignee.tsx b/apps/carbon/app/components/Assignee.tsx
index 2a5022676b..a1dc096ba1 100644
--- a/apps/carbon/app/components/Assignee.tsx
+++ b/apps/carbon/app/components/Assignee.tsx
@@ -4,21 +4,26 @@ import {
CommandGroup,
CommandInput,
CommandItem,
+ HStack,
+ IconButton,
Popover,
PopoverContent,
PopoverTrigger,
+ VStack,
cn,
} from "@carbon/react";
import { useFetcher, useFetchers } from "@remix-run/react";
import type { ComponentPropsWithoutRef } from "react";
import { forwardRef, useMemo, useState } from "react";
-import { LuUser } from "react-icons/lu";
+import { LuSettings2, LuUser } from "react-icons/lu";
import { RxCheck } from "react-icons/rx";
import { useUser } from "~/hooks";
import { usePeople } from "~/stores";
import { path } from "~/utils/path";
import EmployeeAvatar from "./EmployeeAvatar";
+type AssigneeVariants = "button" | "inline";
+
export type AssigneeProps = Omit<
ComponentPropsWithoutRef<"button">,
"onChange"
@@ -29,6 +34,7 @@ export type AssigneeProps = Omit<
value?: string;
isReadOnly?: boolean;
placeholder?: string;
+ variant?: AssigneeVariants;
onChange?: (selected: string) => void;
};
@@ -41,6 +47,7 @@ const Assign = forwardRef<HTMLButtonElement, AssigneeProps>(
value,
isReadOnly,
placeholder,
+ variant = "button",
onChange,
className,
...props
@@ -81,65 +88,94 @@ const Assign = forwardRef<HTMLButtonElement, AssigneeProps>(
}, [people, user]);
return (
- <Popover open={open} onOpenChange={setOpen}>
- <PopoverTrigger asChild>
- <button
- className={cn(
- "rounded-md px-2.5 py-0.5 text-sm transition-colors cursor-pointer hover:bg-accent hover:text-accent-foreground border border-input bg-card font-normal",
- className
- )}
- role="combobox"
- aria-expanded={open}
- aria-controls="assignee-options"
- ref={ref}
- onClick={() => setOpen(true)}
- disabled={isReadOnly}
- {...props}
- >
- {value ? (
+ <VStack spacing={2}>
+ {variant === "inline" && (
+ <span className="text-xs text-muted-foreground">Assignee</span>
+ )}
+ <HStack className="w-full justify-between">
+ {variant === "inline" &&
+ (value ? (
<EmployeeAvatar size={size ?? "xs"} employeeId={value ?? null} />
) : (
- <div className="flex items-center justify-start gap-2">
- <LuUser className="w-4 h-4" />
- <span className="text-sm">Unassigned</span>
- </div>
- )}
- </button>
- </PopoverTrigger>
- <PopoverContent
- align="start"
- className="min-w-[260px] w-[--radix-popover-trigger-width] p-0"
- >
- <Command id="assignee-options">
- <CommandInput placeholder="Search..." className="h-9" />
- <CommandEmpty>No option found.</CommandEmpty>
- <CommandGroup>
- {options.map((option) => (
- <CommandItem
- value={
- typeof option.label === "string" ? option.label : undefined
- }
- key={option.value}
- onSelect={() => {
- handleChange(option.value);
- onChange?.(option.value);
- setOpen(false);
- }}
+ <span className="text-sm">Unassigned</span>
+ ))}
+
+ <Popover open={open} onOpenChange={setOpen}>
+ <PopoverTrigger asChild>
+ {variant === "button" ? (
+ <button
+ className={cn(
+ "rounded-md px-2.5 py-0.5 text-sm transition-colors cursor-pointer hover:bg-accent hover:text-accent-foreground border border-input bg-card font-normal",
+
+ className
+ )}
+ role="combobox"
+ aria-expanded={open}
+ aria-controls="assignee-options"
+ ref={ref}
+ onClick={() => setOpen(true)}
+ disabled={isReadOnly}
+ {...props}
>
- {option.label}
+ {value ? (
+ <EmployeeAvatar
+ size={size ?? "xs"}
+ employeeId={value ?? null}
+ />
+ ) : (
+ <div className="flex items-center justify-start gap-2">
+ <LuUser className="w-4 h-4" />
+ <span className="text-sm">Unassigned</span>
+ </div>
+ )}
+ </button>
+ ) : (
+ <IconButton
+ aria-label="Toggle Assignee"
+ icon={<LuSettings2 />}
+ size="sm"
+ variant="secondary"
+ />
+ )}
+ </PopoverTrigger>
+ <PopoverContent
+ align="start"
+ className="min-w-[260px] w-[--radix-popover-trigger-width] p-0"
+ >
+ <Command id="assignee-options">
+ <CommandInput placeholder="Search..." className="h-9" />
+ <CommandEmpty>No option found.</CommandEmpty>
+ <CommandGroup>
+ {options.map((option) => (
+ <CommandItem
+ value={
+ typeof option.label === "string"
+ ? option.label
+ : undefined
+ }
+ key={option.value}
+ onSelect={() => {
+ handleChange(option.value);
+ onChange?.(option.value);
+ setOpen(false);
+ }}
+ >
+ {option.label}
- <RxCheck
- className={cn(
- "ml-auto h-4 w-4",
- option.value === value ? "opacity-100" : "opacity-0"
- )}
- />
- </CommandItem>
- ))}
- </CommandGroup>
- </Command>
- </PopoverContent>
- </Popover>
+ <RxCheck
+ className={cn(
+ "ml-auto h-4 w-4",
+ option.value === value ? "opacity-100" : "opacity-0"
+ )}
+ />
+ </CommandItem>
+ ))}
+ </CommandGroup>
+ </Command>
+ </PopoverContent>
+ </Popover>
+ </HStack>
+ </VStack>
);
}
);
diff --git a/apps/carbon/app/modules/production/ui/Jobs/JobHeader.tsx b/apps/carbon/app/modules/production/ui/Jobs/JobHeader.tsx
index bc21dfca05..3f13bf52dc 100644
--- a/apps/carbon/app/modules/production/ui/Jobs/JobHeader.tsx
+++ b/apps/carbon/app/modules/production/ui/Jobs/JobHeader.tsx
@@ -36,7 +36,6 @@ import {
LuTable,
} from "react-icons/lu";
import { RiProgress8Line } from "react-icons/ri";
-import { Assignee, useOptimisticAssignment } from "~/components";
import { useOptimisticLocation, usePermissions, useRouteData } from "~/hooks";
import { path } from "~/utils/path";
import type { Job } from "../../types";
@@ -54,14 +53,6 @@ const JobHeader = () => {
const cancelModal = useDisclosure();
const routeData = useRouteData<{ job: Job }>(path.to.job(jobId));
- const optimisticAssignment = useOptimisticAssignment({
- id: jobId,
- table: "job",
- });
- const assignee =
- optimisticAssignment !== undefined
- ? optimisticAssignment
- : routeData?.job?.assignee;
const statusFetcher = useFetcher<{}>();
const status = routeData?.job?.status;
@@ -92,14 +83,6 @@ const JobHeader = () => {
<JobStatus status={routeData?.job?.status} />
</HStack>
<HStack>
- <Assignee
- id={jobId}
- table="job"
- value={assignee ?? ""}
- className="h-8"
- isReadOnly={!permissions.can("update", "production")}
- />
-
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
diff --git a/apps/carbon/app/modules/production/ui/Jobs/JobProperties.tsx b/apps/carbon/app/modules/production/ui/Jobs/JobProperties.tsx
index c9b52be9a9..cb0f13550c 100644
--- a/apps/carbon/app/modules/production/ui/Jobs/JobProperties.tsx
+++ b/apps/carbon/app/modules/production/ui/Jobs/JobProperties.tsx
@@ -10,17 +10,25 @@ import {
import { useFetcher, useParams } from "@remix-run/react";
import { useCallback, useEffect, useState } from "react";
import { LuCopy, LuLink } from "react-icons/lu";
-import { useRouteData } from "~/hooks";
+import { usePermissions, useRouteData } from "~/hooks";
import type { action } from "~/routes/x+/items+/update";
-import { DatePicker, NumberControlled, ValidatedForm } from "@carbon/form";
+import {
+ DatePicker,
+ NumberControlled,
+ Select,
+ ValidatedForm,
+} from "@carbon/form";
import { z } from "zod";
import { zfd } from "zod-form-data";
+import { Assignee, useOptimisticAssignment } from "~/components";
import { Customer, Item, Location, UnitOfMeasure } from "~/components/Form";
import type { MethodItemType } from "~/modules/shared";
import { path } from "~/utils/path";
import { copyToClipboard } from "~/utils/string";
+import { deadlineTypes } from "../../production.models";
import type { Job } from "../../types";
+import { getDeadlineIcon, getDeadlineText } from "./Deadline";
const JobProperties = () => {
const { jobId } = useParams();
@@ -59,6 +67,16 @@ const JobProperties = () => {
[fetcher, jobId, routeData?.job]
);
+ const permissions = usePermissions();
+ const optimisticAssignment = useOptimisticAssignment({
+ id: jobId,
+ table: "job",
+ });
+ const assignee =
+ optimisticAssignment !== undefined
+ ? optimisticAssignment
+ : routeData?.job?.assignee;
+
return (
<VStack
spacing={4}
@@ -109,6 +127,14 @@ const JobProperties = () => {
<span className="text-sm">{routeData?.job?.jobId}</span>
</VStack>
+ <Assignee
+ id={jobId}
+ table="job"
+ value={assignee ?? ""}
+ variant="inline"
+ isReadOnly={!permissions.can("update", "production")}
+ />
+
<ValidatedForm
defaultValues={{ itemId: routeData?.job?.itemId ?? undefined }}
validator={z.object({
@@ -167,78 +193,112 @@ const JobProperties = () => {
}}
/>
</ValidatedForm>
+
<ValidatedForm
defaultValues={{
- unitOfMeasureCode: routeData?.job?.unitOfMeasureCode ?? undefined,
+ dueDate: routeData?.job?.dueDate ?? "",
}}
validator={z.object({
- unitOfMeasureCode: z
- .string()
- .min(1, { message: "Unit of Measure is required" }),
+ dueDate: zfd.text(z.string().optional()),
})}
className="w-full"
>
- <UnitOfMeasure
- label="Unit of Measure"
- name="unitOfMeasureCode"
+ <DatePicker
+ name="dueDate"
+ label="Due Date"
inline
+ onChange={(date) => {
+ onUpdate("dueDate", date);
+ }}
+ />
+ </ValidatedForm>
+
+ <ValidatedForm
+ defaultValues={{
+ deadlineType: routeData?.job?.deadlineType ?? "",
+ }}
+ validator={z.object({
+ deadlineType: z
+ .string()
+ .min(1, { message: "Deadline Type is required" }),
+ })}
+ className="w-full"
+ >
+ <Select
+ name="deadlineType"
+ label="Deadline Type"
+ inline={(value, options) => {
+ const deadlineType = value as (typeof deadlineTypes)[number];
+ return (
+ <div className="flex gap-1 items-center">
+ {getDeadlineIcon(deadlineType, false)}
+ <span>{getDeadlineText(deadlineType)}</span>
+ </div>
+ );
+ }}
+ options={deadlineTypes.map((d) => ({
+ value: d,
+ label: d,
+ }))}
onChange={(value) => {
- onUpdate("unitOfMeasureCode", value?.value ?? null);
+ onUpdate("deadlineType", value?.value ?? null);
}}
/>
</ValidatedForm>
<ValidatedForm
- defaultValues={{ locationId: routeData?.job?.locationId ?? undefined }}
+ defaultValues={{ customerId: routeData?.job?.customerId ?? undefined }}
validator={z.object({
- locationId: z.string().min(1, { message: "Location is required" }),
+ customerId: zfd.text(z.string().optional()),
})}
className="w-full"
>
- <Location
- label="Job Location"
- name="locationId"
+ <Customer
+ name="customerId"
inline
+ isOptional
onChange={(value) => {
- if (value?.value) {
- onUpdate("locationId", value.value);
- }
+ onUpdate("customerId", value?.value ?? null);
}}
/>
</ValidatedForm>
<ValidatedForm
defaultValues={{
- dueDate: routeData?.job?.dueDate ?? "",
+ unitOfMeasureCode: routeData?.job?.unitOfMeasureCode ?? undefined,
}}
validator={z.object({
- dueDate: zfd.text(z.string().optional()),
+ unitOfMeasureCode: z
+ .string()
+ .min(1, { message: "Unit of Measure is required" }),
})}
className="w-full"
>
- <DatePicker
- name="dueDate"
- label="Due Date"
+ <UnitOfMeasure
+ label="Unit of Measure"
+ name="unitOfMeasureCode"
inline
- onChange={(date) => {
- onUpdate("dueDate", date);
+ onChange={(value) => {
+ onUpdate("unitOfMeasureCode", value?.value ?? null);
}}
/>
</ValidatedForm>
<ValidatedForm
- defaultValues={{ customerId: routeData?.job?.customerId ?? undefined }}
+ defaultValues={{ locationId: routeData?.job?.locationId ?? undefined }}
validator={z.object({
- customerId: zfd.text(z.string().optional()),
+ locationId: z.string().min(1, { message: "Location is required" }),
})}
className="w-full"
>
- <Customer
- name="customerId"
+ <Location
+ label="Job Location"
+ name="locationId"
inline
- isOptional
onChange={(value) => {
- onUpdate("customerId", value?.value ?? null);
+ if (value?.value) {
+ onUpdate("locationId", value.value);
+ }
}}
/>
</ValidatedForm>
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsx
index dca61585c6..c3f6d86744 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsx
@@ -33,7 +33,7 @@ import {
LuTrophy,
LuXCircle,
} from "react-icons/lu";
-import { Assignee, Copy, useOptimisticAssignment } from "~/components";
+import { Copy } from "~/components";
import { usePermissions, useRouteData } from "~/hooks";
import type { Quotation, QuotationLine, QuotationPrice } from "~/modules/sales";
@@ -61,15 +61,6 @@ const QuoteHeader = () => {
const convertToOrderModal = useDisclosure();
const shareModal = useDisclosure();
- const optimisticAssignment = useOptimisticAssignment({
- id: quoteId,
- table: "quote",
- });
- const assignee =
- optimisticAssignment !== undefined
- ? optimisticAssignment
- : routeData?.quote?.assignee;
-
const finalizeFetcher = useFetcher<{}>();
const statusFetcher = useFetcher<{}>();
@@ -86,13 +77,6 @@ const QuoteHeader = () => {
<QuoteStatus status={routeData?.quote?.status} />
</HStack>
<HStack>
- <Assignee
- id={quoteId}
- table="quote"
- value={assignee ?? ""}
- className="h-8"
- isReadOnly={!permissions.can("update", "sales")}
- />
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteProperties.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteProperties.tsx
index 178c31132a..3f8a133268 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteProperties.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteProperties.tsx
@@ -15,6 +15,7 @@ import { useCallback, useEffect, useMemo } from "react";
import { LuCopy, LuInfo, LuLink, LuRefreshCcw } from "react-icons/lu";
import { z } from "zod";
import { zfd } from "zod-form-data";
+import { Assignee, useOptimisticAssignment } from "~/components";
import {
Currency,
Customer,
@@ -23,7 +24,7 @@ import {
Employee,
Location,
} from "~/components/Form";
-import { useRouteData, useUser } from "~/hooks";
+import { usePermissions, useRouteData, useUser } from "~/hooks";
import type { action } from "~/routes/x+/items+/update";
import type { action as exchangeRateAction } from "~/routes/x+/quote+/$quoteId.exchange-rate";
import { path } from "~/utils/path";
@@ -75,6 +76,16 @@ const QuoteProperties = () => {
[fetcher, quoteId, routeData?.quote]
);
+ const optimisticAssignment = useOptimisticAssignment({
+ id: quoteId,
+ table: "quote",
+ });
+ const assignee =
+ optimisticAssignment !== undefined
+ ? optimisticAssignment
+ : routeData?.quote?.assignee;
+ const permissions = usePermissions();
+
return (
<VStack
spacing={4}
@@ -124,7 +135,13 @@ const QuoteProperties = () => {
</HStack>
<span className="text-sm">{routeData?.quote?.quoteId}</span>
</VStack>
-
+ <Assignee
+ id={quoteId}
+ table="quote"
+ value={assignee ?? ""}
+ variant="inline"
+ isReadOnly={!permissions.can("update", "sales")}
+ />
<ValidatedForm
defaultValues={{ customerId: routeData?.quote?.customerId }}
validator={z.object({
diff --git a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx
index 7e2f7c9816..ba56f1492c 100644
--- a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx
@@ -9,7 +9,6 @@ import {
LuStopCircle,
LuTruck,
} from "react-icons/lu";
-import { Assignee, useOptimisticAssignment } from "~/components";
import { usePermissions, useRouteData } from "~/hooks";
import type { SalesOrder, SalesOrderLine } from "~/modules/sales";
@@ -18,7 +17,6 @@ import { path } from "~/utils/path";
import SalesStatus from "./SalesStatus";
const SalesOrderHeader = () => {
- const permissions = usePermissions();
const { orderId } = useParams();
if (!orderId) throw new Error("orderId not found");
@@ -27,14 +25,7 @@ const SalesOrderHeader = () => {
lines: SalesOrderLine[];
}>(path.to.salesOrder(orderId));
- const optimisticAssignment = useOptimisticAssignment({
- id: orderId,
- table: "salesOrder",
- });
- const assignee =
- optimisticAssignment !== undefined
- ? optimisticAssignment
- : routeData?.salesOrder?.assignee;
+ const permissions = usePermissions();
const statusFetcher = useFetcher<{}>();
@@ -51,13 +42,6 @@ const SalesOrderHeader = () => {
<SalesStatus status={routeData?.salesOrder?.status} />
</HStack>
<HStack>
- <Assignee
- id={orderId}
- table="salesOrder"
- value={assignee ?? ""}
- className="h-8"
- isReadOnly={!permissions.can("update", "sales")}
- />
<Button leftIcon={<LuEye />} variant="secondary" asChild>
<a
target="_blank"
diff --git a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderProperties.tsx b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderProperties.tsx
index f1397f2209..48da459d9c 100644
--- a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderProperties.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderProperties.tsx
@@ -15,6 +15,7 @@ import { useCallback, useEffect, useMemo } from "react";
import { LuCopy, LuInfo, LuLink, LuRefreshCcw } from "react-icons/lu";
import { z } from "zod";
import { zfd } from "zod-form-data";
+import { Assignee, useOptimisticAssignment } from "~/components";
import {
Currency,
Customer,
@@ -23,7 +24,7 @@ import {
Employee,
Location,
} from "~/components/Form";
-import { useRouteData, useUser } from "~/hooks";
+import { usePermissions, useRouteData, useUser } from "~/hooks";
import type { action } from "~/routes/x+/items+/update";
import type { action as exchangeRateAction } from "~/routes/x+/sales-order+/$orderId.exchange-rate";
import { path } from "~/utils/path";
@@ -77,6 +78,16 @@ const SalesOrderProperties = () => {
[fetcher, orderId, routeData?.salesOrder]
);
+ const permissions = usePermissions();
+ const optimisticAssignment = useOptimisticAssignment({
+ id: orderId,
+ table: "salesOrder",
+ });
+ const assignee =
+ optimisticAssignment !== undefined
+ ? optimisticAssignment
+ : routeData?.salesOrder?.assignee;
+
return (
<VStack
spacing={4}
@@ -130,6 +141,14 @@ const SalesOrderProperties = () => {
<span className="text-sm">{routeData?.salesOrder?.salesOrderId}</span>
</VStack>
+ <Assignee
+ id={orderId}
+ table="salesOrder"
+ value={assignee ?? ""}
+ variant="inline"
+ isReadOnly={!permissions.can("update", "sales")}
+ />
+
<ValidatedForm
defaultValues={{ customerId: routeData?.salesOrder?.customerId }}
validator={z.object({
diff --git a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQHeader.tsx b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQHeader.tsx
index 9f8046e14c..21413dac3a 100644
--- a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQHeader.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQHeader.tsx
@@ -19,7 +19,6 @@ import { Link, useFetcher, useParams } from "@remix-run/react";
import { useEffect } from "react";
import { LuAlertTriangle, LuRefreshCw, LuXCircle } from "react-icons/lu";
import { RiProgress4Line } from "react-icons/ri";
-import { Assignee, useOptimisticAssignment } from "~/components";
import { usePermissions, useRouteData } from "~/hooks";
import type { SalesRFQ, SalesRFQLine } from "~/modules/sales";
import { path } from "~/utils/path";
@@ -39,15 +38,6 @@ const SalesRFQHeader = () => {
lines: SalesRFQLine[];
}>(path.to.salesRfq(rfqId));
- const optimisticAssignment = useOptimisticAssignment({
- id: rfqId,
- table: "salesRfq",
- });
- const assignee =
- optimisticAssignment !== undefined
- ? optimisticAssignment
- : routeData?.rfqSummary?.assignee;
-
const status = routeData?.rfqSummary?.status ?? "Draft";
const statusFetcher = useFetcher<{}>();
@@ -65,14 +55,6 @@ const SalesRFQHeader = () => {
<SalesRFQStatus status={routeData?.rfqSummary?.status} />
</HStack>
<HStack>
- <Assignee
- id={rfqId}
- table="salesRfq"
- value={assignee ?? ""}
- className="h-8"
- isReadOnly={!permissions.can("update", "sales")}
- />
-
{status === "Draft" &&
(routeData?.rfqSummary?.customerId ? (
<statusFetcher.Form
diff --git a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQProperties.tsx b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQProperties.tsx
index da0ce1cf2f..79b854bc91 100644
--- a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQProperties.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQProperties.tsx
@@ -13,6 +13,7 @@ import { useCallback, useEffect } from "react";
import { LuCopy, LuLink } from "react-icons/lu";
import { z } from "zod";
import { zfd } from "zod-form-data";
+import { Assignee, useOptimisticAssignment } from "~/components";
import {
Customer,
CustomerContact,
@@ -20,7 +21,7 @@ import {
Employee,
Location,
} from "~/components/Form";
-import { useRouteData } from "~/hooks";
+import { usePermissions, useRouteData } from "~/hooks";
import type { action } from "~/routes/x+/items+/update";
import { path } from "~/utils/path";
import { copyToClipboard } from "~/utils/string";
@@ -59,6 +60,16 @@ const SalesRFQProperties = () => {
[fetcher, rfqId, routeData?.rfqSummary]
);
+ const optimisticAssignment = useOptimisticAssignment({
+ id: rfqId,
+ table: "salesRfq",
+ });
+ const assignee =
+ optimisticAssignment !== undefined
+ ? optimisticAssignment
+ : routeData?.rfqSummary?.assignee;
+ const permissions = usePermissions();
+
return (
<VStack
spacing={4}
@@ -111,6 +122,14 @@ const SalesRFQProperties = () => {
<span className="text-sm">{routeData?.rfqSummary?.rfqId}</span>
</VStack>
+ <Assignee
+ id={rfqId}
+ table="salesRfq"
+ value={assignee ?? ""}
+ variant="inline"
+ isReadOnly={!permissions.can("update", "sales")}
+ />
+
<ValidatedForm
defaultValues={{ customerId: routeData?.rfqSummary?.customerId }}
validator={z.object({
diff --git a/apps/carbon/app/routes/x+/job+/$jobId.details.tsx b/apps/carbon/app/routes/x+/job+/$jobId.details.tsx
index a626ab1fb3..a87a79d6b0 100644
--- a/apps/carbon/app/routes/x+/job+/$jobId.details.tsx
+++ b/apps/carbon/app/routes/x+/job+/$jobId.details.tsx
@@ -16,14 +16,12 @@ import { CadModel, Documents } from "~/components";
import { usePermissions, useRealtime, useRouteData } from "~/hooks";
import type { Job } from "~/modules/production";
import {
- JobForm,
jobValidator,
recalculateJobRequirements,
upsertJob,
} from "~/modules/production";
-import JobMakeMethodTools from "~/modules/production/ui/Jobs/JobMakeMethodTools";
import type { StorageItem } from "~/types";
-import { getCustomFields, setCustomFields } from "~/utils/form";
+import { setCustomFields } from "~/utils/form";
import { path } from "~/utils/path";
export async function action({ request, params }: ActionFunctionArgs) {
@@ -91,28 +89,8 @@ export default function JobDetailsRoute() {
useRealtime("modelUpload", `modelPath=eq.(${jobData?.job.modelPath})`);
- const jobInitialValues = {
- id: jobData.job?.id ?? "",
- jobId: jobData.job?.jobId ?? "",
- customerId: jobData.job?.customerId ?? "",
- deadlineType: jobData.job?.deadlineType ?? ("No Deadline" as "No Deadline"),
- description: jobData.job?.description ?? "",
- dueDate: jobData.job?.dueDate ?? "",
- itemId: jobData.job?.itemId ?? "",
- itemType: jobData.job?.itemType ?? ("Part" as const),
- locationId: jobData.job?.locationId ?? "",
- quantity: jobData.job?.quantity ?? 0,
- scrapQuantity: jobData.job?.scrapQuantity ?? 0,
- status: jobData.job?.status ?? ("Draft" as const),
- unitOfMeasureCode: jobData.job?.unitOfMeasureCode ?? "EA",
- ...getCustomFields(jobData.job?.customFields ?? {}),
- };
-
return (
<VStack spacing={2} className="p-2 h-full">
- <JobMakeMethodTools />
- {/* @ts-ignore */}
- <JobForm key={jobInitialValues.id} initialValues={jobInitialValues} />
{permissions.is("employee") && (
<div className="grid grid-cols-1 md:grid-cols-2 w-full flex-grow gap-2">
<CadModel
diff --git a/packages/form/src/components/Select.tsx b/packages/form/src/components/Select.tsx
index 37308e6124..fe938d6e5f 100644
--- a/packages/form/src/components/Select.tsx
+++ b/packages/form/src/components/Select.tsx
@@ -1,5 +1,6 @@
import {
Select as CarbonSelect,
+ cn,
FormControl,
FormErrorMessage,
FormHelperText,
@@ -15,7 +16,7 @@ import {
import type { ComponentPropsWithoutRef } from "react";
import { forwardRef } from "react";
-import { LuX } from "react-icons/lu";
+import { LuPlus, LuSettings2, LuX } from "react-icons/lu";
import { useControlField, useField } from "../hooks";
export type SelectProps = Omit<SelectBaseProps, "onChange"> & {
@@ -38,7 +39,6 @@ const Select = ({
helperText,
isOptional = false,
isLoading,
- inline,
options,
...props
}: SelectProps) => {
@@ -53,8 +53,6 @@ const Select = ({
}
};
- const inlinePreview = !!inline;
-
return (
<FormControl isInvalid={!!error} className={props.className}>
{label && (
@@ -112,6 +110,10 @@ export type SelectBaseProps = Omit<
isLoading?: boolean;
isReadOnly?: boolean;
placeholder?: string;
+ inline?: (
+ value: string,
+ options: { value: string; label: string | JSX.Element }[]
+ ) => JSX.Element;
onChange: (selected: string) => void;
};
@@ -125,13 +127,22 @@ export const SelectBase = forwardRef<HTMLButtonElement, SelectBaseProps>(
isLoading,
isReadOnly,
placeholder,
+ inline,
onChange,
...props
},
ref
) => {
+ const isInlinePreview = !!inline;
+
return (
<HStack spacing={1}>
+ {isInlinePreview && value && (
+ <span className="flex-grow line-clamp-1">
+ {inline(value, options)}
+ </span>
+ )}
+
<CarbonSelect
value={value}
onValueChange={(value) => onChange(value)}
@@ -140,15 +151,26 @@ export const SelectBase = forwardRef<HTMLButtonElement, SelectBaseProps>(
<SelectTrigger
ref={ref}
size={size}
- // isReadOnly={isReadOnly}
{...props}
- className="min-w-[160px] relative"
+ className={cn(!isInlinePreview && "min-w-[160px] relative")}
+ inline={isInlinePreview}
hideIcon={isLoading}
>
- <SelectValue placeholder={placeholder} />
- {isLoading && (
- <div className="absolute top-3 right-2">
- <Spinner />
+ {isInlinePreview ? (
+ <IconButton
+ size={size ?? "sm"}
+ variant="secondary"
+ aria-label={value ? "Edit" : "Add"}
+ icon={value ? <LuSettings2 /> : <LuPlus />}
+ />
+ ) : (
+ <div>
+ <SelectValue placeholder={placeholder} />
+ {isLoading && (
+ <div className="absolute top-3 right-2">
+ <Spinner />
+ </div>
+ )}
</div>
)}
</SelectTrigger>
diff --git a/packages/react/src/Select.tsx b/packages/react/src/Select.tsx
index 00f52de1ef..80df7f859b 100644
--- a/packages/react/src/Select.tsx
+++ b/packages/react/src/Select.tsx
@@ -40,24 +40,26 @@ interface SelectTriggerProps
extends ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>,
VariantProps<typeof selectTriggerVariants> {
hideIcon?: boolean;
+ inline?: boolean;
}
const SelectTrigger = forwardRef<
ElementRef<typeof SelectPrimitive.Trigger>,
SelectTriggerProps
->(({ size, className, children, hideIcon, ...props }, ref) => (
+>(({ size, className, children, hideIcon, inline, ...props }, ref) => (
<SelectPrimitive.Trigger
ref={ref}
className={cn(
- selectTriggerVariants({
- size,
- }),
+ !inline &&
+ selectTriggerVariants({
+ size,
+ }),
className
)}
{...props}
>
{children}
- {!hideIcon && (
+ {!hideIcon && !inline && (
<SelectPrimitive.Icon asChild>
<LuChevronsUpDown className="h-4 w-4 opacity-50" />
</SelectPrimitive.Icon>