company evaluation
This commit is contained in:
parent
6a26849a6f
commit
61da517719
5597
css/main/style.css
5597
css/main/style.css
File diff suppressed because one or more lines are too long
@ -2945,7 +2945,7 @@ main {
|
||||
}
|
||||
|
||||
&:nth-child(5) {
|
||||
word-break: break-all;
|
||||
word-break: break-word;
|
||||
width: 18%;
|
||||
}
|
||||
|
||||
@ -4214,7 +4214,8 @@ main .dropdown_blocks_list .dropdown_block .block_body {
|
||||
margin-top: auto;
|
||||
margin-left: auto;
|
||||
margin-right: 0;
|
||||
width: 343px;
|
||||
/*width: 343px;*/
|
||||
width: 250px;
|
||||
pointer-events: all;
|
||||
top: calc(100vh - 150px);
|
||||
/* tile shadow */
|
||||
@ -4229,9 +4230,75 @@ main .dropdown_blocks_list .dropdown_block .block_body {
|
||||
|
||||
&.opened {
|
||||
form {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
|
||||
textarea {
|
||||
min-height: 160px;
|
||||
}
|
||||
|
||||
button {
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
animation: rate_form 0.25s normal forwards ease-in-out;
|
||||
}
|
||||
width: 350px;
|
||||
// height: 400px;
|
||||
.rate_body {
|
||||
overflow: hidden;
|
||||
//height: 450px;
|
||||
|
||||
animation: rate_body_opened 0.25s normal forwards ease-in-out;
|
||||
|
||||
&.completed {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
animation: rate_body_shrink 0.25s normal forwards ease-in-out;
|
||||
}
|
||||
}
|
||||
animation: rate_opened 0.25s normal forwards ease-in-out;
|
||||
}
|
||||
|
||||
@keyframes rate_opened {
|
||||
from {
|
||||
width: 250px;
|
||||
}
|
||||
to {
|
||||
width: 350px;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes rate_body_opened {
|
||||
from {
|
||||
height: 110px;
|
||||
}
|
||||
to {
|
||||
height: 450px;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes rate_body_shrink {
|
||||
from {
|
||||
height: 450px;
|
||||
}
|
||||
to {
|
||||
height: 120px;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes rate_form {
|
||||
from {
|
||||
// transform: translate(-80px, -130px) scale(0.25, 0.25);
|
||||
transform: scale(0.5, 0.5);
|
||||
}
|
||||
to {
|
||||
// transform: translate(0px, 0px) scale(1, 1);
|
||||
transform: scale(1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
.rate_body {
|
||||
margin-left: auto;
|
||||
@ -4240,6 +4307,10 @@ main .dropdown_blocks_list .dropdown_block .block_body {
|
||||
width: 100%;
|
||||
padding: 16px 24px;
|
||||
box-shadow: 0px 4px 32px 0px rgba(0, 0, 0, 0.16);
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
p {
|
||||
@ -4248,12 +4319,14 @@ main .dropdown_blocks_list .dropdown_block .block_body {
|
||||
line-height: 23px;
|
||||
width: 100%;
|
||||
margin-bottom: 8px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.rate_start {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-direction: column;
|
||||
|
||||
p {
|
||||
text-align: center;
|
||||
@ -4268,7 +4341,7 @@ main .dropdown_blocks_list .dropdown_block .block_body {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
gap: 0 2px;
|
||||
gap: 0 0px;
|
||||
|
||||
label {
|
||||
width: 32px;
|
||||
|
||||
@ -1,115 +1,222 @@
|
||||
import React from "react"
|
||||
import { connect } from "react-redux"
|
||||
import { SpinnerCircular } from "spinners-react";
|
||||
import InputMask from 'react-input-mask';
|
||||
|
||||
class Rating extends React.Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
opened: false,
|
||||
rating: 0,
|
||||
hovered: 0,
|
||||
stars: []
|
||||
}
|
||||
import { sendNewAppeal } from "../../../actions"
|
||||
import { _checkStrValue } from "../../../utils";
|
||||
|
||||
let outOf = props.outOf ? props.outOf : 5
|
||||
class Rating extends React.Component
|
||||
{
|
||||
constructor(props)
|
||||
{
|
||||
super(props)
|
||||
this.state = {
|
||||
name: "",
|
||||
phone: "",
|
||||
comment: "",
|
||||
opened: false,
|
||||
rating: 0,
|
||||
hovered: 0,
|
||||
stars: [],
|
||||
completed: false,
|
||||
publish: false,
|
||||
loading: false,
|
||||
errors: [],
|
||||
}
|
||||
|
||||
for (var i = 0; i < outOf; i++) {
|
||||
this.state.stars.push(i + 1)
|
||||
}
|
||||
}
|
||||
let outOf = props.outOf ? props.outOf : 5
|
||||
|
||||
static getDerivedStateFromProps(nextProps, prevState) {
|
||||
return {}
|
||||
}
|
||||
for (var i = 0; i < outOf; i++) {
|
||||
this.state.stars.push(i + 1)
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {}
|
||||
static getDerivedStateFromProps(nextProps, prevState)
|
||||
{
|
||||
return {}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {}
|
||||
componentDidMount() {}
|
||||
|
||||
changeRating(newRating) {
|
||||
this.setState({
|
||||
rating: newRating
|
||||
})
|
||||
componentDidUpdate(prevProps, prevState) {}
|
||||
|
||||
if (this.props.onChange) this.props.onChange(newRating)
|
||||
}
|
||||
changeRating(newRating)
|
||||
{
|
||||
this.setState({
|
||||
rating: newRating
|
||||
})
|
||||
|
||||
hoverRating(rating) {
|
||||
this.setState({
|
||||
hovered: rating
|
||||
})
|
||||
}
|
||||
if (this.props.onChange) this.props.onChange(newRating)
|
||||
}
|
||||
|
||||
_handleRate = () => {
|
||||
if (this.state.rating > 0) {
|
||||
this.setState({
|
||||
opened: true
|
||||
})
|
||||
}
|
||||
}
|
||||
_handle_hoverRating(rating)
|
||||
{
|
||||
this.setState({
|
||||
hovered: rating,
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
const { opened, stars, rating, hovered } = this.state
|
||||
const data = ["Очень плохо", "Плохо", "Нормально", "Хорошо", "Отлично"]
|
||||
_handleRate = (newRating) =>
|
||||
{
|
||||
this.setState({
|
||||
rating: newRating,
|
||||
hovered: newRating,
|
||||
opened: true,
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={opened ? "rate_us opened" : "rate_us"}>
|
||||
<div className="rate_body">
|
||||
<p>Оцените нас</p>
|
||||
<div className="rate_start">
|
||||
<div className="stars">
|
||||
{stars.map((star) => {
|
||||
return (
|
||||
<label
|
||||
className={rating < star ? (hovered < star ? "" : "hover") : "active"}
|
||||
onClick={() => {
|
||||
this.changeRating(star)
|
||||
}}
|
||||
onMouseEnter={() => {
|
||||
this.hoverRating(star)
|
||||
}}
|
||||
onMouseLeave={() => {
|
||||
this.hoverRating(0)
|
||||
}}
|
||||
></label>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
{opened ? (
|
||||
<p>{data[this.state.rating - 1]}</p>
|
||||
) : (
|
||||
<button
|
||||
className="button button button-blue"
|
||||
onClick={() => {
|
||||
this._handleRate()
|
||||
}}
|
||||
>
|
||||
Оценить
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<form>
|
||||
<div className="form_field">
|
||||
<input type="text" value="" placeholder="Имя" />
|
||||
</div>
|
||||
<div className="form_field">
|
||||
<input type="text" value="" placeholder="Телефон" />
|
||||
</div>
|
||||
<div className="form_field">
|
||||
<textarea placeholder="Комментарий"></textarea>
|
||||
</div>
|
||||
<button type="submit" className="button button button-blue">
|
||||
Отправить
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
_handle_onFieldChange = (field, value) =>
|
||||
{
|
||||
const update = { ...this.state };
|
||||
update[field] = value;
|
||||
|
||||
this.setState(update);
|
||||
}
|
||||
|
||||
_removeError = (name) =>
|
||||
{
|
||||
const errors = [ ...this.state.errors ];
|
||||
|
||||
if(typeof name === "string")
|
||||
{
|
||||
if(errors.indexOf(name) > -1)
|
||||
{
|
||||
errors.splice(errors.indexOf(name), 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(let i in name)
|
||||
{
|
||||
if(errors.indexOf(name[i]) > -1)
|
||||
{
|
||||
errors.splice(errors.indexOf(name[i]), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.setState({ errors });
|
||||
}
|
||||
|
||||
_handle_onFormSubmit = (event) =>
|
||||
{
|
||||
event.preventDefault();
|
||||
|
||||
const { name, phone, comment, rating } = this.state;
|
||||
|
||||
const payload = {
|
||||
name: name,
|
||||
phone: phone,
|
||||
email: "",
|
||||
description: comment,
|
||||
contract_numbers: [],
|
||||
evaluation: rating,
|
||||
};
|
||||
|
||||
this.setState({ completed: true, loading: true }, () =>
|
||||
{
|
||||
sendNewAppeal(payload)
|
||||
.then((result) =>
|
||||
{
|
||||
this.setState({ completed: true, loading: false });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
render()
|
||||
{
|
||||
const { opened, stars, rating, hovered, completed, publish, loading, name, phone, comment, errors } = this.state
|
||||
const data = ["Очень плохо", "Плохо", "Нормально", "Хорошо", "Отлично"]
|
||||
|
||||
return (
|
||||
<div className={`rate_us ${ opened && "opened" }`}>
|
||||
<div className={`rate_body ${ completed && "completed" }`}>
|
||||
{ completed ? ( <>
|
||||
{ loading ? (
|
||||
<SpinnerCircular size={ 45 } thickness={ 51 } speed={ 100 } color="rgba(28, 1, 169, 1)" secondaryColor="rgba(236, 239, 244, 1)" />
|
||||
) : (
|
||||
<>
|
||||
<p>Спасибо за Вашу оценку!</p>
|
||||
<div className="form_field checkbox">
|
||||
<input type="checkbox"
|
||||
checked={ publish ? true : false }
|
||||
hidden=""
|
||||
id="rate_allow_publish"
|
||||
name="rate_allow_publish"
|
||||
onChange={ () => this.setState({ publish: this.state.publish ? false : true }) }
|
||||
/>
|
||||
<label htmlFor="rate_allow_publish" className="unselectable">Даю разрешение на публикацию своего отзыва в сети Интернет</label>
|
||||
</div>
|
||||
</>
|
||||
) }
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<p>Оцените нас</p>
|
||||
<div className="rate_start">
|
||||
<p>{ hovered > 0 ? data[ hovered - 1 ] : rating > 0 ? data[ rating - 1 ] : <> </> }</p>
|
||||
<div
|
||||
className="stars"
|
||||
>
|
||||
{ stars.map((star, index) => {
|
||||
return (
|
||||
<label key={ index }
|
||||
className={rating < star ? (hovered < star ? "" : "hover") : "active"}
|
||||
onClick={() =>
|
||||
{
|
||||
this._handleRate(star)
|
||||
}}
|
||||
onMouseEnter={() => {
|
||||
this._handle_hoverRating(star)
|
||||
}}
|
||||
onMouseLeave={() => {
|
||||
this._handle_hoverRating(0)
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
) }
|
||||
</div>
|
||||
</div>
|
||||
<form onSubmit={ this._handle_onFormSubmit }>
|
||||
<div className="form_field">
|
||||
<input type="text" placeholder="Имя" name="name" onChange={ (event) => this._handle_onFieldChange(event.target.name, event.target.value) } defaultValue={ name }/>
|
||||
</div>
|
||||
<div className="form_field">
|
||||
<InputMask
|
||||
className={ errors.indexOf("phone") > -1 ? "error" : "" }
|
||||
mask='+7 (999) 999 99 99'
|
||||
id="phone"
|
||||
name="phone"
|
||||
value={ _checkStrValue(phone) }
|
||||
placeholder="Телефон"
|
||||
onChange={ (event) => { if(event.target.value !== "" && !isNaN(parseInt(event.target.value.replace(/[^\d]+/g, ''), 10)) && parseInt(event.target.value.replace(/[^\d]+/g, ''), 10) > 7) { this._removeError("phone"); } this._handle_onFieldChange(event.target.name, event.target.value); } }
|
||||
/>
|
||||
</div>
|
||||
<div className="form_field">
|
||||
<textarea
|
||||
name="comment"
|
||||
placeholder="Комментарий"
|
||||
onChange={ (event) => this._handle_onFieldChange(event.target.name, event.target.value) }
|
||||
defaultValue={ comment }
|
||||
required={ rating > 1 ? false : true }
|
||||
/>
|
||||
</div>
|
||||
<button type="submit" className="button button button-blue">
|
||||
Отправить
|
||||
</button>
|
||||
</form>
|
||||
</>
|
||||
) }
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function mapStateToProps(state, ownProps) {
|
||||
return {}
|
||||
function mapStateToProps(state, ownProps)
|
||||
{
|
||||
return {}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps)(Rating)
|
||||
|
||||
@ -21,8 +21,6 @@ import AccountLayout from "./components/Layout/Account"
|
||||
import ContractStatus from "./components/ContractStatus"
|
||||
import AnnouncementsList from "./components/AnnouncementsList"
|
||||
|
||||
import { getContractsList, getImage } from "../actions"
|
||||
|
||||
import { getCompanyInfo, getContractsList, getImage } from '../actions';
|
||||
class IndexPage extends React.Component
|
||||
{
|
||||
|
||||
6
utils/index.js
Normal file
6
utils/index.js
Normal file
@ -0,0 +1,6 @@
|
||||
const _checkStrValue = (value) =>
|
||||
{
|
||||
return value !== undefined && value !== null ? value.toString() : "";
|
||||
}
|
||||
|
||||
export { _checkStrValue }
|
||||
Loading…
x
Reference in New Issue
Block a user