csv en reservaciones

This commit is contained in:
Mariela 2022-08-28 01:47:26 -06:00
parent 7b7a3f27d2
commit cc9a83d550
4 changed files with 33 additions and 20 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -446,6 +446,8 @@ const App = () => {
<> <>
<Route path="/login" exact component={LogInUser} /> <Route path="/login" exact component={LogInUser} />
<Route path="/crud" component={Crud} />
</> </>
) )

View File

@ -6,11 +6,11 @@ export const AppFooter = (props) => {
<img <img
src={ src={
props.layoutColorMode === 'light' props.layoutColorMode === 'light'
? 'assets/layout/images/logo-dark.svg' ? 'images/deimos-logo.png'
: 'assets/layout/images/logo-white.svg' : 'assets/layout/images/logo-white.svg'
} }
alt="Logo" alt="Logo"
height="20" height="40"
className="mr-2" className="mr-2"
/> />
por por

View File

@ -94,7 +94,7 @@ const Reservations = () => {
) )
data.map((item) => { data.map((item) => {
item.date = formatDateString(item.date) item.date = formatDateString(item.date)
if (item.status == '1') { if (item.status == '1') {
item.status_text = 'Activo'; item.status_text = 'Activo';
@ -134,7 +134,7 @@ const Reservations = () => {
let _reservation = { ...reservation }; let _reservation = { ...reservation };
if (_reservation.date && _reservation.time && tenantId && areaId if (_reservation.date && _reservation.time && tenantId && areaId
&& !validationTime() && !validationTime()
&& !validationIsSameUser() && !validationIsReservation()) { && !validationIsSameUser() && !validationIsReservation()) {
_reservation.common_area_name = areas.find(item => item._id == areaId).name; _reservation.common_area_name = areas.find(item => item._id == areaId).name;
let tenant = tenants.find(item => item._id == tenantId); let tenant = tenants.find(item => item._id == tenantId);
@ -175,16 +175,25 @@ const Reservations = () => {
setAreaId('') setAreaId('')
setTenantId('') setTenantId('')
}) })
} else { } else {
setSubmitted(true); setSubmitted(true);
} }
} }
const exportCSV = () => { const exportCSV = () => {
dt.current.exportCSV(); //
selectedReservations.current.exportCSV(); if (selectedReservations) {
}; while (dt.current.props.value.length > 0)
dt.current.props.value.pop();
let n=0;
for (let n = 0; n < selectedReservations.length; n++){
dt.current.props.value.push(selectedReservations[n]);
}
}
dt.current.exportCSV();
};
const actionsReservation = (rowData) => { const actionsReservation = (rowData) => {
@ -238,8 +247,9 @@ const Reservations = () => {
<Button <Button
label="Nueva Reservación" label="Nueva Reservación"
icon="pi pi-plus" icon="pi pi-plus"
className="p-button-success mr-2" className="p-button-primary mr-2"
onClick={openNewReservation} onClick={openNewReservation}
/> />
<Button <Button
label="Eliminar" label="Eliminar"
@ -418,17 +428,17 @@ const Reservations = () => {
} }
function validationIsReservation() { function validationIsReservation() {
if(reservation.date && reservation.time && areaId){ if (reservation.date && reservation.time && areaId) {
let date1 = new Date(reservation.date).toJSON().split('T')[0]; let date1 = new Date(reservation.date).toJSON().split('T')[0];
let date2 = date1.split('-')[2] + '-' + date1.split('-')[1] + '-' +date1.split('-')[0]; let date2 = date1.split('-')[2] + '-' + date1.split('-')[1] + '-' + date1.split('-')[0];
let booked = reservations.filter(item => item.common_area_id == areaId let booked = reservations.filter(item => item.common_area_id == areaId
&& item.date == date2 && item.date == date2
&& item.time == reservation.time); && item.time == reservation.time);
if (booked.length > 0) { if (booked.length > 0) {
return true; return true;
} else { } else {
return false; return false;
} }
@ -436,16 +446,16 @@ const Reservations = () => {
} }
function validationIsSameUser() { function validationIsSameUser() {
if(reservation.date && tenantId && areaId){ if (reservation.date && tenantId && areaId) {
let date1 = new Date(reservation.date).toJSON().split('T')[0]; let date1 = new Date(reservation.date).toJSON().split('T')[0];
let date2 = date1.split('-')[2] + '-' + date1.split('-')[1] + '-' +date1.split('-')[0]; let date2 = date1.split('-')[2] + '-' + date1.split('-')[1] + '-' + date1.split('-')[0];
let booked = reservations.filter(item => item.common_area_id == areaId let booked = reservations.filter(item => item.common_area_id == areaId
&& item.date == date2 && item.date == date2
&& item.user_id == tenantId); && item.user_id == tenantId);
if (booked.length >= 2) { if (booked.length >= 2) {
return true; return true;
} else { } else {
return false; return false;
} }
@ -499,6 +509,7 @@ const Reservations = () => {
headerStyle={{ width: '3rem' }} headerStyle={{ width: '3rem' }}
></Column> ></Column>
<Column <Column
exportFilename="Date"
field="date" field="date"
sortable sortable
header={headerDate} header={headerDate}