2022-01-05 19:43:40 +03:00
|
|
|
import React, { FunctionComponent } from 'react';
|
|
|
|
import datetime from '../../../scripts/datetime';
|
|
|
|
import globalize from '../../../scripts/globalize';
|
|
|
|
|
2022-02-18 14:27:39 +03:00
|
|
|
const createButtonElement = (index: number) => ({
|
2022-01-05 19:43:40 +03:00
|
|
|
__html: `<button
|
|
|
|
type='button'
|
|
|
|
is='paper-icon-button-light'
|
|
|
|
class='btnDelete listItemButton'
|
|
|
|
data-index='${index}'
|
|
|
|
>
|
2022-02-24 20:15:24 +03:00
|
|
|
<span class='material-icons delete' aria-hidden='true' />
|
2022-01-05 19:43:40 +03:00
|
|
|
</button>`
|
|
|
|
});
|
|
|
|
|
|
|
|
type IProps = {
|
|
|
|
index: number;
|
|
|
|
Id: number;
|
|
|
|
DayOfWeek?: string;
|
|
|
|
StartHour?: number ;
|
|
|
|
EndHour?: number;
|
|
|
|
}
|
|
|
|
|
2022-02-18 14:27:39 +03:00
|
|
|
function getDisplayTime(hours = 0) {
|
2022-01-05 19:43:40 +03:00
|
|
|
let minutes = 0;
|
|
|
|
const pct = hours % 1;
|
|
|
|
|
|
|
|
if (pct) {
|
|
|
|
minutes = Math.floor(60 * pct);
|
|
|
|
}
|
|
|
|
|
|
|
|
return datetime.getDisplayTime(new Date(2000, 1, 1, hours, minutes, 0, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
const AccessScheduleList: FunctionComponent<IProps> = ({index, DayOfWeek, StartHour, EndHour}: IProps) => {
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className='liSchedule listItem'
|
|
|
|
data-day={ DayOfWeek}
|
|
|
|
data-start={ StartHour}
|
|
|
|
data-end={ EndHour}
|
|
|
|
>
|
|
|
|
<div className='listItemBody two-line'>
|
|
|
|
<h3 className='listItemBodyText'>
|
|
|
|
{globalize.translate(DayOfWeek)}
|
|
|
|
</h3>
|
|
|
|
<div className='listItemBodyText secondary'>
|
|
|
|
{getDisplayTime(StartHour) + ' - ' + getDisplayTime(EndHour)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div
|
2022-02-18 14:27:39 +03:00
|
|
|
dangerouslySetInnerHTML={createButtonElement(index)}
|
2022-01-05 19:43:40 +03:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default AccessScheduleList;
|