Skip to content

Commit

Permalink
Merge pull request #97 from midday-ai/feature/inbox-v1
Browse files Browse the repository at this point in the history
[Draft] Inbox v1
  • Loading branch information
pontusab committed Apr 29, 2024
2 parents 5e6fab4 + 83cde5c commit 36de386
Show file tree
Hide file tree
Showing 95 changed files with 3,409 additions and 2,137 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Expand Up @@ -51,4 +51,8 @@ packages/email/public

# Storybook
storybook-static
tailwind.css
tailwind.css

# Supabase
.branches
.temp
File renamed without changes.
4 changes: 2 additions & 2 deletions apps/dashboard/.env-example
Expand Up @@ -20,8 +20,8 @@ API_ROUTE_SECRET=

# Base64 encoded json (project_id, private_key, client_email)
GOOGLE_APPLICATION_CREDENTIALS=
GOOGLE_APPLICATION_PROCESSOR_ID=

GOOGLE_APPLICATION_INVOICE_PROCESSOR_ID=
GOOGLE_APPLICATION_EXPENSE_PROCESSOR_ID=
# Teller (Base 64 encoded certificate)
TELLER_CERTIFICATE=
TELLER_CERTIFICATE_PRIVATE_KEY=
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/README.md
@@ -1 +1 @@
## Dashboard
## Dashboard
28 changes: 14 additions & 14 deletions apps/dashboard/package.json
Expand Up @@ -17,6 +17,7 @@
"@date-fns/utc": "^1.2.0",
"@hookform/resolvers": "^3.3.4",
"@midday/events": "workspace:*",
"@midday/inbox": "workspace:*",
"@midday/jobs": "workspace:*",
"@midday/kv": "workspace:*",
"@midday/location": "workspace:*",
Expand All @@ -38,48 +39,47 @@
"@uidotdev/usehooks": "^2.4.1",
"@vercel/analytics": "^1.2.2",
"@vercel/speed-insights": "^1.0.10",
"@zip.js/zip.js": "2.7.41",
"ai": "^3.0.24",
"base64-arraybuffer": "^1.0.2",
"@zip.js/zip.js": "2.7.43",
"ai": "^3.0.35",
"change-case": "^5.4.4",
"currency-symbol-map": "^5.1.0",
"dub": "^0.24.1",
"dub": "^0.25.2",
"framer-motion": "^11.1.7",
"geist": "^1.3.0",
"headless-currency-input": "^1.1.0",
"loops": "1.0.1",
"lottie-react": "^2.4.0",
"ms": "^2.1.3",
"next": "14.2.2",
"next": "14.2.1",
"next-international": "1.2.4",
"next-safe-action": "6.2.0",
"next-themes": "^0.3.0",
"nuqs": "^1.17.1",
"openai": "^4.38.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"openai": "^4.38.5",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-dropzone": "^14.2.3",
"react-hook-form": "^7.51.3",
"react-hotkeys-hook": "^4.5.0",
"react-intersection-observer": "^9.8.2",
"react-intersection-observer": "^9.10.0",
"react-pdf": "^7.7.1",
"react-plaid-link": "^3.5.1",
"recharts": "^2.12.5",
"recharts": "^2.12.6",
"resend": "^3.2.0",
"sharp": "^0.33.3",
"teller-connect-react": "^0.1.0",
"tus-js-client": "^4.1.0",
"use-long-press": "^3.2.0",
"zod": "^3.22.5",
"zod": "^3.23.4",
"zustand": "^4.5.2"
},
"devDependencies": {
"@midday/tsconfig": "workspace:*",
"@t3-oss/env-nextjs": "^0.9.2",
"@t3-oss/env-nextjs": "^0.10.1",
"@todesktop/tailwind-variants": "^1.0.1",
"@types/node": "^20.12.7",
"@types/react": "^18.2.79",
"@types/react-dom": "^18.2.25",
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.0",
"typescript": "^5.4.5"
}
}
1 change: 0 additions & 1 deletion apps/dashboard/src/actions/inbox/filter.ts
Expand Up @@ -3,7 +3,6 @@
import { action } from "@/actions/safe-action";
import { inboxFilter } from "@/actions/schema";
import { Cookies } from "@/utils/constants";

import { cookies } from "next/headers";

export const changeInboxFilterAction = action(inboxFilter, async (status) => {
Expand Down
18 changes: 18 additions & 0 deletions apps/dashboard/src/actions/inbox/order.ts
@@ -0,0 +1,18 @@
"use server";

import { action } from "@/actions/safe-action";
import { inboxOrder } from "@/actions/schema";
import { Cookies } from "@/utils/constants";
import { revalidatePath } from "next/cache";
import { cookies } from "next/headers";

export const inboxOrderAction = action(inboxOrder, async (ascending) => {
cookies().set({
name: Cookies.InboxOrder,
value: ascending.toString(),
});

revalidatePath("/inbox");

return ascending;
});
1 change: 1 addition & 0 deletions apps/dashboard/src/actions/inbox/update.ts
Expand Up @@ -11,6 +11,7 @@ export const updateInboxAction = action(updateInboxSchema, async (params) => {
const user = await getUser();
const teamId = user?.data?.team_id;
const supabase = createClient();

const { data: inboxData } = await updateInboxById(supabase, {
...params,
teamId,
Expand Down
17 changes: 12 additions & 5 deletions apps/dashboard/src/actions/schema.ts
Expand Up @@ -21,7 +21,7 @@ export const sendSupportSchema = z.object({
export const updateTeamSchema = z.object({
name: z.string().min(2).max(32).optional(),
email: z.string().email().optional(),
inbox_email: z.string().email().optional(),
inbox_email: z.string().email().optional().nullable(),
logo_url: z.string().url().optional(),
revalidatePath: z.string().optional(),
});
Expand Down Expand Up @@ -235,13 +235,11 @@ export const declineInviteSchema = z.object({
revalidatePath: z.string().optional(),
});

export const inboxFilter = z.enum(["all", "completed", "archived", "deleted"]);
export const inboxFilter = z.enum(["done", "todo", "all"]);

export const updateInboxSchema = z.object({
id: z.string(),
read: z.boolean().optional(),
trash: z.boolean().optional(),
archived: z.boolean().optional(),
status: z.enum(["deleted", "pending"]).optional(),
transaction_id: z.string().nullable().optional(),
});

Expand Down Expand Up @@ -329,3 +327,12 @@ export const verifyOtpSchema = z.object({
phone: z.string().optional(),
email: z.string().optional(),
});

export const searchSchema = z.object({
query: z.string().min(1),
type: z.enum(["inbox"]),
limit: z.number().optional(),
threshold: z.number().optional(),
});

export const inboxOrder = z.boolean();
33 changes: 33 additions & 0 deletions apps/dashboard/src/actions/search-action.ts
@@ -0,0 +1,33 @@
"use server";

import { getUser } from "@midday/supabase/cached-queries";
import { action } from "./safe-action";
import { searchSchema } from "./schema";

export const searchAction = action(searchSchema, async (params) => {
const user = await getUser();

const { query, type, limit = 10, threshold } = params;

const res = await fetch(
`${process.env.NEXT_PUBLIC_SUPABASE_URL}/functions/v1/search`,
{
cache: "no-store",
method: "POST",
headers: {
authorization: `Bearer ${process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY}`,
},
body: JSON.stringify({
type,
limit,
threshold,
search: query,
team_id: user?.data?.team_id,
}),
}
);

const { data } = await res.json();

return data;
});
@@ -1,18 +1,23 @@
import { Inbox } from "@/components/inbox";
import { InboxViewSkeleton } from "@/components/inbox-view";
import { Metadata } from "next";
import { InboxViewSkeleton } from "@/components/inbox-skeleton";
import { Cookies } from "@/utils/constants";
import type { Metadata } from "next";
import { cookies } from "next/headers";
import { Suspense } from "react";

export const metadata: Metadata = {
title: "Inbox | Midday",
};

export default function InboxPage({ searchParams }) {
export default async function InboxPage({ searchParams }) {
const ascending =
cookies().get(Cookies.InboxOrder)?.value === "true" ?? false;

return (
<div className="flex-col flex">
<Suspense fallback={<InboxViewSkeleton />}>
<Inbox selectedId={searchParams?.id} />
</Suspense>
</div>
<Suspense
fallback={<InboxViewSkeleton key={ascending.toString()} ascending />}
>
<Inbox ascending={ascending} query={searchParams?.q} />
</Suspense>
);
}
2 changes: 1 addition & 1 deletion apps/dashboard/src/app/api/webhook/inbox/match/route.ts
Expand Up @@ -47,7 +47,7 @@ export async function POST(req: Request) {
.is("transaction_id", null);

// NOTE: If we match more than one inbox record we can't be sure of a match
if (inboxData.length === 1) {
if (inboxData && inboxData.length === 1) {
const inbox = inboxData.at(0);

const { data: attachmentData } = await supabase
Expand Down

0 comments on commit 36de386

Please sign in to comment.