Merge pull request #37 from apuc/quiz-error-msg

Quiz error msg
This commit is contained in:
kavalar 2022-10-20 13:02:23 +03:00 committed by GitHub
commit 1651968337
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 106 additions and 22011 deletions

21983
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -26,8 +26,9 @@ const ReportForm = () => {
const dispatch = useDispatch() const dispatch = useDispatch()
const history = useHistory() const history = useHistory()
const role = useSelector(getRole) const role = useSelector(getRole)
const [isFetching, setIsFetching] = useState(false) const [isFetching, setIsFetching] = useState(false)
const [reportSuccess, setReportSuccess] = useState(false)
const [inputs, setInputs] = useState([ { task: '', hours_spent: '', minutes_spent: 0 } ]); const [inputs, setInputs] = useState([ { task: '', hours_spent: '', minutes_spent: 0 } ]);
const [troublesInputValue, setTroublesInputValue] = useState(''); const [troublesInputValue, setTroublesInputValue] = useState('');
@ -37,8 +38,10 @@ const ReportForm = () => {
setInputs((prev) => [...prev, { task: '', hours_spent: '', minutes_spent: 0 }]) setInputs((prev) => [...prev, { task: '', hours_spent: '', minutes_spent: 0 }])
} }
const totalHours = inputs.reduce((a,b) => a + b.hours_spent, 0)
const deleteInput = (indexRemove) => { const deleteInput = (indexRemove) => {
if (indexRemove !== 1) { if (indexRemove !== 0) {
setInputs((prev) => prev.filter((el, index) => index !== indexRemove)) setInputs((prev) => prev.filter((el, index) => index !== indexRemove))
} }
} }
@ -152,6 +155,10 @@ const ReportForm = () => {
logout: () => dispatch(auth(false)) logout: () => dispatch(auth(false))
}).then((res) => }).then((res) =>
res.json().then((resJSON) => { res.json().then((resJSON) => {
if(res.status === 200) {
setReportSuccess(true)
setTimeout(()=> setReportSuccess(false),2000)
}
setInputs( () => [] ) setInputs( () => [] )
setTroublesInputValue(''); setTroublesInputValue('');
setScheduledInputValue(''); setScheduledInputValue('');
@ -163,8 +170,11 @@ const ReportForm = () => {
{isFetching ? <Loader /> : 'Отправить'} {isFetching ? <Loader /> : 'Отправить'}
</button> </button>
<p className='report-form__footer-text'> <p className='report-form__footer-text'>
Всего за день : <span>60 часов</span> Всего за день : <span>{totalHours} часов</span>
</p> </p>
{reportSuccess &&
<p className='report-form__footer-done'>Отчет отправлен</p>
}
</div> </div>
</div> </div>
</div> </div>

View File

@ -264,6 +264,14 @@
font-weight: 100; font-weight: 100;
} }
} }
&-done {
margin-bottom: 0;
font-size: 18px;
color: green;
font-weight: 500;
margin-left: 20px;
}
} }
&__form { &__form {

View File

@ -26,21 +26,25 @@ export const HeaderQuiz = ({header}) => {
}, [dispatch]) }, [dispatch])
return ( return (
<div className="header-quiz"> <div>
<div className="header-quiz__container"> { userInfo?.status === 500 ? <div className="error-msg">{userInfo.message}</div> :
{!userInfo ? <h2>Loading...</h2> : <div className="header-quiz">
<> <div className="header-quiz__container">
{header && <h2 className={'header-quiz__title-main'}>Добрый день, {userInfo.fio}</h2>} {!userInfo ? <h2>Loading...</h2> :
<div className="header-quiz__body header-quiz__body_interjacent"> <>
<div className="header-quiz__avatar"> {header && <h2 className={'header-quiz__title-main'}>Добрый день, {userInfo.fio}</h2>}
<img src={userInfo.photo} alt={userInfo.photo}/> <div className="header-quiz__body header-quiz__body_interjacent">
</div> <div className="header-quiz__avatar">
<div className="header-quiz__name-user">{userInfo.fio}</div> <img src={userInfo.photo} alt={userInfo.photo}/>
<div className="header-quiz__title">{userInfo.position_name}</div> </div>
</div> <div className="header-quiz__name-user">{userInfo.fio}</div>
</> <div className="header-quiz__title">{userInfo.position_name}</div>
} </div>
</div> </>
</div> }
</div>
</div>
}
</div>
) )
} }

View File

@ -1,4 +1,4 @@
@use 'sass:math'; @use 'sass:math';
@import 'functions.scss'; @import 'functions.scss';
$maxWidthContainer: 1123; $maxWidthContainer: 1123;
@ -11,8 +11,8 @@ $maxWidthContainer: 1123;
.quiz-text{ .quiz-text{
font-size: 20px; font-size: 20px;
font-weight: 400; font-weight: 400;
line-height: math.div(30, 20); line-height: math.div(30, 20);
} }
.title{ .title{
color: #282828; color: #282828;
@ -58,7 +58,7 @@ $maxWidthContainer: 1123;
text-decoration: none; text-decoration: none;
color: #1a310c; color: #1a310c;
background: #fff; background: #fff;
} }
} }
&_restriction{ &_restriction{
max-width: 131px; max-width: 131px;
@ -69,9 +69,17 @@ $maxWidthContainer: 1123;
font-family: "GT Eesti Pro Display"; font-family: "GT Eesti Pro Display";
font-size: 25px; font-size: 25px;
font-weight: 400; font-weight: 400;
line-height: math.div(30, 25); line-height: math.div(30, 25);
} }
//============================================= //=============================================
.error-msg {
text-align: center;
font-size: 25px;
color: red;
font-weight: 500;
}
.header-quiz{ .header-quiz{
@include adaptiv-value("padding-top", 48, 30, 1); @include adaptiv-value("padding-top", 48, 30, 1);
@include adaptiv-value("padding-bottom", 85, 30, 1); @include adaptiv-value("padding-bottom", 85, 30, 1);
@ -120,16 +128,16 @@ $maxWidthContainer: 1123;
color: #000000; color: #000000;
font-family: "GT Eesti Pro Display"; font-family: "GT Eesti Pro Display";
font-size: 16px; font-size: 16px;
font-weight: 400; font-weight: 400;
line-height: math.div(30, 20); line-height: math.div(30, 20);
margin-right: 70px; margin-right: 70px;
} }
&__title{ &__title{
color: #000000; color: #000000;
font-family: "GT Eesti Pro Display"; font-family: "GT Eesti Pro Display";
@include adaptiv-value("font-size", 25, 16, 1); @include adaptiv-value("font-size", 25, 16, 1);
font-weight: 700; font-weight: 700;
line-height: math.div(36, 25); line-height: math.div(36, 25);
position: relative; position: relative;
&::before{ &::before{
@ -140,7 +148,7 @@ $maxWidthContainer: 1123;
border-radius: 3px; border-radius: 3px;
background-color: #54b611; background-color: #54b611;
bottom: -26px; bottom: -26px;
} }
} }
} }
.my-tests{ .my-tests{
@ -155,9 +163,9 @@ $maxWidthContainer: 1123;
&__title{ &__title{
color: #000000; color: #000000;
font-size: 25px; font-size: 25px;
font-weight: 400; font-weight: 400;
line-height: math.div(30, 25); line-height: math.div(30, 25);
@include adaptiv-value("margin-bottom", 80, 30, 1); @include adaptiv-value("margin-bottom", 80, 30, 1);
} }
&__items{ &__items{
display: flex; display: flex;
@ -175,21 +183,21 @@ $maxWidthContainer: 1123;
flex: 0 1 100%; flex: 0 1 100%;
} }
&__name-test{ &__name-test{
color: #373936; color: #373936;
margin-bottom: 29px; margin-bottom: 29px;
} }
.active{ .active{
color: #54b611; color: #54b611;
} }
&__body{ &__body{
} }
} }
.test-data{ .test-data{
display: flex; display: flex;
align-items: center; align-items: center;
&__calendar{ &__calendar{
padding: 13px 21px; padding: 13px 21px;
box-shadow: 0 0 59px rgba(44, 44, 44, 0.05); box-shadow: 0 0 59px rgba(44, 44, 44, 0.05);
@ -243,8 +251,8 @@ $maxWidthContainer: 1123;
} }
&__strip{ &__strip{
flex: 1 1 auto; flex: 1 1 auto;
height: 19px; height: 19px;
div{ div{
border-radius: 10px; border-radius: 10px;
height: 100%; height: 100%;
@ -260,11 +268,11 @@ $maxWidthContainer: 1123;
margin: 0 auto; margin: 0 auto;
padding: 0 10px; padding: 0 10px;
} }
&__title{ &__title{
margin-bottom: 39px; margin-bottom: 39px;
} }
&__form{ &__form{
} }
} }
@ -286,22 +294,22 @@ $maxWidthContainer: 1123;
width: initial; width: initial;
margin-bottom: 0; margin-bottom: 0;
display: none; display: none;
cursor: pointer; cursor: pointer;
} }
&__buttons{ &__buttons{
display: flex; display: flex;
gap: 56px; gap: 56px;
flex-wrap: wrap; flex-wrap: wrap;
align-items: center; align-items: center;
@include adaptiv-value("margin-top", 60, 30, 1); @include adaptiv-value("margin-top", 60, 30, 1);
} }
} }
.form-task__group{ .form-task__group{
display: block; display: block;
margin-bottom: 15px; margin-bottom: 15px;
label { label {
color: #373936; color: #373936;
font-family: "GT Eesti Pro Display"; font-family: "GT Eesti Pro Display";
@ -359,8 +367,8 @@ $maxWidthContainer: 1123;
font-family: "GT Eesti Pro Display"; font-family: "GT Eesti Pro Display";
font-size: 18px; font-size: 18px;
font-weight: 300; font-weight: 300;
line-height: math.div(28, 18); line-height: math.div(28, 18);
@include adaptiv-value("margin-bottom", 50, 20, 1); @include adaptiv-value("margin-bottom", 50, 20, 1);
span{ span{
color: #54b611; color: #54b611;
font-weight: 700; font-weight: 700;
@ -399,4 +407,4 @@ $maxWidthContainer: 1123;
&__score{ &__score{
color: #5cb42b; color: #5cb42b;
} }
} }