Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Dec 17, 2023
1 parent 71b68a7 commit 100dc07
Show file tree
Hide file tree
Showing 11 changed files with 222 additions and 13 deletions.
24 changes: 24 additions & 0 deletions apps/dashboard/src/actions/change-chart-period-action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use server";

import { Cookies } from "@/utils/constants";
import { getUser } from "@midday/supabase/cached-queries";
import { revalidateTag } from "next/cache";
import { cookies } from "next/headers";
import { action } from "./safe-action";
import { changeChartPeriodSchema } from "./schema";

export const changeChartPeriodAction = action(
changeChartPeriodSchema,
async (value) => {
const user = await getUser();

cookies().set({
name: Cookies.ChartPeriod,
value: JSON.stringify(value),
});

revalidateTag(`chart_${user.data.team_id}`);

return value;
}
);
4 changes: 2 additions & 2 deletions apps/dashboard/src/actions/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export const changeSpendingPeriodSchema = z.object({

export const changeChartTypeSchema = z.enum(["profit_loss", "income"]);
export const changeChartPeriodSchema = z.object({
from: z.string().datetime(),
to: z.string().datetime(),
from: z.string().datetime().optional(),
to: z.string().datetime().optional(),
});

export const changeTransactionsPeriodSchema = z.enum([
Expand Down
171 changes: 171 additions & 0 deletions apps/dashboard/src/app/[locale]/@dashboard/(root)/apps/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,177 @@ const apps = [
</svg>
),
},
{
id: "linear",
name: "Linear",
description:
"Integration with Visma offers a comprehensive solution for connecting Midday with Visma's suite of financial and administrative software. This integration facilitates the exchange of data and automates key financial processes, enhancing the efficiency of your operations and ensuring accurate financial management.",
logo: (
<svg
xmlns="http://www.w3.org/2000/svg"
width={60}
height={60}
fill="none"
>
<g clipPath="url(#a)">
<path
fill="currentColor"
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"
/>
</g>
<defs>
<clipPath id="a">
<path fill="currentColor" d="M0 0h60v60H0z" />
</clipPath>
</defs>
</svg>
),
},
{
id: "notion",
name: "Notion",
description:
"Integration with Visma offers a comprehensive solution for connecting Midday with Visma's suite of financial and administrative software. This integration facilitates the exchange of data and automates key financial processes, enhancing the efficiency of your operations and ensuring accurate financial management.",
logo: (
<svg
xmlns="http://www.w3.org/2000/svg"
width={60}
height={60}
fill="none"
>
<g clipPath="url(#a)">
<path
fill="transparent"
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"
/>
<path
fill="currentColor"
fillRule="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"
clipRule="evenodd"
/>
</g>
<defs>
<clipPath id="a">
<path fill="currentColor" d="M0 0h60v60H0z" />
</clipPath>
</defs>
</svg>
),
},
{
id: "calcom",
name: "Cal.com",
description:
"Integration with Visma offers a comprehensive solution for connecting Midday with Visma's suite of financial and administrative software. This integration facilitates the exchange of data and automates key financial processes, enhancing the efficiency of your operations and ensuring accurate financial management.",
logo: (
<svg
xmlns="http://www.w3.org/2000/svg"
width={101}
height={22}
fill="none"
>
<path
fill="currentColor"
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"
/>
</svg>
),
},
{
id: "quickbooks",
name: "Quickbooks",
description:
"Integration with Visma offers a comprehensive solution for connecting Midday with Visma's suite of financial and administrative software. This integration facilitates the exchange of data and automates key financial processes, enhancing the efficiency of your operations and ensuring accurate financial management.",
logo: (
<svg
xmlns="http://www.w3.org/2000/svg"
width={60}
height={60}
fill="none"
>
<path
fill="white"
d="M30 60c16.568 0 30-13.432 30-30C60 13.432 46.568 0 30 0 13.432 0 0 13.432 0 30c0 16.568 13.432 30 30 30Z"
/>
<path
fill="black"
d="M8.333 30A11.667 11.667 0 0 0 20 41.667h1.667v-4.334H20a7.332 7.332 0 0 1-6.828-10.153A7.336 7.336 0 0 1 20 22.666h4v22.667a4.335 4.335 0 0 0 4.333 4.334V18.333H20A11.666 11.666 0 0 0 8.333 30ZM40 18.333h-1.666v4.334H40a7.333 7.333 0 0 1 0 14.666h-4V14.667a4.331 4.331 0 0 0-4.333-4.333v31.333H40a11.667 11.667 0 0 0 0-23.334Z"
/>
</svg>
),
},
{
id: "xero",
name: "Xero",
description:
"Integration with Visma offers a comprehensive solution for connecting Midday with Visma's suite of financial and administrative software. This integration facilitates the exchange of data and automates key financial processes, enhancing the efficiency of your operations and ensuring accurate financial management.",
logo: (
<svg
xmlns="http://www.w3.org/2000/svg"
width={60}
height={60}
fill="none"
>
<g clipPath="url(#a)">
<mask
id="b"
width={88}
height={88}
x={-14}
y={-14}
maskUnits="userSpaceOnUse"
style={{
maskType: "luminance",
}}
>
<path
fill="#fff"
d="M-13.205-13.275h86.464V73.19h-86.464v-86.464Z"
/>
</mask>
<g mask="url(#b)">
<path
fill="white"
d="M30 59.885c16.505 0 29.886-13.38 29.886-29.885C59.886 13.494 46.505.114 30 .114S.114 13.494.114 30c0 16.505 13.38 29.885 29.886 29.885Z"
/>
<path
fill="#121212"
d="m14.42 29.913 5.1-5.112a.914.914 0 0 0-1.3-1.285l-5.096 5.094-5.118-5.101a.914.914 0 1 0-1.285 1.299l5.1 5.098-5.097 5.107a.914.914 0 1 0 1.282 1.3l5.11-5.103 5.091 5.085a.911.911 0 0 0 1.576-.628.907.907 0 0 0-.266-.644l-5.097-5.11ZM44.74 29.912c0 .915.745 1.66 1.662 1.66.914 0 1.66-.745 1.66-1.66 0-.916-.746-1.66-1.66-1.66-.917 0-1.662.744-1.662 1.66Z"
/>
<path
fill="#121212"
d="M41.59 29.912a4.814 4.814 0 0 1 4.81-4.809 4.815 4.815 0 0 1 4.808 4.81A4.814 4.814 0 0 1 46.4 34.72a4.814 4.814 0 0 1-4.81-4.808Zm-1.891 0c0 3.695 3.006 6.7 6.7 6.7 3.695 0 6.703-3.005 6.703-6.7 0-3.694-3.008-6.7-6.702-6.7a6.709 6.709 0 0 0-6.701 6.7ZM39.223 23.326h-.28a3.8 3.8 0 0 0-2.339.79.916.916 0 0 0-.892-.72.904.904 0 0 0-.906.907l.003 11.286a.915.915 0 0 0 1.827-.002v-6.939c0-2.313.212-3.247 2.193-3.494.184-.023.383-.02.383-.02.543-.018.928-.39.928-.894a.916.916 0 0 0-.917-.914ZM21.677 28.81l.003-.077a4.842 4.842 0 0 1 9.402.076h-9.405Zm11.276-.173c-.394-1.864-1.415-3.396-2.969-4.38-2.272-1.442-5.272-1.362-7.467.198a6.777 6.777 0 0 0-2.823 5.503c0 .538.065 1.081.2 1.616a6.754 6.754 0 0 0 5.687 5.006 6.379 6.379 0 0 0 2.41-.16c.701-.171 1.38-.455 2.004-.855.648-.417 1.19-.966 1.714-1.624l.032-.036c.364-.451.296-1.093-.104-1.4-.337-.258-.904-.363-1.35.208a6.233 6.233 0 0 1-.32.417c-.354.392-.794.771-1.32 1.065a4.81 4.81 0 0 1-2.247.568c-2.658-.03-4.08-1.885-4.586-3.21a4.806 4.806 0 0 1-.204-.768 1.715 1.715 0 0 1-.012-.14l9.538-.002c1.308-.028 2.011-.95 1.817-2.006Z"
/>
</g>
</g>
<defs>
<clipPath id="a">
<path fill="#fff" d="M0 0h60v60H0z" />
</clipPath>
</defs>
</svg>
),
},
{
id: "stripe",
name: "Stripe",
description:
"Integration with Visma offers a comprehensive solution for connecting Midday with Visma's suite of financial and administrative software. This integration facilitates the exchange of data and automates key financial processes, enhancing the efficiency of your operations and ensuring accurate financial management.",
logo: (
<svg
xmlns="http://www.w3.org/2000/svg"
width={72}
height={30}
fill="none"
>
<path
fill="currentColor"
d="M5.058 11.735c0-.78.64-1.08 1.699-1.08 1.52 0 3.438.46 4.958 1.28V7.236c-1.66-.66-3.299-.92-4.958-.92C2.699 6.317 0 8.437 0 11.975c0 5.517 7.597 4.637 7.597 7.016 0 .92-.8 1.22-1.92 1.22-1.659 0-3.778-.68-5.457-1.6v4.758c1.859.8 3.738 1.14 5.457 1.14 4.159 0 7.017-2.06 7.017-5.638-.02-5.957-7.636-4.897-7.636-7.136Zm13.514-9.416-4.878 1.04-.02 16.012c0 2.959 2.219 5.138 5.177 5.138 1.64 0 2.84-.3 3.499-.66v-4.058c-.64.26-3.799 1.18-3.799-1.78v-7.096h3.799V6.657H18.55l.02-4.338Zm9.995 5.817-.32-1.479H23.93v17.492h4.998V12.294c1.18-1.539 3.178-1.259 3.798-1.04V6.658c-.64-.24-2.979-.68-4.158 1.48Zm5.377-1.479h5.018v17.492h-5.018V6.657Zm0-1.52 5.018-1.079V0l-5.018 1.06v4.078Zm15.453 1.18c-1.959 0-3.218.92-3.918 1.56l-.26-1.24h-4.398v23.31l4.998-1.06.02-5.658c.72.52 1.78 1.26 3.538 1.26 3.579 0 6.837-2.879 6.837-9.216-.02-5.797-3.318-8.956-6.817-8.956Zm-1.199 13.774c-1.18 0-1.88-.42-2.359-.94l-.02-7.416c.52-.58 1.24-.98 2.379-.98 1.82 0 3.079 2.04 3.079 4.658 0 2.679-1.24 4.678-3.079 4.678Zm23.77-4.618c0-5.118-2.48-9.156-7.218-9.156-4.757 0-7.636 4.038-7.636 9.116 0 6.017 3.398 9.056 8.276 9.056 2.379 0 4.178-.54 5.538-1.3v-3.998c-1.36.68-2.92 1.1-4.898 1.1-1.94 0-3.659-.68-3.878-3.039h9.775c0-.26.04-1.3.04-1.78Zm-9.876-1.9c0-2.258 1.379-3.198 2.638-3.198 1.22 0 2.52.94 2.52 3.199h-5.158Z"
/>
</svg>
),
},
];

export default function Apps() {
Expand Down
6 changes: 6 additions & 0 deletions apps/dashboard/src/app/[locale]/@dashboard/(root)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import { Realtime } from "@/components/charts/realtime";
import { Spending } from "@/components/charts/spending";
import { Transactions } from "@/components/charts/transactions";
import { OverviewModal } from "@/components/modals/overview-modal";
import { Cookies } from "@/utils/constants";
import {
getBankConnectionsByTeamId,
getUser,
} from "@midday/supabase/cached-queries";
import { cn } from "@midday/ui/utils";
import { startOfMonth, startOfYear } from "date-fns";
import { Metadata } from "next";
import { cookies } from "next/headers";
import { Suspense } from "react";

export const metadata: Metadata = {
Expand All @@ -26,8 +28,12 @@ const defaultValue = {
export default async function Overview({ searchParams }) {
const { data: userData } = await getUser();
const { data } = await getBankConnectionsByTeamId();
const chartPeriod = cookies().has(Cookies.ChartPeriod)
? JSON.parse(cookies().get(Cookies.ChartPeriod)?.value)
: {};

const value = {
...chartPeriod,
...(searchParams.from && { from: searchParams.from }),
...(searchParams.to && { to: searchParams.to }),
period: searchParams.period,
Expand Down
13 changes: 11 additions & 2 deletions apps/dashboard/src/components/charts/chart-period.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import { changeChartPeriodAction } from "@/actions/change-chart-period-action";
import { DateRangePicker } from "@midday/ui/date-range-picker";
import {
Select,
Expand All @@ -10,11 +11,19 @@ import {
SelectValue,
} from "@midday/ui/select";
import { format } from "date-fns";
import { useAction } from "next-safe-action/hook";
import { parseAsString, useQueryStates } from "next-usequerystate";

export function ChartPeriod({ initialValue, defaultValue, disabled }) {
let placeholder;

const { execute } = useAction(changeChartPeriodAction);

const handleChangePeriod = (params) => {
setState(params);
execute(params);
};

const [state, setState] = useQueryStates(
{
to: parseAsString.withDefault(initialValue?.to ?? undefined),
Expand Down Expand Up @@ -53,7 +62,7 @@ export function ChartPeriod({ initialValue, defaultValue, disabled }) {
to: state?.to && new Date(state.to),
}}
onSelect={(range) => {
setState({
handleChangePeriod({
from: range?.from ? new Date(range.from).toISOString() : null,
to: range?.to ? new Date(range.to).toISOString() : null,
});
Expand All @@ -63,7 +72,7 @@ export function ChartPeriod({ initialValue, defaultValue, disabled }) {
<Select
disabled={disabled}
defaultValue={state.period}
onValueChange={(period) => setState({ period })}
onValueChange={(period) => handleChangePeriod({ period })}
>
<SelectTrigger className="w-[130px] font-medium">
<SelectValue placeholder="Monthly" />
Expand Down
3 changes: 2 additions & 1 deletion apps/dashboard/src/components/charts/chart-selectors.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { ChartPeriod } from "@/components/charts/chart-period";
import { ChartType } from "@/components/charts/chart-type";
import { Cookies } from "@/utils/constants";
import { cookies } from "next/headers";

export async function ChartSelectors({ value, defaultValue }) {
const chartType = cookies().get("chart-type")?.value ?? "profit_loss";
const chartType = cookies().get(Cookies.ChartType)?.value ?? "profit_loss";

return (
<div className="flex justify-between mt-6">
Expand Down
4 changes: 1 addition & 3 deletions apps/dashboard/src/components/tables/vault/upload-zone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ export function UploadZone({ children }) {
const { toast, dismiss, update } = useToast();
const { createFolder } = useVaultContext((s) => s);

const isDefaultFolder = ["inbox", "exports", "transactions"].includes(
folders.at(0)
);
const isDefaultFolder = ["inbox", "exports"].includes(folders.at(0));

useEffect(() => {
if (!toastId && showProgress) {
Expand Down
5 changes: 2 additions & 3 deletions apps/dashboard/src/components/vote-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

import { voteAction } from "@/actions/vote-action";
import { Button } from "@midday/ui/button";
import { Loader2 } from "lucide-react";
import { ChevronUp } from "lucide-react";
import { useOptimistic, useTransition } from "react";

export function VoteButton({ count, id }) {
const [isPending, startTransition] = useTransition();
const [_, startTransition] = useTransition();

const [optimisticCount, addOptimisticCount] = useOptimistic(
count,
(prevCount) => {
return +prevCount + 1;
},
}
);

const handleVote = () => {
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export const Cookies = {
PrefferedSignInProvider: "preferred-signin-provider",
SpendingPeriod: "spending-period",
ChartType: "chart-type",
ChartPeriod: "chart-period",
TransactionsPeriod: "transactions-period",
OnboardingVisited: "onboarding-visited",
MfaSetupVisited: "mfa-setup-visited",
Expand Down
Binary file modified bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions packages/kv/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createClient } from "@vercel/kv";

export const client = createClient({
url: process.env.KV_REST_API_URL,
token: process.env.KV_REST_API_TOKEN,
url: process.env.KV_REST_API_URL!,
token: process.env.KV_REST_API_TOKEN!,
});

0 comments on commit 100dc07

Please sign in to comment.