From a2947943eab77fd4bf40f5e05ea56284a22027b5 Mon Sep 17 00:00:00 2001 From: simba77 Date: Mon, 4 Dec 2023 23:24:14 +0300 Subject: [PATCH] Added filter by date in closed deals --- .eslintrc.js | 8 ++ .../components/Forms/InputDateComponent.vue | 117 ++++++++++++++++++ assets/composable/useAnalytics.ts | 10 +- assets/pages/Accounts/ClosedDealsPage.vue | 19 ++- package-lock.json | 92 +++++++++++++- package.json | 1 + src/Repository/DealRepository.php | 29 +++-- .../DTO/Deals/DealsFilterRequestDTO.php | 4 +- src/Services/Deals/ClosedDealsService.php | 18 +-- 9 files changed, 275 insertions(+), 23 deletions(-) create mode 100644 assets/components/Forms/InputDateComponent.vue diff --git a/.eslintrc.js b/.eslintrc.js index 9415d48..fbb991d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -19,6 +19,14 @@ module.exports = { '@typescript-eslint/no-explicit-any': 'off', 'vue/no-v-text-v-html-on-component': 'off', 'vue/no-v-html': 'off', + 'vue/max-attributes-per-line': ['error', { + 'singleline': { + 'max': 4 + }, + 'multiline': { + 'max': 1 + } + }], }, overrides: [ { diff --git a/assets/components/Forms/InputDateComponent.vue b/assets/components/Forms/InputDateComponent.vue new file mode 100644 index 0000000..6c674ae --- /dev/null +++ b/assets/components/Forms/InputDateComponent.vue @@ -0,0 +1,117 @@ + + + + + diff --git a/assets/composable/useAnalytics.ts b/assets/composable/useAnalytics.ts index 3331c32..390eccd 100644 --- a/assets/composable/useAnalytics.ts +++ b/assets/composable/useAnalytics.ts @@ -1,12 +1,12 @@ -import {ref} from "vue"; +import { ref } from "vue"; import axios from "axios"; -import {ClosedDealsListItem, ClosedDealsSummary} from "@/types/analytics"; +import { ClosedDealsListItem, ClosedDealsSummary } from "@/types/analytics"; -const closedDeals = ref<{deals: ClosedDealsListItem[], summary: ClosedDealsSummary}>() +const closedDeals = ref<{ deals: ClosedDealsListItem[], summary: ClosedDealsSummary }>() export default function () { - async function getClosedDeals() { - closedDeals.value = await axios.get('/api/analytics/closed-deals').then((response) => response.data); + async function getClosedDeals(filter: object = {}) { + closedDeals.value = await axios.get('/api/analytics/closed-deals', {params: filter}).then((response) => response.data); } return { diff --git a/assets/pages/Accounts/ClosedDealsPage.vue b/assets/pages/Accounts/ClosedDealsPage.vue index f732a06..2f89663 100644 --- a/assets/pages/Accounts/ClosedDealsPage.vue +++ b/assets/pages/Accounts/ClosedDealsPage.vue @@ -4,16 +4,33 @@ import useAnalytics from "@/composable/useAnalytics"; import useAsync from "@/utils/use-async"; import PreloaderComponent from "@/components/Common/PreloaderComponent.vue"; import ClosedDealsTableComponent from "@/components/Analytics/ClosedDealsTableComponent.vue"; +import InputDateComponent from "@/components/Forms/InputDateComponent.vue"; +import { reactive } from "vue"; const {closedDeals, getClosedDeals} = useAnalytics() -const {loading, run} = useAsync(() => getClosedDeals()) +const filter = reactive({ + startDate: '', + endDate: '', +}) + +const {loading, run} = useAsync(() => getClosedDeals(filter)) run()