From 087c964fedf0f081e90a0b364fa79ddb95d385da Mon Sep 17 00:00:00 2001 From: Raais Date: Mon, 29 Jul 2024 23:02:52 +0500 Subject: [PATCH] fix bug and push ci --- .github/workflows/vite.yml | 51 ++++++++++++++++++ src/FisaMatrix.tsx | 84 +++++++++++++++++++++++------ src/components/ChartDailyCredit.tsx | 4 ++ src/components/ChartDailyDebit.tsx | 5 +- src/lib/fmt.ts | 30 ++++++----- 5 files changed, 144 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/vite.yml diff --git a/.github/workflows/vite.yml b/.github/workflows/vite.yml new file mode 100644 index 0000000..0972d0b --- /dev/null +++ b/.github/workflows/vite.yml @@ -0,0 +1,51 @@ +# Simple workflow for deploying static content to GitHub Pages +name: Deploy static content to Pages + +on: + # Runs on pushes targeting the default branch + push: + branches: ["main"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow one concurrent deployment +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + # Single deploy job since we're just deploying + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "npm" + - name: Install dependencies + run: npm ci + - name: Build + run: npm run build + - name: Setup Pages + uses: actions/configure-pages@v4 + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + # Upload dist folder + path: "./dist" + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 \ No newline at end of file diff --git a/src/FisaMatrix.tsx b/src/FisaMatrix.tsx index efd60be..9d2527c 100644 --- a/src/FisaMatrix.tsx +++ b/src/FisaMatrix.tsx @@ -1,3 +1,5 @@ +import * as chrono from "chrono-node"; + import { AreaChartOutlined, BarChartOutlined, @@ -60,9 +62,8 @@ import { } from "./lib/db/models/categories"; import { cmd_createRecords, parseCSVData } from "./lib/db/models/transactions"; import { renderCat, salaryMonthPrompt } from "./lib/extra"; -import { useEffect, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import { useQueries, useResultTable, useStore } from "tinybase/debug/ui-react"; -import * as chrono from "chrono-node"; import { ChartCategoryAggregates } from "./components/ChartCategoryAggregates"; import { ChartCategoryBreakdown } from "./components/ChartCategoryBreakdown"; @@ -94,6 +95,9 @@ export const FisaMatrix = () => { const [aggregateType, setAggregateType] = useState<"sum" | "count">("sum"); const [repeatsType, setRepeatsType] = useState<"repeats" | "all">("all"); + const [datasetOpen, setDatasetOpen] = useState([]); + const datasetRef = useRef(null); + const [openStates, setOpenStates] = useState({ modalCat: false, modalInfo: false, @@ -285,6 +289,22 @@ export const FisaMatrix = () => { setTrxFiltered(filtered); }; + const handleGotoDate = (_e: any, _chart: any, options: any) => { + const date = options.w.globals.labels[options?.dataPointIndex]; + if (date) { + if (datasetOpen.length === 0) setDatasetOpen(["1"]); + if (datasetRef.current) { + const filtered = extractDataSource(trx).filter((i: any) => + dayjs(i.date, "DD-MM-YYYY").isSame(dayjs(date, "DD-MM-YYYY"), "day") + ); + if (filtered.length > 0) { + setTrxFiltered(filtered); + datasetRef.current.scrollIntoView(); + } + } + } + }; + const closeModalInfo = () => { modalInfo.close(); localStorage.setItem("infoShown", "true"); @@ -371,6 +391,14 @@ export const FisaMatrix = () => { }, }} > +