From 555784b0b12ba2b40fcd16d69c7750a5b8fcbf0f Mon Sep 17 00:00:00 2001 From: IRBorisov <8611739+IRBorisov@users.noreply.github.com> Date: Sun, 16 Jul 2023 20:25:55 +0300 Subject: [PATCH] Improve RSForm and Constituenta UI includeing RSForm list filtering --- rsconcept/frontend/src/backendAPI.ts | 12 +- .../src/components/Common/Checkbox.tsx | 4 +- .../src/components/Common/SubmitButton.tsx | 2 +- .../src/components/Common/TextInput.tsx | 2 +- .../src/components/Navigation/UserTools.tsx | 2 +- .../frontend/src/context/RSFormContext.tsx | 8 +- rsconcept/frontend/src/hooks/useRSForms.ts | 22 ++-- .../frontend/src/hooks/useUserProfile.ts | 1 - rsconcept/frontend/src/models.ts | 15 ++- rsconcept/frontend/src/pages/LoginPage.tsx | 4 +- .../frontend/src/pages/RSFormCreatePage.tsx | 2 +- .../pages/RSFormPage/ConstituentEditor.tsx | 118 +++++++++++++++++- .../src/pages/RSFormPage/ExpressionEditor.tsx | 35 ++++++ .../src/pages/RSFormPage/RSFormCard.tsx | 4 +- .../src/pages/RSFormPage/RSFormStats.tsx | 2 + .../{RSFormEditor.tsx => RSFormTabs.tsx} | 43 +++++-- .../frontend/src/pages/RSFormPage/index.tsx | 4 +- .../frontend/src/pages/RSFormsPage/index.tsx | 19 ++- 18 files changed, 252 insertions(+), 47 deletions(-) create mode 100644 rsconcept/frontend/src/pages/RSFormPage/ExpressionEditor.tsx rename rsconcept/frontend/src/pages/RSFormPage/{RSFormEditor.tsx => RSFormTabs.tsx} (55%) diff --git a/rsconcept/frontend/src/backendAPI.ts b/rsconcept/frontend/src/backendAPI.ts index 79d6ad4e..f8cad1b3 100644 --- a/rsconcept/frontend/src/backendAPI.ts +++ b/rsconcept/frontend/src/backendAPI.ts @@ -3,6 +3,7 @@ import { config } from './constants' import { ErrorInfo } from './components/BackendError' import { toast } from 'react-toastify' import { ICurrentUser, IRSForm, IUserInfo, IUserProfile } from './models' +import { FilterType, RSFormsFilter } from './hooks/useRSForms' export type BackendCallback = (response: AxiosResponse) => void; @@ -69,10 +70,17 @@ export async function getActiveUsers(request?: IFrontRequest) { }); } -export async function getRSForms(request?: IFrontRequest) { +export async function getRSForms(filter: RSFormsFilter, request?: IFrontRequest) { + let endpoint: string = '' + if (filter.type === FilterType.PERSONAL) { + endpoint = `${config.url.BASE}rsforms?owner=${filter.data!}` + } else { + endpoint = `${config.url.BASE}rsforms?is_common=true` + } + AxiosGet({ title: `RSForms list`, - endpoint: `${config.url.BASE}rsforms/`, + endpoint: endpoint, request: request }); } diff --git a/rsconcept/frontend/src/components/Common/Checkbox.tsx b/rsconcept/frontend/src/components/Common/Checkbox.tsx index e5ccd1d6..c08a753c 100644 --- a/rsconcept/frontend/src/components/Common/Checkbox.tsx +++ b/rsconcept/frontend/src/components/Common/Checkbox.tsx @@ -6,7 +6,7 @@ interface CheckboxProps { required?: boolean disabled?: boolean widthClass?: string - value?: any + value?: boolean onChange?: (event: React.ChangeEvent) => void } @@ -17,7 +17,7 @@ function Checkbox({id, required, disabled, label, widthClass='w-full', value, on className='relative cursor-pointer peer w-4 h-4 shrink-0 mt-0.5 bg-white border rounded-sm appearance-none dark:bg-gray-900 checked:bg-blue-700 dark:checked:bg-orange-500' required={required} disabled={disabled} - value={value} + checked={value} onChange={onChange} />