Skip to content

Commit

Permalink
Export
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Dec 18, 2023
1 parent 8e591dd commit 3bb4fdf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/charts/spending-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { SpendingChart } from "./spending-chart";

function SpendingCategoryList({ categories }) {
return (
<ul className="absolute z-10 left-8 bottom-8 space-y-2">
<ul className="absolute z-10 left-8 bottom-8 space-y-2 invisible xl:visible">
{categories.map(({ category }) => (
<li key={category}>
<Link
Expand Down
10 changes: 5 additions & 5 deletions apps/dashboard/src/components/export-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ export function ExportButton({ totalMissingAttachments }) {
const [isOpen, setOpen] = useState();

const searchParams = useSearchParams();
const hasFilters =
searchParams.get("filter") &&
Object.keys(JSON.parse(searchParams.get("filter"))).length > 0;
const hasDate = searchParams.get("filter")
? JSON.parse(searchParams.get("filter"))?.date
: null;

return (
<>
<Button
className="space-x-2"
variant={hasFilters ? "default" : "outline"}
disabled={!hasFilters}
variant={hasDate ? "default" : "outline"}
disabled={!hasDate}
onClick={() => setOpen(true)}
>
Export
Expand Down
10 changes: 10 additions & 0 deletions apps/dashboard/src/components/modals/export-transactions-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
DialogHeader,
DialogTitle,
} from "@midday/ui/dialog";
import { useToast } from "@midday/ui/use-toast";
import { Loader2 } from "lucide-react";
import { useAction } from "next-safe-action/hook";
import Link from "next/link";
Expand All @@ -23,6 +24,8 @@ export function ExportTransactionsModal({
setOpen,
totalMissingAttachments,
}) {
const { toast } = useToast();

const searchParams = useSearchParams();
const { setExportId } = useExportStore();
const filter = searchParams.get("filter");
Expand All @@ -32,6 +35,13 @@ export function ExportTransactionsModal({
onSuccess: ({ id }) => {
setExportId(id);
},
onError: () => {
toast({
duration: 3500,
variant: "error",
title: "Something went wrong pleaase try again.",
});
},
});

useEffect(() => {
Expand Down

0 comments on commit 3bb4fdf

Please sign in to comment.