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.

fix: sign in issue

Brad Barbin330010e8dd94
diff --git a/apps/carbon/app/components/Layout/Navigation/IconSidebar.tsx b/apps/carbon/app/components/Layout/Navigation/IconSidebar.tsx
index f7813bb7bb..533bd108c7 100644
--- a/apps/carbon/app/components/Layout/Navigation/IconSidebar.tsx
+++ b/apps/carbon/app/components/Layout/Navigation/IconSidebar.tsx
@@ -103,7 +103,7 @@ const NavigationIconLink = forwardRef<
"hover:bg-secondary active:",
`${
isActive
- ? "dark:bg-primary/10 bg-primary/20 text-primary shadow-sm hover:text-primary hover:bg-primary/20 "
+ ? "dark:bg-primary/10 bg-primary/20 text-primary shadow-sm hover:text-primary hover:bg-primary/20 dark:shadow-inner"
: "hover:text-foreground"
}`,
"group/item",
diff --git a/apps/carbon/app/lib/supabase/client.ts b/apps/carbon/app/lib/supabase/client.ts
index c233c9dc6d..3133e2354d 100644
--- a/apps/carbon/app/lib/supabase/client.ts
+++ b/apps/carbon/app/lib/supabase/client.ts
@@ -54,3 +54,5 @@ export const getSupabaseServiceRole = () => {
return getSupabaseClient(SUPABASE_SERVICE_ROLE);
};
+
+export const supabaseClient = getSupabase();
diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationExplorer.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationExplorer.tsx
index bc8f8c74ba..e202ea1d24 100644
--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationExplorer.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationExplorer.tsx
@@ -56,7 +56,7 @@ const QuotationExplorerItem = (
return (
<Button
leftIcon={<AiOutlinePartition />}
- variant={isActive ? "primary" : "ghost"}
+ variant={isActive ? "active" : "ghost"}
className="flex-1 justify-start"
asChild
>
@@ -75,7 +75,7 @@ const QuotationExplorerItem = (
path.to.newQuoteAssembly(meta.quoteId, meta.quoteLineId, parentId);
return (
<Button
- variant={isActive ? "primary" : "ghost"}
+ variant={isActive ? "active" : "ghost"}
className={cn(
"font-mono w-full justify-between",
!isActive && "text-muted-foreground"
@@ -100,7 +100,7 @@ const QuotationExplorerItem = (
return (
<Button
- variant={isActive ? "primary" : "ghost"}
+ variant={isActive ? "active" : "ghost"}
className="flex-1 justify-between"
asChild
>
@@ -167,7 +167,7 @@ const QuotationExplorerItem = (
path.to.newQuoteOperation(meta.quoteId, meta.quoteLineId, parentId);
return (
<Button
- variant={isActive ? "primary" : "ghost"}
+ variant={isActive ? "active" : "ghost"}
className={cn(
"font-mono w-full justify-between",
!isActive && "text-muted-foreground"
@@ -196,7 +196,7 @@ const QuotationExplorerItem = (
return (
<Button
leftIcon={<LuClock />}
- variant={isActive ? "primary" : "ghost"}
+ variant={isActive ? "active" : "ghost"}
className="flex-1 justify-start"
asChild
>
@@ -213,7 +213,7 @@ const QuotationExplorerItem = (
isActive = pathname === path.to.quoteDetails(id);
return (
<Button
- variant={isActive ? "primary" : "ghost"}
+ variant={isActive ? "active" : "ghost"}
className="flex-1 justify-start"
asChild
>
@@ -340,8 +340,8 @@ const QuotationExplorer = () => {
label: quote.quote.quoteId!,
type: "parent",
children: quote.lines?.map<BillOfMaterialNode>((line) => ({
- id: line.id,
- label: line.description,
+ id: line.id!,
+ label: line.description!,
type: "line",
meta: line,
children:
@@ -351,9 +351,9 @@ const QuotationExplorer = () => {
id: `${line.id}-assemblies`,
label: "Assemblies",
type: "assemblies",
- children: assembliesByLineId[line.id]
+ children: assembliesByLineId[line.id!]
? [
- ...(arrayToTree([...assembliesByLineId[line.id]], {
+ ...(arrayToTree([...assembliesByLineId[line.id!]], {
id: "id",
dataField: null,
}) as BillOfMaterialNode[]),
@@ -368,8 +368,8 @@ const QuotationExplorer = () => {
id: `${line.id}-operations`,
label: "Operations",
type: "operations",
- children: operationsByLineId[line.id]
- ? [...operationsByLineId[line.id]]?.filter(
+ children: operationsByLineId[line.id!]
+ ? [...operationsByLineId[line.id!]]?.filter(
(operation) => operation.parentId === undefined
)
: ([] as BillOfMaterialNode[]),
@@ -589,7 +589,7 @@ const QuotationSearch = ({ onSelect }: QuotationSearchProps) => {
const linesById = useMemo(
() =>
quote?.lines.reduce<Record<string, QuotationLine>>((acc, line) => {
- acc[line.id] = line;
+ acc[line.id!] = line;
return acc;
}, {}),
[quote?.lines]
@@ -640,8 +640,8 @@ const QuotationSearch = ({ onSelect }: QuotationSearchProps) => {
value={`lines ${line.partId} ${line.description}`}
key={line.id}
onSelect={() => {
- onSelect(line.id);
- navigate(path.to.quoteLine(line.quoteId, line.id));
+ onSelect(line.id!);
+ navigate(path.to.quoteLine(line.quoteId!, line.id!));
setOpen(false);
}}
>
@@ -656,7 +656,7 @@ const QuotationSearch = ({ onSelect }: QuotationSearchProps) => {
className={cn(
"ml-auto h-4 w-4",
`${pathname}${search}` ===
- path.to.quoteLine(line.quoteId, line.id)
+ path.to.quoteLine(line.quoteId!, line.id!)
? "opacity-100"
: "opacity-0"
)}
diff --git a/apps/carbon/app/routes/_public+/callback.tsx b/apps/carbon/app/routes/_public+/callback.tsx
index 6a88b3aa1f..b4d7efe5fc 100644
--- a/apps/carbon/app/routes/_public+/callback.tsx
+++ b/apps/carbon/app/routes/_public+/callback.tsx
@@ -1,9 +1,9 @@
import { validator } from "@carbon/remix-validated-form";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
import { json, redirect } from "@remix-run/node";
-import { useFetcher } from "@remix-run/react";
-import { useEffect, useMemo } from "react";
-import { getSupabase } from "~/lib/supabase";
+import { useActionData, useFetcher } from "@remix-run/react";
+import { useEffect } from "react";
+import { supabaseClient } from "~/lib/supabase/client";
import { getUserByEmail } from "~/modules/users/users.server";
import { refreshAccessToken } from "~/services/auth";
import { callbackValidator } from "~/services/auth/auth.models";
@@ -42,7 +42,7 @@ export async function action({ request }: ActionFunctionArgs): FormActionData {
const { refreshToken } = validation.data;
const authSession = await refreshAccessToken(refreshToken);
if (!authSession) {
- throw redirect(
+ return redirect(
path.to.root,
await flash(request, error(authSession, "Invalid refresh token"))
);
@@ -66,13 +66,13 @@ export async function action({ request }: ActionFunctionArgs): FormActionData {
}
export default function AuthCallback() {
+ const result = useActionData<typeof action>();
const fetcher = useFetcher();
- const supabase = useMemo(() => getSupabase(), []);
useEffect(() => {
const {
data: { subscription },
- } = supabase.auth.onAuthStateChange((event, supabaseSession) => {
+ } = supabaseClient.auth.onAuthStateChange((event, supabaseSession) => {
if (event === "SIGNED_IN") {
// supabase sdk has ability to read url fragment that contains your token after third party provider redirects you here
// this fragment url looks like https://.....#access_token=evxxxxxxxx&refresh_token=xxxxxx, and it's not readable server-side (Oauth security)
@@ -86,16 +86,18 @@ export default function AuthCallback() {
if (!refreshToken) return;
const formData = new FormData();
+
formData.append("refreshToken", refreshToken);
+
fetcher.submit(formData, { method: "post" });
}
});
return () => {
- // to prevent a memory leak
+ // prevent memory leak. Listener stays alive 👨‍🎤
subscription.unsubscribe();
};
- }, [fetcher, supabase.auth]);
+ }, [fetcher]);
- return null;
+ return <pre>{JSON.stringify(result, null, 2)}</pre>;
}
diff --git a/apps/carbon/app/services/session.server.ts b/apps/carbon/app/services/session.server.ts
index 139615f484..fc1f55651e 100644
--- a/apps/carbon/app/services/session.server.ts
+++ b/apps/carbon/app/services/session.server.ts
@@ -68,7 +68,7 @@ export async function commitAuthSession(
export async function destroyAuthSession(request: Request) {
const session = await getSession(request);
- throw redirect(path.to.login, {
+ return redirect(path.to.login, {
headers: {
"Set-Cookie": await sessionStorage.destroySession(session),
},
diff --git a/packages/react/src/Button.tsx b/packages/react/src/Button.tsx
index 6f58f4c0c1..82792c6add 100644
--- a/packages/react/src/Button.tsx
+++ b/packages/react/src/Button.tsx
@@ -15,7 +15,7 @@ export const buttonVariants = cva(
primary:
"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm",
active:
- "dark:bg-primary/10 bg-primary/20 text-primary hover:bg-primary/20 shadow-sm",
+ "dark:bg-primary/10 bg-primary/20 text-primary hover:bg-primary/20 dark:shadow-inner",
secondary:
"border border-input bg-background hover:bg-accent hover:text-accent-foreground",
solid: "bg-primary/25 text-accent-foreground hover:bg-primary/35",