Skip to content

Commit

Permalink
chore: remove unused page (jotform feature)
Browse files Browse the repository at this point in the history
  • Loading branch information
iacopolea committed Jun 26, 2024
1 parent 5b5f745 commit 722bb87
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 12 deletions.
8 changes: 3 additions & 5 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import EditPreselectionForm from "src/pages/preselectionForms/edit";
import { setupStore } from "src/store";
import { PageTemplate } from "./features/PageTemplate";
import SentryWrapper from "./features/SentryWrapper";
import Jotform from "./pages/Jotform";
import Prospect from "./pages/Prospect";
import UxDashboard from "./pages/UxDashboard";
import AgreementsList from "./pages/agreements/list";
Expand Down Expand Up @@ -50,17 +49,16 @@ function App() {
path="/backoffice/payments"
component={AdminPayments}
/>
<SentryRoute path="/backoffice/jotform" component={Jotform} />
<SentryRoute
path="/backoffice/campaigns/preselection-forms/new"
path="/backoffice/preselection-forms/new"
component={NewPreselectionForm}
/>
<SentryRoute
path="/backoffice/campaigns/preselection-forms/:id"
path="/backoffice/preselection-forms/:id"
component={EditPreselectionForm}
/>
<SentryRoute
path="/backoffice/campaigns/preselection-forms"
path="/backoffice/preselection-forms"
component={CampaignPreselectionList}
/>
<SentryRoute
Expand Down
10 changes: 7 additions & 3 deletions src/features/AuthorizedOnlyContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { Container } from "@appquality/appquality-design-system";
import React from "react";
import ErrorUnauthorized from "src/features/ErrorUnauthorized/ErrorUnauthorized";
import useUserData from "src/pages/Jotform/useUserData";
import { useGetUsersMeQuery } from "src/services/tryberApi";

export const AuthorizedOnlyContainer: React.FC<{
excludeRule: boolean;
children: React.ReactNode;
isFluid?: boolean;
}> = ({ children, excludeRule, isFluid }) => {
const { isFetching, isError, isLoading } = useUserData();
const { isError, isFetching, isLoading } = useGetUsersMeQuery({
fields: "role",
});
if (isLoading || isFetching) return <Container>loading...</Container>;
if (isError) return <Container>there was an error</Container>;
if (excludeRule)
Expand All @@ -23,7 +25,9 @@ export const AuthorizedOnlyContainer: React.FC<{
export const OpsUserContainer: React.FC<{ children: React.ReactNode }> = ({
children,
}) => {
const { data } = useUserData();
const { data } = useGetUsersMeQuery({
fields: "role",
});
return (
<AuthorizedOnlyContainer
excludeRule={data?.role === "tester" || data?.role === "subscriber"}
Expand Down
1 change: 1 addition & 0 deletions src/pages/preselectionForms/components/FormProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Form, Formik } from "@appquality/appquality-design-system";
import useCufData from "../hooks/useCufData";
import { useHistory } from "react-router-dom";
import siteWideMessageStore from "src/redux/siteWideMessages";
import { scrollToFormTitle } from "../functions/scrollToFormTitle";

interface FormProviderInterface {
savedData?: GetCampaignsFormsByFormIdApiResponse;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import {
Select,
FormGroup,
ErrorMessage,
} from "@appquality/appquality-design-system";
import { Option } from "@appquality/appquality-design-system/dist/stories/select/_types";
import { Field, FieldProps } from "formik";
import { useMemo } from "react";

const optionAll = [{ label: "All options", value: "-1" }];

export const CufMultiselect = ({
label,
options,
name,
}: {
label: string;
options: Option[];
name: string;
}) => {
const selectOptions = useMemo(
() =>
options.map((option) => ({
label: option.label,
value: option.value,
})),
[options]
);
return (
<div className="aq-mb-3">
<Field
name={name}
validate={(value: string) => {
if (!value || !value.length) {
return "This is a required field";
}
}}
>
{({
field, // { name, value, onChange, onBlur }
form,
}: FieldProps) => {
return (
<FormGroup>
<Select
key={name}
name={name}
value={field.value || []}
options={
field.value?.some((v: any) => v.value === "-1")
? optionAll
: [...optionAll, ...selectOptions]
}
onBlur={() => {
form.setFieldTouched(name);
}}
label={label}
placeholder={"Select options"}
menuTargetQuery="body"
noOptionsMessage={() => "No options"}
onChange={(v) => {
if (v === null) {
v = { label: "", value: "" };
}
form.setFieldValue(field.name, v, true);
if (v?.some((v: any) => v.value === "-1"))
form.setFieldValue(field.name, optionAll, true);
}}
isMulti
/>
<ErrorMessage name={name} />
</FormGroup>
);
}}
</Field>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { FC, useEffect } from "react";
import { OptionsField } from "src/pages/preselectionForms/components/formConfigurator/OptionsField";
import { CufMultiselect } from "src/pages/Jotform/CufConfigurator/CufMultiselect";
import {
aqBootstrapTheme,
Card,
Expand All @@ -12,6 +11,7 @@ import { DropZone } from "src/pages/preselectionForms/components/formConfigurato
import { XLg, GripVertical } from "react-bootstrap-icons";
import { ShortTitleField } from "./ShortTitleField";
import styled from "styled-components";
import { CufMultiselect } from "./CufMultiselect";

const StyledInlineField = styled.div`
display: flex;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function scrollToFormTitle() {
export function scrollToFormTitle() {
const selector = `[id="formTitle"]`;
const formTitleElement = document.querySelector(selector) as HTMLElement;
formTitleElement?.scrollIntoView({
Expand Down
4 changes: 4 additions & 0 deletions src/pages/preselectionForms/singleSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import { v4 as uuidv4 } from "uuid";
import { GetCampaignsFormsByFormIdApiResponse } from "../../services/tryberApi";

interface CufField {
fieldData: ApiComponents["schemas"]["CustomUserFieldsData"];
checked: boolean;
}
interface PreselectionFormState {
profileFieldsList: ProfileField[];
cufList: CufField[];
Expand Down
2 changes: 0 additions & 2 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { configureStore, PreloadedState } from "@reduxjs/toolkit";
import { tryberApiSlice } from "src/services/tryberApi/apiTags";
import oldReducers from "src/redux/reducer";
import { combineReducers } from "redux";
import jotformReducer from "src/pages/Jotform/jotformSlice";
import campaignPreselectionReducer from "src/pages/preselectionForms/singleSlice";
import campaignPreselectionListReducer from "src/pages/preselectionForms/listSlice";
import selectionReducer from "src/pages/campaigns/selection/selectionSlice";
Expand All @@ -12,7 +11,6 @@ import type { TypedUseSelectorHook } from "react-redux";

const rootReducer = combineReducers({
...oldReducers,
jotform: jotformReducer,
campaignPreselection: campaignPreselectionReducer,
campaignPreselectionList: campaignPreselectionListReducer,
selection: selectionReducer,
Expand Down

0 comments on commit 722bb87

Please sign in to comment.