Skip to content

Commit

Permalink
fix: server search for budget
Browse files Browse the repository at this point in the history
  • Loading branch information
jesusantguerrero committed Oct 23, 2023
1 parent d10d724 commit c88cfc6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion resources/js/Pages/WidgetHeaderRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ defineProps<{
{{ valueBadge }}
</span>
<span>
{{ {{ value }}}}
{{ value }}
</span>
</h2>
<p class="text-xs" v-if="valueSubtitle">
Expand Down
18 changes: 12 additions & 6 deletions resources/js/composables/useServerSearch.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { endOfMonth, startOfMonth, format, parseISO } from 'date-fns';
// import { format, parseISO } from "date-fns";
import format from "date-fns/format";
import parseISO from "date-fns/parseISO";
import { reactive, Ref, watch, nextTick, computed, ref, inject, toRaw, onMounted } from "vue";
import { reactive, Ref, watch, nextTick, computed, ref, inject } from "vue";
import debounce from "lodash/debounce";

export interface IServerSearchData {
Expand Down Expand Up @@ -102,10 +101,17 @@ export const parseParams = (state: SearchState) => {
.join("&");
};

function parseDateFilters(options: Ref<Partial<IServerSearchData>>) {
const dates = options?.value?.filters?.date
function parseDateFilters(options: Ref<Partial<IServerSearchData>>, setDefaultDate: boolean) {

const defaultDates = setDefaultDate ? [
format(startOfMonth(new Date()), 'yyyy-MM-dd'),
format(endOfMonth(new Date()), 'yyyy-MM-dd')
] : [null, null]

const dates = options?.value?.filters?.date
? options.value.filters.date.split("~")
: [null, null];
: defaultDates;

return {
startDate: dates[0] && parseISO(dates[0]),
endDate:
Expand Down

0 comments on commit c88cfc6

Please sign in to comment.