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 internal notes to salesRfq and quote headers

Rob Carrington169cee0a0bdd
diff --git a/apps/carbon/app/routes/x+/quote+/$quoteId.details.tsx b/apps/carbon/app/routes/x+/quote+/$quoteId.details.tsx
index 6ff8f71491..8f18b134b6 100644
--- a/apps/carbon/app/routes/x+/quote+/$quoteId.details.tsx
+++ b/apps/carbon/app/routes/x+/quote+/$quoteId.details.tsx
@@ -6,6 +6,7 @@ import {
CardTitle,
Editor,
generateHTML,
+ HStack,
toast,
useThrottle,
} from "@carbon/react";
@@ -135,7 +136,18 @@ const QuoteNotes = ({ quote }: { quote: Quotation }) => {
await supabase
?.from("quote")
.update({
- notes: content,
+ externalNotes: content,
+ updatedAt: today(getLocalTimeZone()).toString(),
+ updatedBy: userId,
+ })
+ .eq("id", quote.id!);
+ }, 2500);
+
+ const onUpdateInternalNotes = useThrottle(async (content: JSONContent) => {
+ await supabase
+ ?.from("quote")
+ .update({
+ internalNotes: content,
updatedAt: today(getLocalTimeZone()).toString(),
updatedBy: userId,
})
@@ -143,26 +155,49 @@ const QuoteNotes = ({ quote }: { quote: Quotation }) => {
}, 2500);
return (
- <Card>
- <CardHeader>
- <CardTitle>External Notes</CardTitle>
- </CardHeader>
- <CardContent>
- {permissions.can("update", "sales") ? (
- <Editor
- initialValue={(quote.notes ?? {}) as JSONContent}
- onUpload={onUploadImage}
- onChange={onUpdateExternalNotes}
- />
- ) : (
- <div
- className="prose dark:prose-invert"
- dangerouslySetInnerHTML={{
- __html: generateHTML(quote.notes as JSONContent),
- }}
- />
- )}
- </CardContent>
- </Card>
+ <HStack className="w-full justify-between items-stretch">
+ <Card>
+ <CardHeader>
+ <CardTitle>External Notes</CardTitle>
+ </CardHeader>
+ <CardContent>
+ {permissions.can("update", "sales") ? (
+ <Editor
+ initialValue={(quote.externalNotes ?? {}) as JSONContent}
+ onUpload={onUploadImage}
+ onChange={onUpdateExternalNotes}
+ />
+ ) : (
+ <div
+ className="prose dark:prose-invert"
+ dangerouslySetInnerHTML={{
+ __html: generateHTML(quote.externalNotes as JSONContent),
+ }}
+ />
+ )}
+ </CardContent>
+ </Card>
+ <Card>
+ <CardHeader>
+ <CardTitle>Internal Notes</CardTitle>
+ </CardHeader>
+ <CardContent>
+ {permissions.can("update", "sales") ? (
+ <Editor
+ initialValue={(quote.internalNotes ?? {}) as JSONContent}
+ onUpload={onUploadImage}
+ onChange={onUpdateInternalNotes}
+ />
+ ) : (
+ <div
+ className="prose dark:prose-invert"
+ dangerouslySetInnerHTML={{
+ __html: generateHTML(quote.internalNotes as JSONContent),
+ }}
+ />
+ )}
+ </CardContent>
+ </Card>
+ </HStack>
);
};
diff --git a/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.details.tsx b/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.details.tsx
index 4d14e20f00..ab918c3b14 100644
--- a/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.details.tsx
+++ b/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.details.tsx
@@ -6,6 +6,7 @@ import {
CardTitle,
Editor,
generateHTML,
+ HStack,
toast,
useThrottle,
VStack,
@@ -144,7 +145,6 @@ const SalesRFQNotes = ({ salesRfq }: { salesRfq: SalesRFQ }) => {
};
const onUpdateExternalNotes = useThrottle(async (content: JSONContent) => {
- console.log({ content });
await supabase
?.from("salesRfq")
.update({
@@ -155,27 +155,61 @@ const SalesRFQNotes = ({ salesRfq }: { salesRfq: SalesRFQ }) => {
.eq("id", salesRfq.id!);
}, 2500);
+ const onUpdateInternalNotes = useThrottle(async (content: JSONContent) => {
+ await supabase
+ ?.from("salesRfq")
+ .update({
+ internalNotes: content,
+ updatedAt: today(getLocalTimeZone()).toString(),
+ updatedBy: userId,
+ })
+ .eq("id", salesRfq.id!);
+ }, 2500);
+
return (
- <Card>
- <CardHeader>
- <CardTitle>External Notes</CardTitle>
- </CardHeader>
- <CardContent>
- {permissions.can("update", "sales") ? (
- <Editor
- initialValue={(salesRfq.notes ?? {}) as JSONContent}
- onUpload={onUploadImage}
- onChange={onUpdateExternalNotes}
- />
- ) : (
- <div
- className="prose dark:prose-invert"
- dangerouslySetInnerHTML={{
- __html: generateHTML(salesRfq.notes as JSONContent),
- }}
- />
- )}
- </CardContent>
- </Card>
+ <HStack className="w-full justify-between items-stretch">
+ <Card>
+ <CardHeader>
+ <CardTitle>External Notes</CardTitle>
+ </CardHeader>
+ <CardContent>
+ {permissions.can("update", "sales") ? (
+ <Editor
+ initialValue={(salesRfq.externalNotes ?? {}) as JSONContent}
+ onUpload={onUploadImage}
+ onChange={onUpdateExternalNotes}
+ />
+ ) : (
+ <div
+ className="prose dark:prose-invert"
+ dangerouslySetInnerHTML={{
+ __html: generateHTML(salesRfq.externalNotes as JSONContent),
+ }}
+ />
+ )}
+ </CardContent>
+ </Card>
+ <Card>
+ <CardHeader>
+ <CardTitle>Internal Notes</CardTitle>
+ </CardHeader>
+ <CardContent>
+ {permissions.can("update", "sales") ? (
+ <Editor
+ initialValue={(salesRfq.internalNotes ?? {}) as JSONContent}
+ onUpload={onUploadImage}
+ onChange={onUpdateInternalNotes}
+ />
+ ) : (
+ <div
+ className="prose dark:prose-invert"
+ dangerouslySetInnerHTML={{
+ __html: generateHTML(salesRfq.internalNotes as JSONContent),
+ }}
+ />
+ )}
+ </CardContent>
+ </Card>
+ </HStack>
);
};
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index e9b64d6ed2..5a0250ac81 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -15452,7 +15452,7 @@ export type Database = {
expirationDate: string | null
externalNotes: Json | null
id: string
- internalNotes: string | null
+ internalNotes: Json | null
locationId: string | null
revisionId: number
rfqDate: string
@@ -15475,7 +15475,7 @@ export type Database = {
expirationDate?: string | null
externalNotes?: Json | null
id?: string
- internalNotes?: string | null
+ internalNotes?: Json | null
locationId?: string | null
revisionId?: number
rfqDate: string
@@ -15498,7 +15498,7 @@ export type Database = {
expirationDate?: string | null
externalNotes?: Json | null
id?: string
- internalNotes?: string | null
+ internalNotes?: Json | null
locationId?: string | null
revisionId?: number
rfqDate?: string
@@ -25038,7 +25038,7 @@ export type Database = {
externalNotes: Json | null
favorite: boolean | null
id: string | null
- internalNotes: string | null
+ internalNotes: Json | null
locationId: string | null
locationName: string | null
quoteId: string | null
diff --git a/packages/database/supabase/functions/convert/index.ts b/packages/database/supabase/functions/convert/index.ts
index 8049f53779..f993fcecc2 100644
--- a/packages/database/supabase/functions/convert/index.ts
+++ b/packages/database/supabase/functions/convert/index.ts
@@ -86,7 +86,8 @@ serve(async (req: Request) => {
expirationDate: salesRfq.data?.expirationDate,
salesPersonId: salesRfq.data?.createdBy,
status: "Draft",
- notes: salesRfq.data?.notes,
+ externalNotes: salesRfq.data?.externalNotes,
+ internalNotes: salesRfq.data?.internalNotes,
companyId,
createdBy: userId,
},
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index e9b64d6ed2..5a0250ac81 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -15452,7 +15452,7 @@ export type Database = {
expirationDate: string | null
externalNotes: Json | null
id: string
- internalNotes: string | null
+ internalNotes: Json | null
locationId: string | null
revisionId: number
rfqDate: string
@@ -15475,7 +15475,7 @@ export type Database = {
expirationDate?: string | null
externalNotes?: Json | null
id?: string
- internalNotes?: string | null
+ internalNotes?: Json | null
locationId?: string | null
revisionId?: number
rfqDate: string
@@ -15498,7 +15498,7 @@ export type Database = {
expirationDate?: string | null
externalNotes?: Json | null
id?: string
- internalNotes?: string | null
+ internalNotes?: Json | null
locationId?: string | null
revisionId?: number
rfqDate?: string
@@ -25038,7 +25038,7 @@ export type Database = {
externalNotes: Json | null
favorite: boolean | null
id: string | null
- internalNotes: string | null
+ internalNotes: Json | null
locationId: string | null
locationName: string | null
quoteId: string | null
diff --git a/packages/database/supabase/migrations/20240823012655_rfq-quote-internal-notes.sql b/packages/database/supabase/migrations/20240823012655_rfq-quote-internal-notes.sql
index f390b9489c..8269df768e 100644
--- a/packages/database/supabase/migrations/20240823012655_rfq-quote-internal-notes.sql
+++ b/packages/database/supabase/migrations/20240823012655_rfq-quote-internal-notes.sql
@@ -2,7 +2,9 @@ DROP VIEW "salesRfqs";
ALTER TABLE "salesRfq"
DROP COLUMN "notes",
- ADD COLUMN "externalNotes" JSON DEFAULT '{}';
+ DROP Column "internalNotes",
+ ADD COLUMN "externalNotes" JSON DEFAULT '{}',
+ ADD COLUMN "internalNotes" JSON DEFAULT '{}';
CREATE OR REPLACE VIEW "salesRfqs" WITH(SECURITY_INVOKER=true) AS