Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Nov 19, 2023
1 parent aa99deb commit 9d37379
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 81 deletions.
24 changes: 24 additions & 0 deletions apps/dashboard/src/actions/export-transactions-action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use server";

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

export const exportTransactionsAction = action(
exportTransactionsSchema,
async ({ from, to }) => {
const user = await getUser();

const event = await client.sendEvent({
name: "transactions.export",
payload: {
from,
to,
teamId: user.data.team_id,
},
});

console.log(event);
}
);
7 changes: 6 additions & 1 deletion apps/dashboard/src/actions/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ export const createAttachmentsSchema = z.array(
size: z.number(),
transaction_id: z.string(),
type: z.string(),
}),
})
);

export const deleteAttachmentSchema = z.string();

export const exportTransactionsSchema = z.object({
from: z.string(),
to: z.string(),
});
77 changes: 0 additions & 77 deletions apps/dashboard/src/app/[locale]/@dashboard/(root)/apps/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,83 +6,6 @@ export const metadata: Metadata = {
};

const apps = [
{
id: "linear",
name: "Linear",
description:
"Our integration with Linear from Midday is a powerful collaboration tool that seamlessly connects Linear, a popular project management and issue tracking platform, with Midday. Midday will create tasks in Linear about everything related to your financial tasks.",
logo: (
<svg
width="60"
height="60"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<g clipPath="url(#a)">
<path
d="M.735 36.914c-.133-.57.545-.928.958-.514l21.908 21.907c.413.413.054 1.091-.515.958C12.031 56.67 3.33 47.969.736 36.914Zm-.734-8.78c-.01.17.053.335.174.456L31.41 59.825c.12.12.287.185.456.174a30.042 30.042 0 0 0 4.178-.556.583.583 0 0 0 .287-.989L1.546 23.67a.583.583 0 0 0-.99.287 30.04 30.04 0 0 0-.555 4.177Zm2.526-10.31a.593.593 0 0 0 .124.66l38.866 38.865a.593.593 0 0 0 .66.124 29.941 29.941 0 0 0 3.111-1.61.589.589 0 0 0 .11-.924L5.061 14.602a.589.589 0 0 0-.924.11 29.949 29.949 0 0 0-1.61 3.111Zm5.068-6.98a.591.591 0 0 1-.026-.812C13.068 3.876 21.067 0 29.97 0 46.556 0 60 13.444 60 30.029c0 8.904-3.876 16.903-10.032 22.402a.592.592 0 0 1-.813-.026l-41.56-41.56Z"
fill="#fff"
/>
</g>
<defs>
<clipPath id="a">
<path fill="#fff" d="M0 0h60v60H0z" />
</clipPath>
</defs>
</svg>
),
},
{
id: "notion",
name: "Notion",
description:
"Our Integration with Notion from Midday is a game-changer for teams seeking a seamless connection between project management and collaborative note-taking. With this integration, you can effortlessly link your Notion pages and databases to your Midday workspace.",
logo: (
<svg
width="60"
height="60"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<g clipPath="url(#a)">
<path
d="M3.61 2.588 36.81.136c4.078-.35 5.126-.114 7.69 1.75l10.598 7.466c1.748 1.284 2.33 1.633 2.33 3.031V53.33c0 2.566-.932 4.084-4.194 4.316L14.68 59.98c-2.448.116-3.614-.234-4.896-1.868L1.98 47.964C.58 46.096 0 44.698 0 43.064V6.668C0 4.57.932 2.82 3.61 2.588Z"
fill="#101010"
/>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M36.81.136 3.61 2.588C.932 2.82 0 4.57 0 6.668v36.396c0 1.634.58 3.032 1.98 4.9l7.804 10.148c1.282 1.634 2.448 1.984 4.896 1.868l38.554-2.334c3.26-.233 4.194-1.75 4.194-4.316V12.384c0-1.326-.523-1.708-2.065-2.84L44.5 1.886c-2.564-1.864-3.612-2.1-7.69-1.75ZM15.552 11.714c-3.148.212-3.862.26-5.65-1.194L5.356 6.904c-.462-.468-.23-1.052.934-1.168l31.916-2.332c2.68-.234 4.076.7 5.124 1.516l5.474 3.966c.234.118.816.816.116.816l-32.96 1.984-.408.028Zm-3.67 41.266V18.22c0-1.518.466-2.218 1.862-2.336L51.6 13.668c1.284-.116 1.864.7 1.864 2.216v34.528c0 1.518-.234 2.802-2.33 2.918l-36.226 2.1c-2.096.116-3.026-.582-3.026-2.45Zm35.76-32.896c.232 1.05 0 2.1-1.05 2.22l-1.746.346v25.664c-1.516.816-2.912 1.282-4.078 1.282-1.865 0-2.33-.584-3.726-2.332L25.624 29.3v17.38l3.612.818s0 2.1-2.915 2.1l-8.034.466c-.234-.468 0-1.634.815-1.866l2.098-.582v-22.98l-2.912-.236c-.234-1.05.348-2.566 1.98-2.684l8.62-.58 11.88 18.196V23.234l-3.028-.348c-.234-1.285.698-2.22 1.862-2.334l8.04-.468Z"
fill="#fff"
/>
</g>
<defs>
<clipPath id="a">
<path fill="#fff" d="M0 0h60v60H0z" />
</clipPath>
</defs>
</svg>
),
},
{
id: "cal",
name: "Cal.com",
description:
"Our Integration with Cal.com from Midday is a dynamic collaboration tool that brings together two essential elements for productivity and time management. With this integration, you can synchronize your Cal Calendar with your Midday workspace seamlessly. This ensures that your time reporting is accessible from Cal.com",
logo: (
<svg
width="101"
height="22"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M10.058 20.817C4.321 20.817 0 16.277 0 10.67 0 5.046 4.1.468 10.058.468c3.163 0 5.351.971 7.061 3.195l-2.758 2.299c-1.159-1.234-2.556-1.85-4.303-1.85-3.88 0-6.013 2.97-6.013 6.558 0 3.588 2.336 6.503 6.013 6.503 1.729 0 3.2-.616 4.358-1.85l2.721 2.392c-1.636 2.13-3.88 3.102-7.079 3.102ZM29.016 5.886h3.714v14.575h-3.714v-2.13c-.772 1.514-2.06 2.523-4.523 2.523-3.935 0-7.08-3.42-7.08-7.624 0-4.205 3.145-7.624 7.08-7.624 2.445 0 3.75 1.009 4.523 2.522V5.886Zm.11 7.344c0-2.28-1.563-4.167-4.027-4.167-2.372 0-3.916 1.906-3.916 4.167 0 2.205 1.544 4.167 3.916 4.167 2.446 0 4.027-1.906 4.027-4.167ZM35.36 0h3.714v20.443H35.36V0ZM40.729 18.518c0-1.196.956-2.205 2.262-2.205a2.18 2.18 0 0 1 2.225 2.205c0 1.233-.938 2.242-2.225 2.242a2.231 2.231 0 0 1-2.262-2.242ZM59.43 18.107c-1.38 1.681-3.476 2.747-5.958 2.747-4.432 0-7.686-3.42-7.686-7.624 0-4.205 3.254-7.624 7.686-7.624 2.39 0 4.468 1.009 5.847 2.597l-2.868 2.41c-.718-.896-1.655-1.569-2.98-1.569-2.371 0-3.916 1.906-3.916 4.167s1.545 4.167 3.917 4.167c1.434 0 2.427-.747 3.162-1.757l2.795 2.486ZM59.742 13.23c0-4.205 3.255-7.624 7.686-7.624 4.432 0 7.686 3.42 7.686 7.624s-3.254 7.624-7.686 7.624c-4.431-.02-7.686-3.42-7.686-7.624Zm11.603 0c0-2.28-1.545-4.167-3.917-4.167-2.372-.019-3.916 1.887-3.916 4.167 0 2.26 1.544 4.167 3.916 4.167s3.917-1.906 3.917-4.167ZM100.232 11.548v8.895h-3.714v-7.98c0-2.522-1.177-3.606-2.942-3.606-1.655 0-2.832.823-2.832 3.607v7.979H87.03v-7.98c0-2.522-1.195-3.606-2.942-3.606-1.655 0-3.108.823-3.108 3.607v7.979h-3.714V5.868h3.714v2.018c.773-1.57 2.17-2.355 4.322-2.355 2.04 0 3.75 1.01 4.688 2.71.938-1.738 2.317-2.71 4.818-2.71 3.052.019 5.424 2.336 5.424 6.017Z"
fill="#FAFAFA"
/>
</svg>
),
},
{
id: "fortnox",
name: "Fortnox",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import { exportTransactionsAction } from "@/actions/export-transactions-action";
import { Button } from "@midday/ui/button";
import {
Dialog,
Expand All @@ -9,8 +10,23 @@ import {
DialogHeader,
DialogTitle,
} from "@midday/ui/dialog";
import { Loader2 } from "lucide-react";
import { useAction } from "next-safe-action/hook";
import { useSearchParams } from "next/navigation";
import { useEffect } from "react";

export function ExportTransactionsModal({ isOpen, setOpen }) {
const searchParams = useSearchParams();
const { execute, status } = useAction(exportTransactionsAction);
const filter = searchParams.get("filter");
const date = filter ? JSON.parse(filter)?.date : null;

useEffect(() => {
if (status === "hasSucceeded" && isOpen) {
setOpen(false);
}
}, [status]);

return (
<Dialog open={isOpen} onOpenChange={setOpen}>
<DialogContent>
Expand All @@ -27,7 +43,16 @@ export function ExportTransactionsModal({ isOpen, setOpen }) {
<Button variant="outline" onClick={() => setOpen(false)}>
Cancel
</Button>
<Button>Export</Button>
<Button
onClick={() => execute(date)}
disabled={status === "executing"}
>
{status === "executing" ? (
<Loader2 className="h-4 w-4 animate-spin" />
) : (
"Export"
)}
</Button>
</div>
</DialogFooter>
</div>
Expand Down
4 changes: 2 additions & 2 deletions apps/dashboard/src/jobs/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,12 @@ client.defineJob({
schema: z.object({
from: z.string().datetime(),
to: z.string().datetime(),
accountId: z.string(),
teamId: z.string(),
}),
}),
integrations: { supabase },
run: async (payload, io) => {
const { from, to, accountId } = payload;
const { from, to, teamId } = payload;

const generateExport = await io.createStatus("generate-export", {
label: "Generating memes",
Expand Down

0 comments on commit 9d37379

Please sign in to comment.