Skip to content

Commit

Permalink
feat(insight-modal):set-max-length-for-description-to-350
Browse files Browse the repository at this point in the history
  • Loading branch information
iDome89 committed Oct 3, 2023
1 parent 1965b26 commit f628235
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/pages/UxDashboard/UxForm/FormProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export interface FormValuesInterface {

export const sentimentNoteMaxChar = 100;
export const videoCitMaxChar = 150;
export const insightDescriptionMaxChar = 350;
const FormProvider = ({ children }: { children: ReactNode }) => {
const { add } = siteWideMessageStore();
const { id } = useParams<{ id: string }>();
Expand Down Expand Up @@ -179,7 +180,12 @@ const FormProvider = ({ children }: { children: ReactNode }) => {
object().shape({
id: number(),
title: string().required("Campo obbligatorio"),
description: string().required("Campo obbligatorio"),
description: string()
.max(
insightDescriptionMaxChar,
`Massimo ${insightDescriptionMaxChar} caratteri`
)
.required("Campo obbligatorio"),
severity: object()
.shape({
id: number().required("Campo obbligatorio"),
Expand Down
15 changes: 13 additions & 2 deletions src/pages/UxDashboard/UxForm/Insights/InsightModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import styled from "styled-components";
import SeverityField from "../components/fields/SeverityField";
import ClusterField from "../components/fields/ClusterField";
import VideoParts from "../VideoParts";
import { FormValuesInterface } from "../FormProvider";
import {
FormValuesInterface,
insightDescriptionMaxChar,
} from "../FormProvider";
import { useMemo } from "react";
import { fieldName } from ".";

Expand Down Expand Up @@ -160,8 +163,16 @@ const InsightModal = ({ remove }: InsightModalProps) => {
<div data-qa="insight-description">
<TextareaField
height="8em"
counterMax={insightDescriptionMaxChar}
name={`${fieldName}[${insightIndex}].description`}
label="Description"
label={
<div>
Descrizione{" "}
<strong>
(Massimo {insightDescriptionMaxChar} caratteri)
</strong>
</div>
}
/>
</div>
</BSCol>
Expand Down

0 comments on commit f628235

Please sign in to comment.