registro de reservacion
This commit is contained in:
parent
bd79c3a6a8
commit
47efe0bbdf
|
@ -512,7 +512,7 @@ export class AppController {
|
||||||
@Body('user_id') user_id: string,
|
@Body('user_id') user_id: string,
|
||||||
@Body('common_area_id') common_area_id: string,
|
@Body('common_area_id') common_area_id: string,
|
||||||
@Body('common_area_name') common_area_name: string,
|
@Body('common_area_name') common_area_name: string,
|
||||||
@Body('communty_id') communty_id: string,
|
@Body('community_id') community_id: string,
|
||||||
) {
|
) {
|
||||||
return this.appService.createReservation(
|
return this.appService.createReservation(
|
||||||
date,
|
date,
|
||||||
|
@ -522,7 +522,7 @@ export class AppController {
|
||||||
user_id,
|
user_id,
|
||||||
common_area_id,
|
common_area_id,
|
||||||
common_area_name,
|
common_area_name,
|
||||||
communty_id,
|
community_id,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -615,12 +615,12 @@ export class AppService {
|
||||||
//POST parameter from API
|
//POST parameter from API
|
||||||
createReservation(date: string, time: string, status: string,
|
createReservation(date: string, time: string, status: string,
|
||||||
date_entry: Date, user_id: string, common_area_id: string,
|
date_entry: Date, user_id: string, common_area_id: string,
|
||||||
common_area_name: string, communty_id: string) {
|
common_area_name: string, community_id: string) {
|
||||||
const pattern = { cmd: 'createReservation' };
|
const pattern = { cmd: 'createReservation' };
|
||||||
const payload = {
|
const payload = {
|
||||||
date: date, time: time, status: status,
|
date: date, time: time, status: status,
|
||||||
date_entry: date_entry, user_id: user_id, common_area_id: common_area_id,
|
date_entry: date_entry, user_id: user_id, common_area_id: common_area_id,
|
||||||
common_area_name: common_area_name, communty_id: communty_id
|
common_area_name: common_area_name, community_id: community_id
|
||||||
};
|
};
|
||||||
return this.clientReservationApp
|
return this.clientReservationApp
|
||||||
.send<string>(pattern, payload)
|
.send<string>(pattern, payload)
|
||||||
|
|
|
@ -6,7 +6,7 @@ export type ReservationDocument = Reservation & Document;
|
||||||
@Schema({ collection: 'reservations' })
|
@Schema({ collection: 'reservations' })
|
||||||
export class Reservation {
|
export class Reservation {
|
||||||
@Prop()
|
@Prop()
|
||||||
date: string;
|
date: Date;
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
time: string;
|
time: string;
|
||||||
|
|
|
@ -316,7 +316,6 @@ const AdministradoresComunidad = () => {
|
||||||
detail: 'Administrador de comunidad actualizado',
|
detail: 'Administrador de comunidad actualizado',
|
||||||
life: 3000,
|
life: 3000,
|
||||||
})
|
})
|
||||||
toast.current.show({ severity: 'success', summary: 'Exito', detail: 'Administrador de Comunidad de vivienda Actualizada', life: 3000 });
|
|
||||||
|
|
||||||
listaAdmin();
|
listaAdmin();
|
||||||
setCommunityId('');
|
setCommunityId('');
|
||||||
|
|
|
@ -79,7 +79,6 @@ const Reservations = () => {
|
||||||
data = data.filter(
|
data = data.filter(
|
||||||
(val) => val.bookable == 1,
|
(val) => val.bookable == 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
setAreas(data)
|
setAreas(data)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -94,6 +93,9 @@ const Reservations = () => {
|
||||||
(val) => val.status != -1,
|
(val) => val.status != -1,
|
||||||
)
|
)
|
||||||
data.map((item) => {
|
data.map((item) => {
|
||||||
|
|
||||||
|
item.date = formatDateString(item.date)
|
||||||
|
|
||||||
if (item.status == '1') {
|
if (item.status == '1') {
|
||||||
item.status_text = 'Activo';
|
item.status_text = 'Activo';
|
||||||
} else if (item.status == '0') {
|
} else if (item.status == '0') {
|
||||||
|
@ -127,20 +129,52 @@ const Reservations = () => {
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const saveReservation = () => {
|
const saveReservation = () => {
|
||||||
let _reservations = [...reservations];
|
|
||||||
let _reservation = { ...reservation };
|
|
||||||
|
|
||||||
if ( _reservation.date && _reservation.time && tenantId && areaId && !validationTime()) {
|
let _reservations = [...reservations];
|
||||||
_reservations.push(_reservation);
|
let _reservation = { ...reservation };
|
||||||
setReservations(_reservations)
|
|
||||||
toast.current.show({
|
if (_reservation.date && _reservation.time && tenantId && areaId && !validationTime()) {
|
||||||
severity: 'success',
|
_reservation.common_area_name = areas.find(item => item._id == areaId).name;
|
||||||
summary: 'Éxito',
|
let tenant = tenants.find(item => item._id == tenantId);
|
||||||
detail: 'Administrador del Sistema Actualizado',
|
_reservation.user_name = tenant.name + ' ' + tenant.last_name;
|
||||||
life: 3000,
|
_reservation.user_id = tenantId;
|
||||||
});
|
_reservation.common_area_id = areaId;
|
||||||
|
_reservation.community_id = cookies.community_id;
|
||||||
|
|
||||||
|
if (_reservation.status == '1') {
|
||||||
|
_reservation.status_text = 'Activo';
|
||||||
|
} else if (_reservation.status == '0') {
|
||||||
|
_reservation.status_text = 'Inactivo';
|
||||||
|
}
|
||||||
|
console.log(_reservation)
|
||||||
|
fetch('http://localhost:4000/reservation/createReservation/', {
|
||||||
|
cache: 'no-cache',
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify(_reservation),
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
if (response.status !== 200 && response.status !== 201 )
|
||||||
|
console.log(`Hubo un error en el servicio: ${response.status}`)
|
||||||
|
else return response.json()
|
||||||
|
}).then(() => {
|
||||||
|
_reservations.push(_reservation);
|
||||||
|
setReservations(_reservations)
|
||||||
|
toast.current.show({
|
||||||
|
severity: 'success',
|
||||||
|
summary: 'Éxito',
|
||||||
|
detail: 'Reservación realizada',
|
||||||
|
life: 3000,
|
||||||
|
});
|
||||||
|
|
||||||
|
setReservationDialog(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setReservationDialog(false)
|
|
||||||
} else {
|
} else {
|
||||||
setSubmitted(true);
|
setSubmitted(true);
|
||||||
}
|
}
|
||||||
|
@ -259,7 +293,7 @@ const Reservations = () => {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
const headerStartTime = (
|
const headerDate = (
|
||||||
<>
|
<>
|
||||||
<p>
|
<p>
|
||||||
{' '}
|
{' '}
|
||||||
|
@ -269,7 +303,7 @@ const Reservations = () => {
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
const headerEndTime = (
|
const headerTime = (
|
||||||
<>
|
<>
|
||||||
<p>
|
<p>
|
||||||
{' '}
|
{' '}
|
||||||
|
@ -384,6 +418,12 @@ const Reservations = () => {
|
||||||
return date.toString()
|
return date.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatDateString(dateString) {
|
||||||
|
const [date, time] = timeString.split('T');
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid">
|
<div className="grid">
|
||||||
|
@ -419,9 +459,9 @@ const Reservations = () => {
|
||||||
headerStyle={{ width: '3rem' }}
|
headerStyle={{ width: '3rem' }}
|
||||||
></Column>
|
></Column>
|
||||||
<Column
|
<Column
|
||||||
field="start_time"
|
field="date"
|
||||||
sortable
|
sortable
|
||||||
header={headerStartTime}
|
header={headerDate}
|
||||||
style={{
|
style={{
|
||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
flexBasis: '160px',
|
flexBasis: '160px',
|
||||||
|
@ -430,9 +470,9 @@ const Reservations = () => {
|
||||||
}}
|
}}
|
||||||
></Column>
|
></Column>
|
||||||
<Column
|
<Column
|
||||||
field="finish_time"
|
field="time"
|
||||||
sortable
|
sortable
|
||||||
header={headerEndTime}
|
header={headerTime}
|
||||||
style={{
|
style={{
|
||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
flexBasis: '160px',
|
flexBasis: '160px',
|
||||||
|
|
Loading…
Reference in New Issue