From 703e119cf7364162845bdf43a4386212e9036761 Mon Sep 17 00:00:00 2001 From: Pontus Abrahamsson Date: Fri, 6 Sep 2024 12:04:15 +0200 Subject: [PATCH 1/2] fixes --- .../src/actions/ai/chat/tools/burn-rate.tsx | 4 +- .../actions/ai/chat/tools/ui/burn-rate-ui.tsx | 6 +-- apps/dashboard/src/actions/schema.ts | 4 +- .../src/actions/verify-otp-action.ts | 21 +++------ .../src/components/feedback-form.tsx | 2 +- .../src/components/notification-center.tsx | 8 ++-- apps/dashboard/src/components/otp-sign-in.tsx | 47 +++++++------------ .../src/components/tables/vault/tag.tsx | 14 +++++- .../src/components/widgets/vault/vault.tsx | 2 +- apps/dashboard/src/hooks/use-notifications.ts | 12 ++--- apps/dashboard/src/locales/en.ts | 6 +-- packages/ui/src/components/input-otp.tsx | 2 +- 12 files changed, 57 insertions(+), 71 deletions(-) diff --git a/apps/dashboard/src/actions/ai/chat/tools/burn-rate.tsx b/apps/dashboard/src/actions/ai/chat/tools/burn-rate.tsx index baefd8b28a..bbef6a9d65 100644 --- a/apps/dashboard/src/actions/ai/chat/tools/burn-rate.tsx +++ b/apps/dashboard/src/actions/ai/chat/tools/burn-rate.tsx @@ -48,10 +48,10 @@ export function getBurnRateTool({ aiState, currency, dateFrom, dateTo }: Args) { }), ]); - const avarageBurnRate = calculateAvgBurnRate(burnRateData); + const averageBurnRate = calculateAvgBurnRate(burnRateData); const props = { - avarageBurnRate, + averageBurnRate, currency, startDate, endDate, diff --git a/apps/dashboard/src/actions/ai/chat/tools/ui/burn-rate-ui.tsx b/apps/dashboard/src/actions/ai/chat/tools/ui/burn-rate-ui.tsx index 00395ded88..e522450477 100644 --- a/apps/dashboard/src/actions/ai/chat/tools/ui/burn-rate-ui.tsx +++ b/apps/dashboard/src/actions/ai/chat/tools/ui/burn-rate-ui.tsx @@ -6,13 +6,13 @@ import { FormatAmount } from "@/components/format-amount"; import { addMonths, format } from "date-fns"; type Props = { - avarageBurnRate: number; + averageBurnRate: number; currency: string; data: any; months: number; }; -export function BurnRateUI({ avarageBurnRate, currency, months, data }: Props) { +export function BurnRateUI({ averageBurnRate, currency, months, data }: Props) { if (!data?.length) { return ( @@ -24,7 +24,7 @@ export function BurnRateUI({ avarageBurnRate, currency, months, data }: Props) {

Based on your historical data, your avarage burn rate is{" "} - per month. + per month. Your expected runway is {months} months, ending in{" "} {format(addMonths(new Date(), months), "PP")}.

diff --git a/apps/dashboard/src/actions/schema.ts b/apps/dashboard/src/actions/schema.ts index f17b530733..bfd0910a4d 100644 --- a/apps/dashboard/src/actions/schema.ts +++ b/apps/dashboard/src/actions/schema.ts @@ -372,10 +372,8 @@ export const setupUserSchema = z.object({ }); export const verifyOtpSchema = z.object({ - type: z.enum(["phone", "email"]), token: z.string(), - phone: z.string().optional(), - email: z.string().optional(), + email: z.string(), }); export const searchSchema = z.object({ diff --git a/apps/dashboard/src/actions/verify-otp-action.ts b/apps/dashboard/src/actions/verify-otp-action.ts index e35c177f13..9027dad51d 100644 --- a/apps/dashboard/src/actions/verify-otp-action.ts +++ b/apps/dashboard/src/actions/verify-otp-action.ts @@ -11,23 +11,14 @@ import { verifyOtpSchema } from "./schema"; export const verifyOtpAction = actionClient .schema(verifyOtpSchema) - .action(async ({ parsedInput: { type, email, token, phone } }) => { + .action(async ({ parsedInput: { email, token } }) => { const supabase = createClient(); - const options = - type === "email" - ? { - email, - token, - type: "email", - } - : { - phone, - token, - type: "sms", - }; - - await supabase.auth.verifyOtp(options); + await supabase.auth.verifyOtp({ + email, + token, + type: "email", + }); cookies().set(Cookies.PreferredSignInProvider, "otp", { expires: addYears(new Date(), 1), diff --git a/apps/dashboard/src/components/feedback-form.tsx b/apps/dashboard/src/components/feedback-form.tsx index 3d23dd0910..dfb275f8d1 100644 --- a/apps/dashboard/src/components/feedback-form.tsx +++ b/apps/dashboard/src/components/feedback-form.tsx @@ -19,7 +19,7 @@ export function FeedbackForm() { return ( - + ); @@ -107,12 +94,12 @@ export function OTPSignIn({ className }: Props) {
( - {t(`tags.${name}`)} +
+ + {t(`tags.${name}`)} +
); } diff --git a/apps/dashboard/src/components/widgets/vault/vault.tsx b/apps/dashboard/src/components/widgets/vault/vault.tsx index ac30b4d2b7..7e70f357a4 100644 --- a/apps/dashboard/src/components/widgets/vault/vault.tsx +++ b/apps/dashboard/src/components/widgets/vault/vault.tsx @@ -33,7 +33,7 @@ export function Vault({ files }: Props) { {file.name}
-
+
diff --git a/apps/dashboard/src/hooks/use-notifications.ts b/apps/dashboard/src/hooks/use-notifications.ts index f5d7ead7e0..2c1d002404 100644 --- a/apps/dashboard/src/hooks/use-notifications.ts +++ b/apps/dashboard/src/hooks/use-notifications.ts @@ -20,7 +20,7 @@ export function useNotifications() { ...notification, read: true, }; - }) + }), ); headlessService.markAllMessagesAsRead({ @@ -44,7 +44,7 @@ export function useNotifications() { } return notification; - }) + }), ); headlessService.markNotificationsAsRead({ @@ -77,7 +77,7 @@ export function useNotifications() { prevNotifications.map((notification) => ({ ...notification, seen: true, - })) + })), ); headlessService.markAllMessagesAsSeen({ listener: () => {}, @@ -94,7 +94,7 @@ export function useNotifications() { const { data: userData } = await getUserQuery( supabase, - session?.user?.id + session?.user?.id, ); if (userData) { @@ -141,8 +141,8 @@ export function useNotifications() { markAllMessagesAsRead, markMessageAsRead, markAllMessagesAsSeen, - hasUnseenNotificaitons: notifications.some( - (notification) => !notification.seen + hasUnseenNotifications: notifications.some( + (notification) => !notification.seen, ), notifications, }; diff --git a/apps/dashboard/src/locales/en.ts b/apps/dashboard/src/locales/en.ts index 2ac8cd0724..260a054924 100644 --- a/apps/dashboard/src/locales/en.ts +++ b/apps/dashboard/src/locales/en.ts @@ -96,7 +96,7 @@ export default { budget_reports: "Budget Reports", audit_reports: "Audit Reports", tax_returns: "Tax Returns", - invoices_and_receipts: "Invoices and Receipts", + invoices_and_receipts: "Invoices & Receipts", employee_handbook: "Employee Handbook", payroll_records: "Payroll Records", performance_reviews: "Performance Reviews", @@ -141,12 +141,12 @@ export default { lab_notebooks: "Lab Notebooks", experiment_results: "Experiment Results", product_design_documents: "Product Design Documents", - prototypes_and_models: "Prototypes and Models", + prototypes_and_models: "Prototypes & Models", testing_reports: "Testing Reports", newsletters: "Newsletters", email_correspondence: "Email Correspondence", support_tickets: "Support Tickets", - faqs_and_knowledge: "FAQs and Knowledge", + faqs_and_knowledge: "FAQs & Knowledge", user_guides: "User Guides", warranty_information: "Warranty Information", swot_analysis: "SWOT Analysis", diff --git a/packages/ui/src/components/input-otp.tsx b/packages/ui/src/components/input-otp.tsx index 08202215a4..2eb6581372 100644 --- a/packages/ui/src/components/input-otp.tsx +++ b/packages/ui/src/components/input-otp.tsx @@ -35,7 +35,7 @@ const InputOTPSlot = React.forwardRef< className={cn( "relative flex h-16 w-16 items-center justify-center border-y border-r border-input text-2xl transition-all first:rounded-l-md first:border-l last:rounded-r-md", isActive && "z-10 ring-1 ring-ring", - className + className, )} {...props} > From b24631b44f66a62811622e75e497f0485490cbfe Mon Sep 17 00:00:00 2001 From: Pontus Abrahamsson Date: Fri, 6 Sep 2024 12:51:29 +0200 Subject: [PATCH 2/2] Make file name unique --- apps/dashboard/src/app/api/webhook/inbox/route.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/dashboard/src/app/api/webhook/inbox/route.ts b/apps/dashboard/src/app/api/webhook/inbox/route.ts index 87748fe248..ca20925f62 100644 --- a/apps/dashboard/src/app/api/webhook/inbox/route.ts +++ b/apps/dashboard/src/app/api/webhook/inbox/route.ts @@ -164,7 +164,12 @@ export async function POST(req: Request) { const { content, mimeType, size, fileName, name } = await prepareDocument(attachment); - const uniqueFileName = `${nanoid(4)}_${fileName}`; + // Add a random 4 character string to the end of the file name + // to make it unique before the extension + const uniqueFileName = fileName.replace( + /(\.[^.]+)$/, + (ext) => `_${nanoid(4)}${ext}`, + ); const { data } = await supabase.storage .from("vault")