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: quote lines

Brad Barbinaad591fb0fdc
diff --git a/apps/carbon/app/components/Editable/EditableQuotationPart.tsx b/apps/carbon/app/components/Editable/EditableQuotationPart.tsx
new file mode 100644
index 0000000000..8e699d9675
--- /dev/null
+++ b/apps/carbon/app/components/Editable/EditableQuotationPart.tsx
@@ -0,0 +1,90 @@
+/* eslint-disable react/display-name */
+import type { Database } from "@carbon/database";
+import type {
+ PostgrestSingleResponse,
+ SupabaseClient,
+} from "@supabase/supabase-js";
+import { Combobox } from "~/components";
+import type { EditableTableCellComponentProps } from "~/components/Editable";
+import type { QuotationLine } from "~/modules/sales";
+
+const EditableQuotationPart =
+ (
+ mutation: (
+ accessorKey: string,
+ newValue: string,
+ row: QuotationLine
+ ) => Promise<PostgrestSingleResponse<unknown>>,
+ options: {
+ client?: SupabaseClient<Database>;
+ parts: { label: string; value: string }[];
+ userId: string;
+ }
+ ) =>
+ ({
+ value,
+ row,
+ accessorKey,
+ onError,
+ onUpdate,
+ }: EditableTableCellComponentProps<QuotationLine>) => {
+ const { client, parts, userId } = options;
+
+ const onPartChange = async (partId: string) => {
+ if (!client) throw new Error("Supabase client not found");
+ const [part, cost] = await Promise.all([
+ client
+ .from("part")
+ .select("name, unitOfMeasureCode")
+ .eq("id", partId)
+ .single(),
+ client
+ .from("partCost")
+ .select("unitCost")
+ .eq("partId", partId)
+ .single(),
+ ]);
+
+ if (part.error) {
+ onError();
+ return;
+ }
+
+ onUpdate({
+ partId: partId,
+ description: part.data?.name,
+ });
+
+ try {
+ const { error } = await client
+ .from("quoteLine")
+ .update({
+ partId: partId,
+ description: part.data?.name,
+ unitCost: cost.data?.unitCost,
+ unitPrice: cost.data?.unitCost,
+ updatedBy: userId,
+ })
+ .eq("id", row.id!);
+
+ if (error) onError();
+ } catch (error) {
+ console.error(error);
+ onError();
+ }
+ };
+
+ return (
+ <Combobox
+ autoFocus
+ value={row?.partId ?? ""}
+ options={parts}
+ onChange={onPartChange}
+ size="sm"
+ className="border-0 rounded-none w-full"
+ />
+ );
+ };
+
+EditableQuotationPart.displayName = "EditableQuotationPart";
+export default EditableQuotationPart;
diff --git a/apps/carbon/app/components/Editable/index.ts b/apps/carbon/app/components/Editable/index.ts
index 3af30890b1..f6e3f2b7e9 100644
--- a/apps/carbon/app/components/Editable/index.ts
+++ b/apps/carbon/app/components/Editable/index.ts
@@ -2,6 +2,7 @@ import EditableList from "./EditableList";
import EditableNumber from "./EditableNumber";
import EditablePurchaseInvoiceLineNumber from "./EditablePurchaseInvoiceLineNumber";
import EditablePurchaseOrderLineNumber from "./EditablePurchaseOrderLineNumber";
+import EditableQuotationPart from "./EditableQuotationPart";
import EditableText from "./EditableText";
export * from "./types";
@@ -10,5 +11,6 @@ export {
EditableNumber,
EditablePurchaseInvoiceLineNumber,
EditablePurchaseOrderLineNumber,
+ EditableQuotationPart,
EditableText,
};
diff --git a/apps/carbon/app/components/Form/NumberControlled.tsx b/apps/carbon/app/components/Form/NumberControlled.tsx
new file mode 100644
index 0000000000..d948869655
--- /dev/null
+++ b/apps/carbon/app/components/Form/NumberControlled.tsx
@@ -0,0 +1,88 @@
+import type { NumberFieldProps } from "@carbon/react";
+import {
+ FormControl,
+ FormErrorMessage,
+ FormHelperText,
+ FormLabel,
+ NumberDecrementStepper,
+ NumberField,
+ NumberIncrementStepper,
+ NumberInput,
+ NumberInputGroup,
+ NumberInputStepper,
+} from "@carbon/react";
+
+import { forwardRef, useEffect } from "react";
+import { LuChevronDown, LuChevronUp } from "react-icons/lu";
+import { useControlField, useField } from "remix-validated-form";
+
+type FormNumberProps = NumberFieldProps & {
+ name: string;
+ label?: string;
+ isRequired?: boolean;
+ helperText?: string;
+ value: number;
+ onChange?: (newValue: number) => void;
+};
+
+const Number = forwardRef<HTMLInputElement, FormNumberProps>(
+ (
+ {
+ name,
+ label,
+ isRequired,
+ isReadOnly,
+ helperText,
+ value,
+ onChange,
+ ...rest
+ },
+ ref
+ ) => {
+ const { getInputProps, error } = useField(name);
+ const [controlValue, setControlValue] = useControlField<number>(name);
+
+ useEffect(() => {
+ setControlValue(value);
+ }, [setControlValue, value]);
+
+ const handleChange = (newValue: number) => {
+ setControlValue(newValue);
+ onChange?.(newValue);
+ };
+
+ return (
+ <FormControl isInvalid={!!error} isRequired={isRequired}>
+ {label && <FormLabel htmlFor={name}>{label}</FormLabel>}
+ <NumberField
+ {...getInputProps({
+ id: name,
+ ...rest,
+ })}
+ value={controlValue}
+ onChange={handleChange}
+ >
+ <NumberInputGroup className="relative">
+ <NumberInput isReadOnly={isReadOnly} />
+ {!isReadOnly && (
+ <NumberInputStepper>
+ <NumberIncrementStepper>
+ <LuChevronUp size="1em" strokeWidth="3" />
+ </NumberIncrementStepper>
+ <NumberDecrementStepper>
+ <LuChevronDown size="1em" strokeWidth="3" />
+ </NumberDecrementStepper>
+ </NumberInputStepper>
+ )}
+ </NumberInputGroup>
+ </NumberField>
+ {helperText && <FormHelperText>{helperText}</FormHelperText>}
+ {error && <FormErrorMessage>{error}</FormErrorMessage>}
+ </FormControl>
+ );
+ }
+);
+
+Number.displayName = "Number";
+
+export default Number;
diff --git a/apps/carbon/app/components/Form/index.ts b/apps/carbon/app/components/Form/index.ts
index 30d31bff69..579f4ae41f 100644
--- a/apps/carbon/app/components/Form/index.ts
+++ b/apps/carbon/app/components/Form/index.ts
@@ -22,6 +22,7 @@ import Input from "./Input";
import InputControlled from "./InputControlled";
import Location from "./Location";
import Number from "./Number";
+import NumberControlled from "./NumberControlled";
import Part from "./Part";
import Password from "./Password";
import Phone from "./Phone";
@@ -67,6 +68,7 @@ export {
InputControlled,
Location,
Number,
+ NumberControlled,
Part,
Password,
Phone,
diff --git a/apps/carbon/app/components/Grid/Grid.tsx b/apps/carbon/app/components/Grid/Grid.tsx
index 9e349dc89c..d18c525b01 100644
--- a/apps/carbon/app/components/Grid/Grid.tsx
+++ b/apps/carbon/app/components/Grid/Grid.tsx
@@ -333,7 +333,7 @@ const Grid = <T extends object>({
/>
)} */}
<div
- className="w-full h-full bg-background overflow-x-auto"
+ className="w-full h-full bg-card overflow-x-auto"
style={{
contain: contained ? "strict" : undefined,
}}
diff --git a/apps/carbon/app/components/Grid/components/Row.tsx b/apps/carbon/app/components/Grid/components/Row.tsx
index eae7171ee2..0feb3a6dbe 100644
--- a/apps/carbon/app/components/Grid/components/Row.tsx
+++ b/apps/carbon/app/components/Grid/components/Row.tsx
@@ -40,7 +40,7 @@ const Row = <T extends object>({
<Tr
key={row.id}
ref={rowRef}
- className={cn("hover:bg-background", rowIsClickable && "cursor-pointer")}
+ className={cn(rowIsClickable && "cursor-pointer")}
>
{row.getVisibleCells().map((cell, columnIndex) => {
const isSelected =
diff --git a/apps/carbon/app/components/Layout/TableFilters.tsx b/apps/carbon/app/components/Layout/TableFilters.tsx
index 8bb04e77c9..2bf48bc031 100644
--- a/apps/carbon/app/components/Layout/TableFilters.tsx
+++ b/apps/carbon/app/components/Layout/TableFilters.tsx
@@ -10,7 +10,7 @@ const TableFilters = forwardRef<
<div
ref={ref}
className={cn(
- "flex px-4 py-3 items-center space-x-4 justify-between border-b border-border w-full",
+ "flex px-4 py-3 items-center space-x-4 justify-between bg-card border-b border-border w-full",
className
)}
{...props}
diff --git a/apps/carbon/app/components/Search/Search/Search.tsx b/apps/carbon/app/components/Search/Search/Search.tsx
index 7286ba765e..1552a3b28d 100644
--- a/apps/carbon/app/components/Search/Search/Search.tsx
+++ b/apps/carbon/app/components/Search/Search/Search.tsx
@@ -167,9 +167,9 @@ const SearchModal = ({
{recentResults.length > 0 && (
<>
<CommandGroup heading="Recent Searches">
- {recentResults.map((result) => (
+ {recentResults.map((result, index) => (
<CommandItem
- key={result.to}
+ key={`${result.to}-${index}`}
onSelect={() => onSelect(result)}
// append with : so we're not sharing a value with a static result
value={`:${result.to}`}
@@ -203,9 +203,9 @@ const SearchModal = ({
))}
{searchResults.length > 0 && (
<CommandGroup heading="Search Results">
- {searchResults.map((result) => (
+ {searchResults.map((result, index) => (
<CommandItem
- key={result.id}
+ key={`${result.id}-${index}`}
value={`${input}${result.id}`}
onSelect={() =>
onSelect({
diff --git a/apps/carbon/app/components/Table/Table.tsx b/apps/carbon/app/components/Table/Table.tsx
index 876f02d3a2..facefc90cf 100644
--- a/apps/carbon/app/components/Table/Table.tsx
+++ b/apps/carbon/app/components/Table/Table.tsx
@@ -439,7 +439,7 @@ const Table = <T extends object>({
/>
)}
<div
- className="w-full h-full bg-background overflow-scroll"
+ className="w-full h-full bg-card overflow-scroll"
style={{ contain: "strict" }}
ref={tableContainerRef}
onKeyDown={editMode ? onKeyDown : undefined}
diff --git a/apps/carbon/app/components/Table/components/Row.tsx b/apps/carbon/app/components/Table/components/Row.tsx
index bb072945f6..1309134bea 100644
--- a/apps/carbon/app/components/Table/components/Row.tsx
+++ b/apps/carbon/app/components/Table/components/Row.tsx
@@ -46,7 +46,7 @@ const Row = <T extends object>({
<Tr
key={row.id}
className={cn(
- "hover:bg-background border-b border-border transition-colors",
+ "border-b border-border transition-colors",
isFrozenColumn && "bg-background"
)}
{...props}
diff --git a/apps/carbon/app/modules/sales/sales.models.ts b/apps/carbon/app/modules/sales/sales.models.ts
index b3743b545a..27f61c26b3 100644
--- a/apps/carbon/app/modules/sales/sales.models.ts
+++ b/apps/carbon/app/modules/sales/sales.models.ts
@@ -86,6 +86,23 @@ export const quotationValidator = withZod(
})
);
+export const quotationLineValidator = withZod(
+ z.object({
+ id: zfd.text(z.string().optional()),
+ quoteId: z.string(),
+ partId: z.string().min(1, { message: "Part is required" }),
+ customerPartId: zfd.text(z.string().optional()),
+ description: z.string().min(1, { message: "Description is required" }),
+ // unitOfMeasureCode: z
+ // .string()
+ // .min(1, { message: "Unit of measure is required" }),
+ unitCost: zfd.numeric(z.number().optional()),
+ unitPrice: zfd.numeric(z.number()),
+ quantity: zfd.numeric(z.number()),
+ leadTime: zfd.numeric(z.number().optional()),
+ })
+);
+
export const quotationReleaseValidator = withZod(
z
.object({
diff --git a/apps/carbon/app/modules/sales/sales.service.ts b/apps/carbon/app/modules/sales/sales.service.ts
index a298aedd93..cea56f0e38 100644
--- a/apps/carbon/app/modules/sales/sales.service.ts
+++ b/apps/carbon/app/modules/sales/sales.service.ts
@@ -10,6 +10,7 @@ import type {
customerShippingValidator,
customerTypeValidator,
customerValidator,
+ quotationLineValidator,
quotationValidator,
} from "./sales.models";
@@ -219,7 +220,7 @@ export async function getQuote(
client: SupabaseClient<Database>,
quoteId: string
) {
- return client.from("quote").select("*").eq("id", quoteId).single();
+ return client.from("quotes").select("*").eq("id", quoteId).single();
}
export async function getQuotes(
@@ -269,11 +270,18 @@ export async function getQuoteInternalDocuments(
return client.storage.from("quote-internal").list(quoteId);
}
+export async function getQuoteLine(
+ client: SupabaseClient<Database>,
+ quoteLineId: string
+) {
+ return client.from("quoteLine").select("*").eq("id", quoteLineId).single();
+}
+
export async function getQuoteLines(
client: SupabaseClient<Database>,
quoteId: string
) {
- return client.from("quoteLines").select("*").eq("quoteId", quoteId);
+ return client.from("quoteLine").select("*").eq("quoteId", quoteId);
}
export async function insertCustomer(
@@ -515,3 +523,25 @@ export async function upsertQuote(
return client.from("quote").update(sanitize(quote)).eq("id", quote.id);
}
}
+
+export async function upsertQuoteLine(
+ client: SupabaseClient<Database>,
+ quotationLine:
+ | (Omit<TypeOfValidator<typeof quotationLineValidator>, "id"> & {
+ createdBy: string;
+ })
+ | (Omit<TypeOfValidator<typeof quotationLineValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+) {
+ if ("id" in quotationLine) {
+ return client
+ .from("quoteLine")
+ .update(sanitize(quotationLine))
+ .eq("id", quotationLine.id)
+ .select("id")
+ .single();
+ }
+ return client.from("quoteLine").insert([quotationLine]).select("id").single();
+}
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationForm.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationForm.tsx
index 60a9f5d831..b8e5a185b2 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationForm.tsx
@@ -65,17 +65,17 @@ const QuotationForm = ({ initialValues }: QuotationFormProps) => {
isEditing ? "grid-cols-1 md:grid-cols-3" : "grid-cols-1"
)}
>
- <VStack>
- <Input name="name" label="Name" />
- <Employee name="ownerId" label="Quoter" />
- <Location name="locationId" label="Location" />
- </VStack>
<VStack>
<Customer
name="customerId"
label="Customer"
onChange={(value) => setCustomer(value?.value as string)}
/>
+ <Input name="name" label="Name" />
+ <Employee name="ownerId" label="Quoter" />
+ </VStack>
+ <VStack>
+ <Location name="locationId" label="Location" />
<CustomerLocation
name="customerLocationId"
label="Customer Location"
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationHeader.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationHeader.tsx
index 5fb684a5af..0652bf3742 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationHeader.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationHeader.tsx
@@ -80,6 +80,12 @@ const QuotationHeader = () => {
{formatter.format(quotationTotals?.total ?? 0)}
</CardAttributeValue>
</CardAttribute>
+ <CardAttribute>
+ <CardAttributeLabel>Name</CardAttributeLabel>
+ <CardAttributeValue>
+ {routeData?.quotation?.name}
+ </CardAttributeValue>
+ </CardAttribute>
<CardAttribute>
<CardAttributeLabel>Quote Date</CardAttributeLabel>
<CardAttributeValue>
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationLineForm.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationLineForm.tsx
new file mode 100644
index 0000000000..f321e905fb
--- /dev/null
+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationLineForm.tsx
@@ -0,0 +1,169 @@
+import {
+ Button,
+ Drawer,
+ DrawerBody,
+ DrawerContent,
+ DrawerFooter,
+ DrawerHeader,
+ DrawerTitle,
+ HStack,
+ VStack,
+} from "@carbon/react";
+
+import { useNavigate, useParams } from "@remix-run/react";
+import { useState } from "react";
+import { ValidatedForm } from "remix-validated-form";
+import {
+ Hidden,
+ Input,
+ InputControlled,
+ Number,
+ NumberControlled,
+ Part,
+ Submit,
+} from "~/components/Form";
+import { usePermissions, useRouteData } from "~/hooks";
+import { useSupabase } from "~/lib/supabase";
+import type { Quotation } from "~/modules/sales";
+import { quotationLineValidator } from "~/modules/sales";
+import type { TypeOfValidator } from "~/types/validators";
+import { path } from "~/utils/path";
+
+type QuotationLineFormProps = {
+ initialValues: TypeOfValidator<typeof quotationLineValidator>;
+};
+
+const QuotationLineForm = ({ initialValues }: QuotationLineFormProps) => {
+ const permissions = usePermissions();
+ const { supabase } = useSupabase();
+ const navigate = useNavigate();
+
+ const { id } = useParams();
+
+ if (!id) throw new Error("id not found");
+
+ const routeData = useRouteData<{
+ quotation: Quotation;
+ }>(path.to.quote(id));
+
+ const [partData, setPartData] = useState<{
+ partId: string;
+ description: string;
+ unitCost: number;
+ unitPrice: number;
+ // uom: string;
+ }>({
+ partId: initialValues.partId ?? "",
+ description: initialValues.description ?? "",
+ unitCost: initialValues.unitCost ?? 0,
+ unitPrice: initialValues.unitPrice ?? 0,
+ // uom: initialValues.unitOfMeasureCode ?? "",
+ });
+
+ const isEditable = ["Draft", "To Review"].includes(
+ routeData?.quotation?.status ?? ""
+ );
+
+ const isEditing = initialValues.id !== undefined;
+ const isDisabled = !isEditable
+ ? true
+ : isEditing
+ ? !permissions.can("update", "sales")
+ : !permissions.can("create", "sales");
+
+ const onClose = () => navigate(-1);
+
+ const onPartChange = async (partId: string) => {
+ if (!supabase) return;
+ const [part, cost] = await Promise.all([
+ supabase
+ .from("part")
+ .select("name, unitOfMeasureCode")
+ .eq("id", partId)
+ .single(),
+ supabase
+ .from("partCost")
+ .select("unitCost")
+ .eq("partId", partId)
+ .single(),
+ ]);
+
+ setPartData({
+ partId,
+ description: part.data?.name ?? "",
+ unitCost: cost.data?.unitCost ?? 0,
+ unitPrice: cost.data?.unitCost ?? 0,
+ // uom: part.data?.unitOfMeasureCode ?? "EA",
+ });
+ };
+
+ return (
+ <Drawer
+ open
+ onOpenChange={(open) => {
+ if (!open) onClose();
+ }}
+ >
+ <DrawerContent>
+ <ValidatedForm
+ defaultValues={initialValues}
+ validator={quotationLineValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.quoteLine(id, initialValues.id!)
+ : path.to.newQuoteLine(id)
+ }
+ className="flex flex-col h-full"
+ >
+ <DrawerHeader>
+ <DrawerTitle>
+ {isEditing ? "Edit" : "New"} Quotation Line
+ </DrawerTitle>
+ </DrawerHeader>
+ <DrawerBody>
+ <Hidden name="id" />
+ <Hidden name="quoteId" />
+ <Hidden name="unitCost" value={partData.unitCost} />
+ <VStack spacing={4}>
+ <Part
+ name="partId"
+ label="Part"
+ onChange={(value) => {
+ onPartChange(value?.value as string);
+ }}
+ />
+
+ <InputControlled
+ name="description"
+ label="Description"
+ value={partData.description}
+ onChange={(newValue) =>
+ setPartData((d) => ({ ...d, description: newValue }))
+ }
+ />
+ <Input name="customerPartId" label="Customer Part ID" />
+ <Number name="quantity" label="Quantity" />
+ <NumberControlled
+ name="unitPrice"
+ label="Unit Price"
+ value={partData.unitPrice}
+ />
+ <Number name="leadTime" label="Lead Time (Days)" />
+ </VStack>
+ </DrawerBody>
+ <DrawerFooter>
+ <HStack>
+ <Submit isDisabled={isDisabled}>Save</Submit>
+ <Button size="md" variant="solid" onClick={onClose}>
+ Cancel
+ </Button>
+ </HStack>
+ </DrawerFooter>
+ </ValidatedForm>
+ </DrawerContent>
+ </Drawer>
+ );
+};
+
+export default QuotationLineForm;
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationLines/QuotationLines.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationLines/QuotationLines.tsx
index f0bf1793fa..c7d3461de0 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationLines/QuotationLines.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationLines/QuotationLines.tsx
@@ -21,12 +21,18 @@ import { IoMdTrash } from "react-icons/io";
import { MdMoreHoriz } from "react-icons/md";
import {
EditableNumber,
- // EditableQuotationPart,
+ EditableQuotationPart,
EditableText,
} from "~/components/Editable";
import Grid from "~/components/Grid";
-import { useRouteData } from "~/hooks";
-import type { Quotation, QuotationLine } from "~/modules/sales";
+import { useRouteData, useUser } from "~/hooks";
+import { useSupabase } from "~/lib/supabase";
+import {
+ useQuotationTotals,
+ type Quotation,
+ type QuotationLine,
+} from "~/modules/sales";
+import { useParts } from "~/stores";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
import useQuotationLines from "./useQuotationLines";
@@ -35,6 +41,15 @@ const QuotationLines = () => {
const { id } = useParams();
if (!id) throw new Error("id not found");
+ const { supabase } = useSupabase();
+ const [parts] = useParts();
+ const { id: userId } = useUser();
+
+ const partOptions = parts.map((part) => ({
+ value: part.id,
+ label: part.id,
+ }));
+
const navigate = useNavigate();
const routeData = useRouteData<{
@@ -44,6 +59,7 @@ const QuotationLines = () => {
}>(path.to.quote(id));
const { canEdit, canDelete, onCellEdit } = useQuotationLines();
+ const [, setQuotationTotals] = useQuotationTotals();
const isEditable = ["Draft"].includes(routeData?.quotation?.status ?? "");
@@ -57,39 +73,41 @@ const QuotationLines = () => {
accessorKey: "partId",
header: "Part",
cell: ({ row }) => {
- <HStack className="justify-between min-w-[100px]">
- <span>{row.original.partId}</span>
- <div className="relative w-6 h-5">
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <IconButton
- aria-label="Edit quote line"
- icon={<MdMoreHoriz />}
- size="md"
- className="absolute right-[-1px] top-[-6px]"
- variant="ghost"
- onClick={(e) => e.stopPropagation()}
- />
- </DropdownMenuTrigger>
- <DropdownMenuContent>
- <DropdownMenuItem
- onClick={() => navigate(row.original.id!)}
- disabled={!isEditable || !canEdit}
- >
- <DropdownMenuIcon icon={<BsFillPenFill />} />
- Edit Line
- </DropdownMenuItem>
- <DropdownMenuItem
- onClick={() => navigate(`delete/${row.original.id}`)}
- disabled={!isEditable || !canDelete}
- >
- <DropdownMenuIcon icon={<IoMdTrash />} />
- Delete Line
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </div>
- </HStack>;
+ return (
+ <HStack className="justify-between min-w-[100px]">
+ <span>{row.original.partId}</span>
+ <div className="relative w-6 h-5">
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton
+ aria-label="Edit quote line"
+ icon={<MdMoreHoriz />}
+ size="md"
+ className="absolute right-[-1px] top-[-6px]"
+ variant="ghost"
+ onClick={(e) => e.stopPropagation()}
+ />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent>
+ <DropdownMenuItem
+ onClick={() => navigate(row.original.id!)}
+ disabled={!isEditable || !canEdit}
+ >
+ <DropdownMenuIcon icon={<BsFillPenFill />} />
+ Edit Line
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onClick={() => navigate(`delete/${row.original.id}`)}
+ disabled={!isEditable || !canDelete}
+ >
+ <DropdownMenuIcon icon={<IoMdTrash />} />
+ Delete Line
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ </HStack>
+ );
},
},
{
@@ -97,26 +115,50 @@ const QuotationLines = () => {
header: "Description",
cell: (item) => item.getValue(),
},
+ {
+ accessorKey: "customerPartId",
+ header: "Customer Part",
+ cell: (item) => item.getValue(),
+ },
{
accessorKey: "quantity",
header: "Quantity",
cell: (item) => item.getValue(),
},
+ {
+ accessorKey: "unitCost",
+ header: "Unit Cost",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "unitPrice",
+ header: "Unit Price",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "leadTime",
+ header: "Lead Time",
+ cell: (item) => item.getValue(),
+ },
];
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [navigate]);
const editableComponents = useMemo(
() => ({
+ partId: EditableQuotationPart(onCellEdit, {
+ client: supabase,
+ parts: partOptions,
+ userId,
+ }),
description: EditableText(onCellEdit),
+ customerPartId: EditableText(onCellEdit),
quantity: EditableNumber(onCellEdit),
+ unitCost: EditableNumber(onCellEdit),
unitPrice: EditableNumber(onCellEdit),
- // partId: EditableQuotationPart(onCellEdit, {
- // client: supabase,
- // parts: partOptions,
- // }),
+ leadTime: EditableNumber(onCellEdit),
}),
- [onCellEdit]
+ [onCellEdit, partOptions, supabase, userId]
);
return (
@@ -141,6 +183,17 @@ const QuotationLines = () => {
columns={columns}
canEdit={canEdit && isEditable}
editableComponents={editableComponents}
+ onDataChange={(lines: QuotationLine[]) => {
+ const totals = lines.reduce(
+ (acc, line) => {
+ acc.total += (line.quantity ?? 0) * (line.unitPrice ?? 0);
+
+ return acc;
+ },
+ { total: 0 }
+ );
+ setQuotationTotals(totals);
+ }}
onNewRow={canEdit && isEditable ? () => navigate("new") : undefined}
/>
</CardContent>
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/index.ts b/apps/carbon/app/modules/sales/ui/Quotation/index.ts
index 01496b611d..8d18fdf931 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/index.ts
+++ b/apps/carbon/app/modules/sales/ui/Quotation/index.ts
@@ -1,6 +1,7 @@
import QuotationDocuments from "./QuotationDocuments";
import QuotationForm from "./QuotationForm";
import QuotationHeader from "./QuotationHeader";
+import QuotationLineForm from "./QuotationLineForm";
import QuotationLines from "./QuotationLines";
import QuotationSidebar from "./QuotationSidebar";
import QuotationStatus from "./QuotationStatus";
@@ -10,6 +11,7 @@ export {
QuotationDocuments,
QuotationForm,
QuotationHeader,
+ QuotationLineForm,
QuotationLines,
QuotationSidebar,
QuotationStatus,
diff --git a/apps/carbon/app/routes/onboarding+/_layout.tsx b/apps/carbon/app/routes/onboarding+/_layout.tsx
index 96d570cd2e..7d0aeac470 100644
--- a/apps/carbon/app/routes/onboarding+/_layout.tsx
+++ b/apps/carbon/app/routes/onboarding+/_layout.tsx
@@ -49,9 +49,9 @@ export default function OnboardingLayout() {
// not sure why we need this ClientOnly, but things break without it
<ClientOnly fallback={null}>
{() => (
- <div className="grid grid-cols-[auto_1fr] h-screen w-screen">
+ <div className="bg-card grid grid-cols-[auto_1fr] h-screen w-screen">
<SidebarPlaceholder />
- <div className="gri grid-rows-[auto_1fr] h-full w-full">
+ <div className="grid grid-rows-[auto_1fr] h-full w-full">
<TopbarPlaceholder />
<div>
<Outlet />
diff --git a/apps/carbon/app/routes/x+/purchase-order+/$orderId.lines.$lineId.tsx b/apps/carbon/app/routes/x+/purchase-order+/$orderId.lines.$lineId.tsx
index 3647b65312..d9504166cd 100644
--- a/apps/carbon/app/routes/x+/purchase-order+/$orderId.lines.$lineId.tsx
+++ b/apps/carbon/app/routes/x+/purchase-order+/$orderId.lines.$lineId.tsx
@@ -17,7 +17,7 @@ import { error } from "~/utils/result";
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client } = await requirePermissions(request, {
- view: "parts",
+ view: "purchasing",
role: "employee",
});
diff --git a/apps/carbon/app/routes/x+/quote+/$id.lines.$lineId.tsx b/apps/carbon/app/routes/x+/quote+/$id.lines.$lineId.tsx
new file mode 100644
index 0000000000..8516ef4fda
--- /dev/null
+++ b/apps/carbon/app/routes/x+/quote+/$id.lines.$lineId.tsx
@@ -0,0 +1,89 @@
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
+import { json, redirect } from "@remix-run/node";
+import { useLoaderData } from "@remix-run/react";
+import { validationError } from "remix-validated-form";
+import {
+ QuotationLineForm,
+ getQuoteLine,
+ quotationLineValidator,
+ upsertQuoteLine,
+} from "~/modules/sales";
+import { requirePermissions } from "~/services/auth";
+import { flash } from "~/services/session.server";
+import { assertIsPost, notFound } from "~/utils/http";
+import { path } from "~/utils/path";
+import { error } from "~/utils/result";
+
+export async function loader({ request, params }: LoaderFunctionArgs) {
+ const { client } = await requirePermissions(request, {
+ view: "sales",
+ role: "employee",
+ });
+
+ const { lineId } = params;
+ if (!lineId) throw notFound("lineId not found");
+
+ const quotationLine = await getQuoteLine(client, lineId);
+
+ return json({
+ quotationLine: quotationLine?.data ?? null,
+ });
+}
+
+export async function action({ request, params }: ActionFunctionArgs) {
+ assertIsPost(request);
+ const { client, userId } = await requirePermissions(request, {
+ create: "purchasing",
+ });
+
+ const { id: quoteId, lineId } = params;
+ if (!quoteId) throw new Error("Could not find id");
+ if (!lineId) throw new Error("Could not find lineId");
+
+ const validation = await quotationLineValidator.validate(
+ await request.formData()
+ );
+
+ if (validation.error) {
+ return validationError(validation.error);
+ }
+
+ const { id, ...data } = validation.data;
+
+ const updateQuotationLine = await upsertQuoteLine(client, {
+ id: lineId,
+ ...data,
+ updatedBy: userId,
+ });
+
+ if (updateQuotationLine.error) {
+ return redirect(
+ path.to.quoteLines(quoteId),
+ await flash(
+ request,
+ error(updateQuotationLine.error, "Failed to update quote line")
+ )
+ );
+ }
+
+ return redirect(path.to.quoteLines(quoteId));
+}
+
+export default function EditQuotationLineRoute() {
+ const { quotationLine } = useLoaderData<typeof loader>();
+
+ const initialValues = {
+ id: quotationLine?.id ?? undefined,
+ quoteId: quotationLine?.quoteId ?? "",
+
+ partId: quotationLine?.partId ?? "",
+ customerPartId: quotationLine?.customerPartId ?? "",
+ description: quotationLine?.description ?? "",
+ quantity: quotationLine?.quantity ?? 1,
+ unitCost: quotationLine?.unitCost ?? 0,
+ unitPrice: quotationLine?.unitPrice ?? 0,
+ leadTime: quotationLine?.leadTime ?? undefined,
+ };
+
+ return <QuotationLineForm initialValues={initialValues} />;
+}
diff --git a/apps/carbon/app/routes/x+/quote+/$id.lines.new.tsx b/apps/carbon/app/routes/x+/quote+/$id.lines.new.tsx
new file mode 100644
index 0000000000..30e84e751f
--- /dev/null
+++ b/apps/carbon/app/routes/x+/quote+/$id.lines.new.tsx
@@ -0,0 +1,70 @@
+import type { ActionFunctionArgs } from "@remix-run/node";
+import { redirect } from "@remix-run/node";
+import { useParams } from "@remix-run/react";
+import { validationError } from "remix-validated-form";
+import {
+ QuotationLineForm,
+ quotationLineValidator,
+ upsertQuoteLine,
+} from "~/modules/sales";
+import { requirePermissions } from "~/services/auth";
+import { flash } from "~/services/session.server";
+import { assertIsPost } from "~/utils/http";
+import { path } from "~/utils/path";
+import { error } from "~/utils/result";
+
+export async function action({ request, params }: ActionFunctionArgs) {
+ assertIsPost(request);
+ const { client, userId } = await requirePermissions(request, {
+ create: "sales",
+ });
+
+ const { id: quoteId } = params;
+ if (!quoteId) throw new Error("Could not find id");
+
+ const validation = await quotationLineValidator.validate(
+ await request.formData()
+ );
+
+ if (validation.error) {
+ return validationError(validation.error);
+ }
+
+ const { id, ...data } = validation.data;
+
+ const createQuotationLine = await upsertQuoteLine(client, {
+ ...data,
+ createdBy: userId,
+ });
+
+ console.log({ createQuotationLine });
+
+ if (createQuotationLine.error) {
+ return redirect(
+ path.to.quoteLines(quoteId),
+ await flash(
+ request,
+ error(createQuotationLine.error, "Failed to create quote line.")
+ )
+ );
+ }
+
+ return redirect(path.to.quoteLines(quoteId));
+}
+
+export default function NewQuotationLineRoute() {
+ const { id } = useParams();
+
+ if (!id) throw new Error("Could not find quote id");
+
+ const initialValues = {
+ quoteId: id,
+ partId: "",
+ description: "",
+ quantity: 1,
+ unitCost: 0,
+ unitPrice: 0,
+ };
+
+ return <QuotationLineForm initialValues={initialValues} />;
+}
diff --git a/apps/carbon/app/routes/x+/quote+/$id.tsx b/apps/carbon/app/routes/x+/quote+/$id.tsx
index 99c207f3e3..7e69d42e05 100644
--- a/apps/carbon/app/routes/x+/quote+/$id.tsx
+++ b/apps/carbon/app/routes/x+/quote+/$id.tsx
@@ -75,7 +75,7 @@ export default function QuotationRoute() {
useEffect(() => {
const totals = quotationLines.reduce(
(acc, line) => {
- acc.total += (line.purchaseQuantity ?? 0) * (line.unitPrice ?? 0);
+ acc.total += (line.quantity ?? 0) * (line.unitPrice ?? 0);
return acc;
},
diff --git a/apps/carbon/app/routes/x+/quote+/$orderId.lines.$lineId.tsx b/apps/carbon/app/routes/x+/quote+/$orderId.lines.$lineId.tsx
deleted file mode 100644
index 3647b65312..0000000000
--- a/apps/carbon/app/routes/x+/quote+/$orderId.lines.$lineId.tsx
+++ /dev/null
@@ -1,121 +0,0 @@
-import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
-import { json, redirect } from "@remix-run/node";
-import { useLoaderData } from "@remix-run/react";
-import { validationError } from "remix-validated-form";
-import type { PurchaseOrderLineType } from "~/modules/purchasing";
-import {
- PurchaseOrderLineForm,
- getPurchaseOrderLine,
- purchaseOrderLineValidator,
- upsertPurchaseOrderLine,
-} from "~/modules/purchasing";
-import { requirePermissions } from "~/services/auth";
-import { flash } from "~/services/session.server";
-import { assertIsPost, notFound } from "~/utils/http";
-import { path } from "~/utils/path";
-import { error } from "~/utils/result";
-
-export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client } = await requirePermissions(request, {
- view: "parts",
- role: "employee",
- });
-
- const { lineId } = params;
- if (!lineId) throw notFound("lineId not found");
-
- const purchaseOrderLine = await getPurchaseOrderLine(client, lineId);
-
- return json({
- purchaseOrderLine: purchaseOrderLine?.data ?? null,
- });
-}
-
-export async function action({ request, params }: ActionFunctionArgs) {
- assertIsPost(request);
- const { client, userId } = await requirePermissions(request, {
- create: "purchasing",
- });
-
- const { orderId, lineId } = params;
- if (!orderId) throw new Error("Could not find orderId");
- if (!lineId) throw new Error("Could not find lineId");
-
- const validation = await purchaseOrderLineValidator.validate(
- await request.formData()
- );
-
- if (validation.error) {
- return validationError(validation.error);
- }
-
- const { id, ...data } = validation.data;
-
- if (data.purchaseOrderLineType === "Part") {
- data.accountNumber = undefined;
- data.assetId = undefined;
- data.serviceId = undefined;
- } else if (data.purchaseOrderLineType === "Service") {
- data.accountNumber = undefined;
- data.assetId = undefined;
- data.partId = undefined;
- } else if (data.purchaseOrderLineType === "G/L Account") {
- data.assetId = undefined;
- data.partId = undefined;
- data.serviceId = undefined;
- } else if (data.purchaseOrderLineType === "Fixed Asset") {
- data.accountNumber = undefined;
- data.partId = undefined;
- data.serviceId = undefined;
- } else if (data.purchaseOrderLineType === "Comment") {
- data.accountNumber = undefined;
- data.assetId = undefined;
- data.partId = undefined;
- data.serviceId = undefined;
- }
-
- const updatePurchaseOrderLine = await upsertPurchaseOrderLine(client, {
- id: lineId,
- ...data,
- updatedBy: userId,
- });
-
- if (updatePurchaseOrderLine.error) {
- return redirect(
- path.to.purchaseOrderLines(orderId),
- await flash(
- request,
- error(
- updatePurchaseOrderLine.error,
- "Failed to update purchase order line"
- )
- )
- );
- }
-
- return redirect(path.to.purchaseOrderLines(orderId));
-}
-
-export default function EditPurchaseOrderLineRoute() {
- const { purchaseOrderLine } = useLoaderData<typeof loader>();
-
- const initialValues = {
- id: purchaseOrderLine?.id ?? undefined,
- purchaseOrderId: purchaseOrderLine?.purchaseOrderId ?? "",
- purchaseOrderLineType:
- purchaseOrderLine?.purchaseOrderLineType ??
- ("Part" as PurchaseOrderLineType),
- partId: purchaseOrderLine?.partId ?? "",
- serviceId: purchaseOrderLine?.serviceId ?? "",
- accountNumber: purchaseOrderLine?.accountNumber ?? "",
- assetId: purchaseOrderLine?.assetId ?? "",
- description: purchaseOrderLine?.description ?? "",
- purchaseQuantity: purchaseOrderLine?.purchaseQuantity ?? 1,
- unitPrice: purchaseOrderLine?.unitPrice ?? 0,
- setupPrice: purchaseOrderLine?.setupPrice ?? 0,
- unitOfMeasureCode: purchaseOrderLine?.unitOfMeasureCode ?? "",
- shelfId: purchaseOrderLine?.shelfId ?? "",
- };
-
- return <PurchaseOrderLineForm initialValues={initialValues} />;
-}
diff --git a/apps/carbon/app/routes/x+/quote+/$orderId.lines.new.tsx b/apps/carbon/app/routes/x+/quote+/$orderId.lines.new.tsx
deleted file mode 100644
index 90b961ef88..0000000000
--- a/apps/carbon/app/routes/x+/quote+/$orderId.lines.new.tsx
+++ /dev/null
@@ -1,74 +0,0 @@
-import type { ActionFunctionArgs } from "@remix-run/node";
-import { redirect } from "@remix-run/node";
-import { useParams } from "@remix-run/react";
-import { validationError } from "remix-validated-form";
-import type { PurchaseOrderLineType } from "~/modules/purchasing";
-import {
- PurchaseOrderLineForm,
- purchaseOrderLineValidator,
- upsertPurchaseOrderLine,
-} from "~/modules/purchasing";
-import { requirePermissions } from "~/services/auth";
-import { flash } from "~/services/session.server";
-import { assertIsPost } from "~/utils/http";
-import { path } from "~/utils/path";
-import { error } from "~/utils/result";
-
-export async function action({ request, params }: ActionFunctionArgs) {
- assertIsPost(request);
- const { client, userId } = await requirePermissions(request, {
- create: "purchasing",
- });
-
- const { orderId } = params;
- if (!orderId) throw new Error("Could not find orderId");
-
- const validation = await purchaseOrderLineValidator.validate(
- await request.formData()
- );
-
- if (validation.error) {
- return validationError(validation.error);
- }
-
- const { id, ...data } = validation.data;
-
- const createPurchaseOrderLine = await upsertPurchaseOrderLine(client, {
- ...data,
- createdBy: userId,
- });
-
- if (createPurchaseOrderLine.error) {
- return redirect(
- path.to.purchaseOrderLines(orderId),
- await flash(
- request,
- error(
- createPurchaseOrderLine.error,
- "Failed to create purchase order line."
- )
- )
- );
- }
-
- return redirect(path.to.purchaseOrderLines(orderId));
-}
-
-export default function NewPurchaseOrderLineRoute() {
- const { orderId } = useParams();
-
- if (!orderId) throw new Error("Could not find purchase order id");
-
- const initialValues = {
- purchaseOrderId: orderId,
- purchaseOrderLineType: "Part" as PurchaseOrderLineType,
- partId: "",
- purchaseQuantity: 1,
- unitPrice: 0,
- setupPrice: 0,
- unitOfMeasureCode: "",
- shelfId: "",
- };
-
- return <PurchaseOrderLineForm initialValues={initialValues} />;
-}
diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.ts
index 784c818859..88555a8f61 100644
--- a/apps/carbon/app/utils/path.ts
+++ b/apps/carbon/app/utils/path.ts
@@ -274,6 +274,7 @@ export const path = {
newPurchaseOrderLine: (id: string) =>
generatePath(`${x}/purchase-order/${id}/lines/new`),
newQuote: `${x}/quote/new`,
+ newQuoteLine: (id: string) => generatePath(`${x}/quote/${id}/lines/new`),
newReceipt: `${x}/inventory/receipts/new`,
newRequestForQuote: `${x}/rfq/new`,
newShift: `${x}/resources/shifts/new`,
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index d37712153f..f8bb4f551c 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -6928,9 +6928,14 @@ export interface Database {
customerPartId: string | null;
description: string;
id: string;
+ leadTime: number | null;
partId: string;
quantity: number;
quoteId: string;
+ quoteRevisionId: number;
+ unitCost: number;
+ unitOfMeasureCode: string | null;
+ unitPrice: number;
updatedAt: string | null;
updatedBy: string | null;
};
@@ -6939,9 +6944,14 @@ export interface Database {
customerPartId?: string | null;
description: string;
id?: string;
+ leadTime?: number | null;
partId: string;
quantity?: number;
quoteId: string;
+ quoteRevisionId?: number;
+ unitCost?: number;
+ unitOfMeasureCode?: string | null;
+ unitPrice?: number;
updatedAt?: string | null;
updatedBy?: string | null;
};
@@ -6950,9 +6960,14 @@ export interface Database {
customerPartId?: string | null;
description?: string;
id?: string;
+ leadTime?: number | null;
partId?: string;
quantity?: number;
quoteId?: string;
+ quoteRevisionId?: number;
+ unitCost?: number;
+ unitOfMeasureCode?: string | null;
+ unitPrice?: number;
updatedAt?: string | null;
updatedBy?: string | null;
};
diff --git a/packages/database/supabase/migrations/20240206224405_quotes.sql b/packages/database/supabase/migrations/20240206224405_quotes.sql
index 807080089c..52b8bbc93c 100644
--- a/packages/database/supabase/migrations/20240206224405_quotes.sql
+++ b/packages/database/supabase/migrations/20240206224405_quotes.sql
@@ -45,11 +45,15 @@ CREATE TABLE "quote" (
CREATE TABLE "quoteLine" (
"id" TEXT NOT NULL DEFAULT xid(),
"quoteId" TEXT NOT NULL,
- -- "quoteRevisionId" INTEGER NOT NULL DEFAULT 0,
+ "quoteRevisionId" INTEGER NOT NULL DEFAULT 0,
"partId" TEXT NOT NULL,
"customerPartId" TEXT,
"description" TEXT NOT NULL,
"quantity" NUMERIC(10, 2) NOT NULL DEFAULT 0,
+ "unitCost" NUMERIC(10, 2) NOT NULL DEFAULT 0,
+ "unitPrice" NUMERIC(10, 2) NOT NULL DEFAULT 0,
+ "unitOfMeasureCode" TEXT,
+ "leadTime" INTEGER,
"createdBy" TEXT NOT NULL,
"updatedAt" TIMESTAMP WITH TIME ZONE,
"updatedBy" TEXT,
@@ -57,6 +61,7 @@ CREATE TABLE "quoteLine" (
CONSTRAINT "quoteLine_pkey" PRIMARY KEY ("id"),
CONSTRAINT "quoteLine_quoteId_fkey" FOREIGN KEY ("quoteId") REFERENCES "quote" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "quoteLine_partId_fkey" FOREIGN KEY ("partId") REFERENCES "part" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
+
CONSTRAINT "quoteLine_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "quoteLine_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
@@ -79,7 +84,7 @@ CREATE TABLE "quoteLineQuantities" (
"unitCostBase" NUMERIC(10, 2) NOT NULL DEFAULT 0,
"unitTaxAmount" NUMERIC(10, 2) NOT NULL DEFAULT 0,
"extendedCost" NUMERIC(10, 2) NOT NULL DEFAULT 0,
- "leadTime" INTEGER NOT NULL DEFAULT 0,
+ "leadTime" NUMERIC (5,2) NOT NULL DEFAULT 0,
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
"createdBy" TEXT NOT NULL,
"updatedAt" TIMESTAMP WITH TIME ZONE,
diff --git a/packages/react/src/Command.tsx b/packages/react/src/Command.tsx
index 13c1eb87d5..1ab0aa3b44 100644
--- a/packages/react/src/Command.tsx
+++ b/packages/react/src/Command.tsx
@@ -179,7 +179,7 @@ const CommandShortcut = ({
CommandShortcut.displayName = "CommandShortcut";
const commandTriggerVariants = cva(
- "bg-background text-foreground flex w-full items-center justify-between whitespace-nowrap rounded-md border border-input shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
+ "bg-card text-foreground flex w-full items-center justify-between whitespace-nowrap rounded-md border border-input shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
{
variants: {
size: {
diff --git a/packages/react/src/Drawer.tsx b/packages/react/src/Drawer.tsx
index 3bf87bcc33..dcbd6e77a8 100644
--- a/packages/react/src/Drawer.tsx
+++ b/packages/react/src/Drawer.tsx
@@ -72,7 +72,7 @@ const DrawerBody = ({
DrawerBody.displayName = "DrawerBody";
const sheetVariants = cva(
- "fixed flex flex-col z-50 scale-100 bg-background opacity-100 shadow-lg border border-border overflow-y-auto transition-all duration-100",
+ "fixed flex flex-col z-50 scale-100 bg-card opacity-100 shadow-lg border border-border overflow-y-auto transition-all duration-100",
{
variants: {
position: {
diff --git a/packages/react/src/Input.tsx b/packages/react/src/Input.tsx
index 8b65c79a93..3b17f8e730 100644
--- a/packages/react/src/Input.tsx
+++ b/packages/react/src/Input.tsx
@@ -10,7 +10,7 @@ import { getValidChildren } from "~/utils/react";
const InputGroupContext = createContext<boolean>(false);
const inputGroupVariants = cva(
- "flex relative w-full bg-background text-foreground shadow-sm focus-within:outline-none border border-input ring-offset-background focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",
+ "flex relative w-full bg-transparent text-foreground shadow-sm focus-within:outline-none border border-input ring-offset-background focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",
{
variants: {
size: {
@@ -93,7 +93,7 @@ const InputGroup = forwardRef<HTMLDivElement, InputGroupProps>(
InputGroup.displayName = "InputGroup";
export const inputVariants = cva(
- "flex w-full px-3 py-1 bg-background text-foreground transition-colors placeholder:text-muted-foreground disabled:opacity-50 rounded-md ",
+ "flex w-full px-3 py-1 bg-transparent text-foreground transition-colors placeholder:text-muted-foreground disabled:opacity-50 rounded-md ",
{
variants: {
size: {
diff --git a/packages/react/src/Menubar.tsx b/packages/react/src/Menubar.tsx
index cb39ec9084..7c6e580327 100644
--- a/packages/react/src/Menubar.tsx
+++ b/packages/react/src/Menubar.tsx
@@ -8,7 +8,7 @@ const Menubar = forwardRef<HTMLDivElement, ComponentProps<"div">>(
return (
<div
{...props}
- className="flex items-center bg-background border border-border rounded-md shadow-sm justify-start p-1 w-full space-x-1"
+ className="flex items-center bg-card border border-border rounded-md shadow-sm justify-start p-1 w-full space-x-1"
>
{children}
</div>
diff --git a/packages/react/src/Select.tsx b/packages/react/src/Select.tsx
index 47daa9cc67..c77b29bb22 100644
--- a/packages/react/src/Select.tsx
+++ b/packages/react/src/Select.tsx
@@ -21,7 +21,7 @@ const SelectGroup = SelectPrimitive.Group;
const SelectValue = SelectPrimitive.Value;
const selectTriggerVariants = cva(
- "bg-background text-foreground flex w-full items-center justify-between whitespace-nowrap rounded-md border border-input shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
+ "bg-transparent text-foreground flex w-full items-center justify-between whitespace-nowrap rounded-md border border-input shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
{
variants: {
size: {
diff --git a/packages/react/src/Textarea.tsx b/packages/react/src/Textarea.tsx
index 8f18ebee73..89ca2870d3 100644
--- a/packages/react/src/Textarea.tsx
+++ b/packages/react/src/Textarea.tsx
@@ -10,7 +10,7 @@ const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
return (
<textarea
className={cn(
- "flex min-h-[2lh] max-h-[10lh] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 read-only:bg-muted read-only:cursor-not-allowed ",
+ "flex min-h-[2lh] max-h-[10lh] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 read-only:bg-muted read-only:cursor-not-allowed ",
className
)}
ref={ref}
diff --git a/packages/utils/src/themes.ts b/packages/utils/src/themes.ts
index 3002a75c72..f862fe270e 100644
--- a/packages/utils/src/themes.ts
+++ b/packages/utils/src/themes.ts
@@ -33,9 +33,9 @@ export const themes = [
dark: {
background: "240 10% 3.9%",
foreground: "0 0% 98%",
- card: "240 10% 3.9%",
+ card: "240 10% 8.9%",
"card-foreground": "0 0% 98%",
- popover: "240 10% 3.9%",
+ popover: "240 10% 8.9%",
"popover-foreground": "0 0% 98%",
primary: "0 0% 98%",
"primary-foreground": "240 5.9% 10%",
@@ -85,9 +85,9 @@ export const themes = [
dark: {
background: "0 0% 3.9%",
foreground: "0 0% 98%",
- card: "0 0% 3.9%",
+ card: "0 0% 8.9%",
"card-foreground": "0 0% 98%",
- popover: "0 0% 3.9%",
+ popover: "0 0% 8.9%",
"popover-foreground": "0 0% 98%",
primary: "0 0% 98%",
"primary-foreground": "0 0% 9%",
@@ -137,9 +137,9 @@ export const themes = [
dark: {
background: "0 0% 3.9%",
foreground: "0 0% 98%",
- card: "0 0% 3.9%",
+ card: "0 0% 8.9%",
"card-foreground": "0 0% 98%",
- popover: "0 0% 3.9%",
+ popover: "0 0% 8.9%",
"popover-foreground": "0 0% 98%",
primary: "0 72.2% 50.6%",
"primary-foreground": "0 85.7% 97.3%",
@@ -191,7 +191,7 @@ export const themes = [
foreground: "0 0% 95%",
popover: "0 0% 9%",
"popover-foreground": "0 0% 95%",
- card: "24 9.8% 10%",
+ card: "24 9.8% 9%",
"card-foreground": "0 0% 95%",
primary: "346.8 77.2% 49.8%",
"primary-foreground": "355.7 100% 97.3%",
@@ -241,9 +241,9 @@ export const themes = [
dark: {
background: "20 14.3% 4.1%",
foreground: "60 9.1% 97.8%",
- card: "20 14.3% 4.1%",
+ card: "20 14.3% 8.9%",
"card-foreground": "60 9.1% 97.8%",
- popover: "20 14.3% 4.1%",
+ popover: "20 14.3% 8.9%",
"popover-foreground": "60 9.1% 97.8%",
primary: "20.5 90.2% 48.2%",
"primary-foreground": "60 9.1% 97.8%",
@@ -295,7 +295,7 @@ export const themes = [
foreground: "0 0% 95%",
popover: "0 0% 9%",
"popover-foreground": "0 0% 95%",
- card: "24 9.8% 10%",
+ card: "24 9.8% 9%",
"card-foreground": "0 0% 95%",
primary: "142.1 87.6% 63.3%",
"primary-foreground": "144.9 80.4% 10%",
@@ -345,9 +345,9 @@ export const themes = [
dark: {
background: "222.2 84% 4.9%",
foreground: "210 40% 98%",
- card: "222.2 84% 4.9%",
+ card: "222.2 84% 8.9%",
"card-foreground": "210 40% 98%",
- popover: "222.2 84% 4.9%",
+ popover: "222.2 84% 8.9%",
"popover-foreground": "210 40% 98%",
primary: "217.2 91.2% 59.8%",
"primary-foreground": "222.2 47.4% 11.2%",
@@ -449,9 +449,9 @@ export const themes = [
dark: {
background: "224 71.4% 4.1%",
foreground: "210 20% 98%",
- card: "224 71.4% 4.1%",
+ card: "224 71.4% 8.9%",
"card-foreground": "210 20% 98%",
- popover: "224 71.4% 4.1%",
+ popover: "224 71.4% 8.9%",
"popover-foreground": "210 20% 98%",
primary: "263.4 70% 50.4%",
"primary-foreground": "210 20% 98%",