generated from IvettaGoIT/react_vite
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from MargoMarm/profilePage
Profile page
- Loading branch information
Showing
11 changed files
with
5,431 additions
and
110 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,50 +1,59 @@ | ||
import PropTypes from 'prop-types'; | ||
import { forwardRef, useState } from 'react'; | ||
import { forwardRef} from 'react'; | ||
import DatePicker, { registerLocale } from 'react-datepicker'; | ||
import 'react-datepicker/dist/react-datepicker-cssmodules.css'; | ||
import uk from 'date-fns/locale/uk'; | ||
import sub from 'date-fns/sub'; | ||
import { format } from 'date-fns'; | ||
import { Icon, Ipt, Label, GlobalStyles } from './Calendar.styled'; | ||
import sprite from '../../assets/sprite.svg'; | ||
import { Global } from '@emotion/react'; | ||
registerLocale('uk', uk); | ||
|
||
export default function Calendar({ name }) { | ||
const maxDate = sub(new Date(), { years: 18 }); | ||
const minDate = sub(new Date(), { years: 70 }); | ||
const [date, setDate] = useState(maxDate); | ||
|
||
const ExampleCustomInput = forwardRef(({ value, onClick }, ref) => ( | ||
<Label> | ||
<Ipt onClick={onClick} ref={ref} value={value} name={name} readOnly /> | ||
<Icon> | ||
<use href={`${sprite}#calendar`}></use> | ||
</Icon> | ||
</Label> | ||
)); | ||
export default function Calendar({ name, value, onChange, maxDate, minDate, showYearDropdown, dateFormat, withoutВorder }) { | ||
const ExampleCustomInput = forwardRef((dd, ref) => { | ||
const { onClick } = dd; | ||
return( | ||
<Label onClick={onClick} ref={ref}> | ||
<Ipt value={value ? format(value, dateFormat || "dd.MM.yyyy") : ''} name="name" readOnly withoutВorder={withoutВorder} /> | ||
<Icon> | ||
<use href={`${sprite}#calendar`}></use> | ||
</Icon> | ||
</Label> | ||
) | ||
}); | ||
|
||
ExampleCustomInput.displayName = 'Label'; | ||
|
||
return ( | ||
<> | ||
<DatePicker | ||
name={name} | ||
locale="uk" | ||
selected={date} | ||
onChange={date => setDate(date)} | ||
selected={value} | ||
onChange={date => { onChange(name, date) }} | ||
maxDate={maxDate} | ||
minDate={minDate} | ||
dateFormat="yyyy-MM-dd" | ||
yearDropdownItemNumber={40} | ||
customInput={<ExampleCustomInput />} | ||
scrollableYearDropdown | ||
showYearDropdown | ||
showYearDropdown={showYearDropdown} | ||
/> | ||
<Global styles={GlobalStyles} /> | ||
</> | ||
); | ||
} | ||
|
||
Calendar.propTypes = { | ||
onClick: PropTypes.func, | ||
name: PropTypes.string.isRequired, | ||
onClick:PropTypes.func, | ||
value: PropTypes.oneOfType([ | ||
PropTypes.string, | ||
PropTypes.instanceOf(Date) | ||
]).isRequired, | ||
onChange: PropTypes.func.isRequired, | ||
maxDate: PropTypes.instanceOf(Date), | ||
minDate: PropTypes.instanceOf(Date), | ||
showYearDropdown: PropTypes.bool, | ||
dateFormat: PropTypes.string, | ||
withoutВorder: PropTypes.bool, | ||
}; |
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
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
Oops, something went wrong.