-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4c47425
commit e8454ef
Showing
21 changed files
with
610 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,4 @@ | |
|
||
.vacancy-card__title-button_delete { | ||
color: #f0924f; | ||
margin-left: 8px; | ||
font-size: 22.3px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,6 @@ | |
} | ||
|
||
.about-shelter__title-button_delete { | ||
color: #d83e3e; | ||
color: var(--color-verify-invalid); | ||
margin-left: 8px; | ||
} |
153 changes: 153 additions & 0 deletions
153
src/modules/ShelterVacancies/AddVacancyForm/AddVacancyForm.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import './AddVacancyForm.scss'; | ||
import Button from '../../../ui/Button/Button'; | ||
import useInput from '../../../hooks/useInput'; | ||
import DeclarationInput from '../../../ui/DeclarationInput/DeclarationInput'; | ||
import Select from '../../../ui/Select/Select'; | ||
import * as regex from '../../../utils/regex'; | ||
import * as errorMessage from '../../../utils/errorMessage'; | ||
|
||
const AddVacancyForm = () => { | ||
const [formValues, setFormValues] = useState({ | ||
schedule: [], | ||
salary: null, | ||
education: '', | ||
is_ndfl: '', | ||
description: '', | ||
position: '', | ||
}); | ||
|
||
const vacancyName = useInput('', { notEmpty: true, maxLength: 30, regex: regex.NAME_REGEX }, errorMessage.VACANCY_NAME); | ||
const vacancySalary = useInput('', { notEmpty: true, maxLength: 12, regex: regex.NUMBER }, errorMessage.VACANCY_SALARY); | ||
const vacancyDescription = useInput('', { notEmpty: true, maxLength: 3000, regex: regex.TEXT }, errorMessage.VACANCY_DESCRIPTION); | ||
|
||
const [isChecked, setIsChecked] = useState(false); | ||
|
||
const handleChangeCheckbox = () => { | ||
setIsChecked(!isChecked); | ||
}; | ||
|
||
const isFormButtonDisabled = | ||
vacancyName.invalidText || | ||
vacancySalary.invalidText || | ||
vacancyDescription.invalidText || | ||
!isChecked || | ||
formValues.education.length !== 0 || | ||
formValues.schedule.length === 0; | ||
|
||
// TODO написать api для отправки формы в след PR | ||
const handleSubmit = (evt) => { | ||
evt.preventDefault(); | ||
console.log('submit'); | ||
}; | ||
|
||
const handleDesctiptionChange = (evt) => { | ||
vacancyDescription.onChange(evt); | ||
|
||
setFormValues((prevValues) => { | ||
return { | ||
...prevValues, | ||
description: evt.target.value, | ||
}; | ||
}); | ||
}; | ||
|
||
useEffect(() => { | ||
setFormValues((prevValues) => { | ||
return { | ||
...prevValues, | ||
salary: vacancySalary.value, | ||
position: vacancyName.value, | ||
}; | ||
}); | ||
}, [vacancySalary.value, vacancyName.value]); | ||
|
||
const handleSelectChange = (id, selected) => { | ||
setFormValues((prevValues) => { | ||
return { | ||
...prevValues, | ||
[id]: selected, | ||
}; | ||
}); | ||
}; | ||
|
||
// TODO бэк сказал сделал эндпоинты для селектов, пока замокала, в след PR | ||
const shiftItems = [ | ||
{ label: 'Полный день', id: 'slug1' }, | ||
{ label: 'Сменный', id: 'slug2' }, | ||
{ label: 'Гибкий', id: 'slug3' }, | ||
{ label: 'Удаленная работа', id: 'slug4' }, | ||
]; | ||
|
||
const salaryItems = [ | ||
{ label: 'На руки', id: '11' }, | ||
{ label: 'с НДФЛ', id: '22' }, | ||
]; | ||
|
||
const educationItems = [ | ||
{ label: 'Не требуется', id: '111' }, | ||
{ label: 'Среднее специальное', id: '222' }, | ||
{ label: 'Высшее', id: '333' }, | ||
]; | ||
|
||
return ( | ||
<form className='add-vacancy-form__container' onSubmit={handleSubmit}> | ||
<DeclarationInput caption='Название вакансии*' inputState={vacancyName} type='text' name='vacancyName' required /> | ||
|
||
<div className='add-vacancy-form__flex-container'> | ||
<DeclarationInput caption='Заработная плата*' inputState={vacancySalary} type='number' name='vacancySalary' required placeholder='₽' /> | ||
|
||
<Select label='Тип оплаты*' onChange={handleSelectChange} options={salaryItems} isMulti={false} required /> | ||
</div> | ||
|
||
<div className='add-vacancy-form__flex-container'> | ||
<Select label='График работы*' onChange={handleSelectChange} options={shiftItems} id='schedule' isMulti required /> | ||
|
||
<Select label='Образование*' onChange={handleSelectChange} options={educationItems} isMulti={false} required /> | ||
</div> | ||
|
||
<p className='add-vacancy-form__desctioption-title'>Обязанности*</p> | ||
<textarea | ||
className={`add-vacancy-form__description ${vacancyDescription.dirty && vacancyDescription.invalidText && 'add-vacancy-form__textarea_invalid'}`} | ||
value={vacancyDescription.value} | ||
onChange={handleDesctiptionChange} | ||
onBlur={vacancyDescription.onBlur} | ||
name='description' | ||
required | ||
/> | ||
<p className='add-shelter-form__error'>{vacancyDescription.dirty && vacancyDescription.invalidText}</p> | ||
|
||
{/* TODO вынести соглашение в отдельный компонент, используется еще в 2х местах, это взято ShelterStep */} | ||
<div className='register__privacy'> | ||
{/* TODO этот checkbox уже на макете выглядит по другому, поменять везде */} | ||
<label className='checkbox__container'> | ||
<input className='checkbox__input' type='checkbox' onClick={handleChangeCheckbox} /> | ||
<span className='checkbox' /> | ||
</label> | ||
|
||
<p className='register__text standard-font standard-font_type_small'> | ||
Я согласен с{' '} | ||
<Link className='register__link standard-font standard-font_type_small' to='/privacy' target='_blank'> | ||
Политикой конфиденциальности | ||
</Link>{' '} | ||
и{' '} | ||
<Link className='register__link standard-font standard-font_type_small' to='/terms' target='_blank'> | ||
Условиями использования сервиса | ||
</Link> | ||
</p> | ||
</div> | ||
|
||
<div className='add-shelter-form__submit-buttons'> | ||
<Button submit disabled={isFormButtonDisabled}> | ||
Добавить вакансию | ||
</Button> | ||
|
||
{/* TODO добавить логику кнопки Отменить, она стирает все значения и убирает рендеринг формы */} | ||
<Button>Отменить</Button> | ||
</div> | ||
</form> | ||
); | ||
}; | ||
|
||
export default AddVacancyForm; |
39 changes: 39 additions & 0 deletions
39
src/modules/ShelterVacancies/AddVacancyForm/AddVacancyForm.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
.add-vacancy-form__flex-container { | ||
display: flex; | ||
gap: 16px; | ||
justify-content: space-between; | ||
} | ||
|
||
.add-vacancy-form__container { | ||
margin-top: 36px; | ||
width: 576px; | ||
} | ||
|
||
.add-shelter-form__submit-buttons { | ||
display: flex; | ||
gap: 32px; | ||
margin-top: 40px; | ||
} | ||
|
||
.add-vacancy-form__description { | ||
width: 100%; | ||
height: 120px; | ||
margin: 0; | ||
padding: 16px 10.5px; | ||
font-size: 16px; | ||
line-height: 19px; | ||
font-weight: 400; | ||
background-color: var(--color-background-additional); | ||
border: 1px solid var(--color-text-additional); | ||
border-radius: 8px; | ||
box-sizing: border-box; | ||
resize: none; | ||
|
||
&_invalid { | ||
border-color: var(--color-verify-invalid); | ||
} | ||
} | ||
|
||
.add-vacancy-form__desctioption-title { | ||
margin-bottom: 10px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import VacancyCard from '../../components/VacancyCard/VacancyCard'; | ||
import './ShelterVacancies.scss'; | ||
|
||
const VacancyList = ({ vacancies, isLoading }) => { | ||
if (!vacancies.length) { | ||
return <p className='standard-font shelter__empty-list'>У приюта нет активных вакансий</p>; | ||
} | ||
|
||
return ( | ||
<ul className='shelter__vacancies-list'> | ||
{vacancies.map((card) => { | ||
return ( | ||
<VacancyCard | ||
isLoading={isLoading} | ||
key={card.id} | ||
id={card.id} | ||
education={card.education} | ||
title={card.position} | ||
salary={card.salary} | ||
schedule={card.schedule} | ||
description={card.description} | ||
/> | ||
); | ||
})} | ||
</ul> | ||
); | ||
}; | ||
|
||
export default VacancyList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ | |
padding: 0; | ||
flex-direction: column; | ||
list-style-type: none; | ||
} | ||
width: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
display: flex; | ||
width: 100%; | ||
justify-content: space-between; | ||
} | ||
gap: 48px; | ||
} |
Oops, something went wrong.