Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Draft] Inbox v1 #97

Merged
merged 45 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
45b291a
Support images
pontusab Apr 22, 2024
82b012d
Convert heic
pontusab Apr 23, 2024
30694a5
wip
pontusab Apr 24, 2024
b6e8c03
Background jobs
pontusab Apr 24, 2024
70d7182
Process document
pontusab Apr 24, 2024
9d4889d
Extractors wip
pontusab Apr 24, 2024
a937344
Add Processors
pontusab Apr 24, 2024
a3abf27
Add Azure
pontusab Apr 24, 2024
f671363
Add Azure
pontusab Apr 24, 2024
5b97e33
Inbox utils
pontusab Apr 25, 2024
2911a51
Workspace
pontusab Apr 26, 2024
29666db
Update description
pontusab Apr 26, 2024
5bc8aca
Fix search
pontusab Apr 26, 2024
6599d20
Remove logging
pontusab Apr 26, 2024
98c1dc7
Add website
pontusab Apr 26, 2024
abe9356
Search
pontusab Apr 26, 2024
b4d7775
Search
pontusab Apr 26, 2024
9b19211
Search
pontusab Apr 27, 2024
05f9547
Wip UI
pontusab Apr 27, 2024
4b2503c
Wip UI
pontusab Apr 27, 2024
6e520f7
Wip UI
pontusab Apr 27, 2024
4e65fac
Wip UI
pontusab Apr 28, 2024
cb29509
Wip UI
pontusab Apr 28, 2024
dee892d
Wip UI
pontusab Apr 28, 2024
0123e58
Wip UI
pontusab Apr 28, 2024
ecef6d1
Wip UI
pontusab Apr 28, 2024
acf593a
Components
pontusab Apr 28, 2024
1e553a6
Delete
pontusab Apr 28, 2024
f46455f
Update description
pontusab Apr 29, 2024
eaa5593
Debug
pontusab Apr 29, 2024
c42d09f
Debug
pontusab Apr 29, 2024
c3dd92b
Debug
pontusab Apr 29, 2024
99a06f9
Debug
pontusab Apr 29, 2024
05d0c8f
Debug
pontusab Apr 29, 2024
a0de887
Lock vercel version
pontusab Apr 29, 2024
3413211
Trigger build
pontusab Apr 29, 2024
cbfc49f
Downgrade next
pontusab Apr 29, 2024
6a878f8
Pin vercel cli
pontusab Apr 29, 2024
9ca6cb6
Pin vercel cli
pontusab Apr 29, 2024
1738b8c
Pin vercel cli
pontusab Apr 29, 2024
3f9102c
Downgrade next
pontusab Apr 29, 2024
3fe813b
Fix select next
pontusab Apr 29, 2024
5b62d10
Fix copy
pontusab Apr 29, 2024
3d33cd2
Fix filter
pontusab Apr 29, 2024
83cde5c
Add tab
pontusab Apr 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -1 +1 @@
## Dashboard
## Dashboard
28 changes: 14 additions & 14 deletions apps/dashboard/package.json
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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;
});
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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