feat: Add Incomplete error state in stepper (#121)

* feat: Add Incomplete error state in stepper

* feat: Remove Incomplete stepper step 2 error when click on back button
This commit is contained in:
Awais Ansari
2021-06-01 11:08:22 +05:00
committed by GitHub
parent 54aea97fab
commit 12fd5cdc83
2 changed files with 16 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
import React, { useState, useEffect } from 'react';
import { useDispatch } from 'react-redux';
import PropTypes from 'prop-types';
import {
Collapsible, Form, Card, Button, IconButton, Icon,
@@ -7,6 +8,9 @@ import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { useFormikContext } from 'formik';
import { ExpandLess, ExpandMore, Delete } from '@edx/paragon/icons';
import messages from '../messages';
import {
updateValidationStatus,
} from '../../../../data/slice';
const TopicItem = ({
intl, index, name, onDelete,
@@ -19,11 +23,18 @@ const TopicItem = ({
touched,
errors,
} = useFormikContext();
const dispatch = useDispatch();
useEffect(() => {
setTitle(name);
}, [name]);
useEffect(() => {
if (Object.keys(touched).length) {
dispatch(updateValidationStatus({ hasError: Object.keys(errors).length > 0 }));
}
}, [errors, touched]);
const isInvalidTopicNameKey = Boolean(
(touched.discussionTopics && touched.discussionTopics[index]?.name)
&& (errors.discussionTopics && errors?.discussionTopics[index]?.name),

View File

@@ -4,7 +4,10 @@ import { CardGrid, Container, breakpoints } from '@edx/paragon';
import { useDispatch, useSelector } from 'react-redux';
import Responsive from 'react-responsive';
import { useModels } from '../../../generic/model-store';
import { selectApp, LOADED, LOADING } from '../data/slice';
import {
selectApp, LOADED, LOADING,
updateValidationStatus,
} from '../data/slice';
import AppCard from './AppCard';
import messages from './messages';
import FeaturesTable from './FeaturesTable';
@@ -30,6 +33,7 @@ function AppList({ intl }) {
if (!selectedAppId) {
dispatch(selectApp({ appId: activeAppId }));
}
dispatch(updateValidationStatus({ hasError: false }));
}, [selectedAppId, activeAppId]);
const handleSelectApp = useCallback((appId) => {