refactor extract alert interface

This commit is contained in:
Ruidy Nemausat 2020-05-15 09:35:35 +02:00
parent 1b6ee31cb3
commit 1a4930e220
2 changed files with 20 additions and 11 deletions

View file

@ -2,8 +2,8 @@ import React, {FC, useState} from 'react';
import {Link} from 'react-router-dom';
import Routes from '../constants/routes';
// Redux
import {enhance, selectProfile} from '../store/firebase';
import {WithFirebaseProps, isLoaded, isEmpty} from 'react-redux-firebase';
import {enhance} from '../store/firebase';
import {WithFirebaseProps} from 'react-redux-firebase';
// Style
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {
@ -14,15 +14,15 @@ import {
faInstagram,
} from '@fortawesome/free-brands-svg-icons';
import FormHeader from '../components/FormHeader';
import Alert from '../components/Alert';
import Statuses from '../constants/statuses';
// Form
import useForm from '../hooks';
import User from '../models/User';
// Typing
import Dev from '../models/Dev';
import User from '../models/User';
import Links from '../types/Links';
import {useSelector} from 'react-redux';
import Alert from '../components/Alert';
import IAlert, {formAlert} from '../types/Alert';
interface FormData {
status: string;
@ -54,11 +54,7 @@ const EditProfile: FC<IProps> = ({
bio,
}) => {
const [showLinks, setShowLinks] = useState(false);
const [alert, setAlert] = useState({
show: false,
color: 'danger',
text: 'Something went wrong',
});
const [alert, setAlert] = useState<IAlert>(formAlert);
const initFormData = {
status: status ?? 'Developer',

13
src/types/Alert.ts Normal file
View file

@ -0,0 +1,13 @@
interface IAlert {
show: boolean;
color: string;
text: string;
}
export const formAlert: IAlert = {
show: false,
color: 'danger',
text: 'Something went wrong',
};
export default IAlert;