From 157134f4efc072ffc7398bf8091d1faeea7df66c Mon Sep 17 00:00:00 2001 From: vincent Date: Wed, 7 Sep 2022 18:36:54 +0200 Subject: [PATCH] (feat) Add period filter --- .../components/base/fab-state-label.tsx | 1 - .../javascript/components/store/orders.tsx | 42 +++++++++++++++++-- .../modules/store/store-filters.scss | 6 +++ config/locales/app.admin.en.yml | 1 + 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/app/frontend/src/javascript/components/base/fab-state-label.tsx b/app/frontend/src/javascript/components/base/fab-state-label.tsx index ef1d7b053..25fc0a998 100644 --- a/app/frontend/src/javascript/components/base/fab-state-label.tsx +++ b/app/frontend/src/javascript/components/base/fab-state-label.tsx @@ -9,7 +9,6 @@ interface FabStateLabelProps { * Render a label preceded by a bot */ export const FabStateLabel: React.FC = ({ status, background, children }) => { - console.log('status: ', status); return ( {children} diff --git a/app/frontend/src/javascript/components/store/orders.tsx b/app/frontend/src/javascript/components/store/orders.tsx index 93cbd88d1..2402b226c 100644 --- a/app/frontend/src/javascript/components/store/orders.tsx +++ b/app/frontend/src/javascript/components/store/orders.tsx @@ -4,12 +4,15 @@ import { useTranslation } from 'react-i18next'; import { react2angular } from 'react2angular'; import { Loader } from '../base/loader'; import { IApplication } from '../../models/application'; +import { useForm } from 'react-hook-form'; import { FabButton } from '../base/fab-button'; import { StoreListHeader } from './store-list-header'; import { AccordionItem } from './accordion-item'; import { OrderItem } from './order-item'; import { MemberSelect } from '../user/member-select'; import { User } from '../../models/user'; +import { FormInput } from '../form/form-input'; +import { TDateISODate } from '../../typings/date-iso'; declare const Application: IApplication; @@ -35,9 +38,10 @@ type checklistOption = { value: number, label: string }; // TODO: delete next eslint disable // eslint-disable-next-line @typescript-eslint/no-unused-vars const Orders: React.FC = ({ currentUser, onSuccess, onError }) => { - console.log('currentUser: ', currentUser); const { t } = useTranslation('admin'); + const { register, getValues } = useForm(); + const [filters, setFilters] = useImmer(initFilters); const [clearFilters, setClearFilters] = useState(false); const [accordion, setAccordion] = useState({}); @@ -119,6 +123,13 @@ const Orders: React.FC = ({ currentUser, onSuccess, onError }) => { }); }; + /** + * Filter: by period + */ + const handlePeriod = () => { + console.log(getValues(['period_from', 'period_to'])); + }; + /** * Open/close accordion items */ @@ -186,6 +197,27 @@ const Orders: React.FC = ({ currentUser, onSuccess, onError }) => { + +
+
+
+ from + + to + +
+ {t('app.admin.store.orders.filter_apply')} +
+
+
@@ -216,11 +248,15 @@ Application.Components.component('orders', react2angular(OrdersWrapper, ['curren interface Filters { reference: string, status: checklistOption[], - memberId: number + memberId: number, + period_from: TDateISODate, + period_to: TDateISODate } const initFilters: Filters = { reference: '', status: [], - memberId: null + memberId: null, + period_from: null, + period_to: null }; diff --git a/app/frontend/src/stylesheets/modules/store/store-filters.scss b/app/frontend/src/stylesheets/modules/store/store-filters.scss index 6dbd308aa..b8009054d 100644 --- a/app/frontend/src/stylesheets/modules/store/store-filters.scss +++ b/app/frontend/src/stylesheets/modules/store/store-filters.scss @@ -143,4 +143,10 @@ } } } + + .period { + display: flex; + justify-content: center; + align-items: center; + } } \ No newline at end of file diff --git a/config/locales/app.admin.en.yml b/config/locales/app.admin.en.yml index 3ac93f1f2..cd5f9474c 100644 --- a/config/locales/app.admin.en.yml +++ b/config/locales/app.admin.en.yml @@ -2037,6 +2037,7 @@ en: filter_ref: "By reference" filter_status: "By status" filter_client: "By client" + filter_period: "By period" status: error: "Payment error" canceled: "Canceled"