delete quote and description
This commit is contained in:
parent
a77782acaa
commit
e9d008da00
|
@ -79,7 +79,6 @@ export class AppController {
|
||||||
@Body('district') district: string,
|
@Body('district') district: string,
|
||||||
@Body('num_houses') num_houses: number,
|
@Body('num_houses') num_houses: number,
|
||||||
@Body('phone') phone: string,
|
@Body('phone') phone: string,
|
||||||
@Body('quote') quote: number,
|
|
||||||
@Body('status') status: string,
|
@Body('status') status: string,
|
||||||
@Body('date_entry') date_entry: Date,
|
@Body('date_entry') date_entry: Date,
|
||||||
@Body('houses') houses: [],
|
@Body('houses') houses: [],
|
||||||
|
@ -87,7 +86,7 @@ export class AppController {
|
||||||
) {
|
) {
|
||||||
return this.appService.createCommunity(name, province, canton,
|
return this.appService.createCommunity(name, province, canton,
|
||||||
district, num_houses, phone,
|
district, num_houses, phone,
|
||||||
quote, status, date_entry, houses);
|
status, date_entry, houses);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('community/allCommunities')
|
@Get('community/allCommunities')
|
||||||
|
|
|
@ -131,11 +131,11 @@ export class AppService {
|
||||||
|
|
||||||
//POST parameter from API
|
//POST parameter from API
|
||||||
createCommunity(name: string, province: string, canton: string, district: string
|
createCommunity(name: string, province: string, canton: string, district: string
|
||||||
, num_houses: number, phone: string, quote: number, status: string, date_entry: Date, houses: []) {
|
, num_houses: number, phone: string, status: string, date_entry: Date, houses: []) {
|
||||||
const pattern = { cmd: 'createCommunity' };
|
const pattern = { cmd: 'createCommunity' };
|
||||||
const payload = {
|
const payload = {
|
||||||
name: name, province: province, canton: canton, district: district, num_houses: num_houses,
|
name: name, province: province, canton: canton, district: district, num_houses: num_houses,
|
||||||
phone: phone, quote: quote, status: status, date_entry: date_entry, houses: houses
|
phone: phone, status: status, date_entry: date_entry, houses: houses
|
||||||
};
|
};
|
||||||
return this.clientCommunityApp
|
return this.clientCommunityApp
|
||||||
.send<string>(pattern, payload)
|
.send<string>(pattern, payload)
|
||||||
|
|
|
@ -31,9 +31,6 @@ export class Community {
|
||||||
@Prop()
|
@Prop()
|
||||||
phone: string;
|
phone: string;
|
||||||
|
|
||||||
@Prop()
|
|
||||||
quote: number;
|
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
status: string;
|
status: string;
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,6 @@ export class House extends Document {
|
||||||
@Prop({ default: " " })
|
@Prop({ default: " " })
|
||||||
number_house: string;
|
number_house: string;
|
||||||
|
|
||||||
@Prop({ default: " " })
|
|
||||||
description: string;
|
|
||||||
|
|
||||||
@Prop({ default: "desocupada" })
|
@Prop({ default: "desocupada" })
|
||||||
state: string;
|
state: string;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ const Communities = () => {
|
||||||
status: 'activo',
|
status: 'activo',
|
||||||
date_entry: new Date(),
|
date_entry: new Date(),
|
||||||
houses: [],
|
houses: [],
|
||||||
quote: 0
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,6 +33,7 @@ const Communities = () => {
|
||||||
const [cantonId, setCantonId] = useState(null);
|
const [cantonId, setCantonId] = useState(null);
|
||||||
const [districtsList, setDistrictsList] = useState([]);
|
const [districtsList, setDistrictsList] = useState([]);
|
||||||
const [districtId, setDistrictId] = useState(null);
|
const [districtId, setDistrictId] = useState(null);
|
||||||
|
const [codeHouses, setCodeHouses] = useState(null);
|
||||||
const [submitted, setSubmitted] = useState(false);
|
const [submitted, setSubmitted] = useState(false);
|
||||||
const toast = useRef(null);
|
const toast = useRef(null);
|
||||||
const dt = useRef(null);
|
const dt = useRef(null);
|
||||||
|
@ -126,6 +126,12 @@ const Communities = () => {
|
||||||
setDistrictId(getDistrictId);
|
setDistrictId(getDistrictId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const handleCodeHouses = (event) => {
|
||||||
|
const getcodehouse = event.target.value;
|
||||||
|
setCodeHouses(getcodehouse);
|
||||||
|
}
|
||||||
|
|
||||||
async function getCommunites() {
|
async function getCommunites() {
|
||||||
let response = await fetch('http://localhost:4000/community/allCommunities', { method: 'GET' });
|
let response = await fetch('http://localhost:4000/community/allCommunities', { method: 'GET' });
|
||||||
let resJson = await response.json();
|
let resJson = await response.json();
|
||||||
|
@ -161,8 +167,7 @@ const Communities = () => {
|
||||||
|
|
||||||
for (let i = 0; i < _community.num_houses; i++){
|
for (let i = 0; i < _community.num_houses; i++){
|
||||||
_community.houses.push({
|
_community.houses.push({
|
||||||
number_house: i+1,
|
number_house: codeHouses + (i+1),
|
||||||
description: "es esta descripcion",
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// console.log(houses)
|
// console.log(houses)
|
||||||
|
@ -197,6 +202,8 @@ const Communities = () => {
|
||||||
setProvinciaId('');
|
setProvinciaId('');
|
||||||
setCantonId('');
|
setCantonId('');
|
||||||
setDistrictId('');
|
setDistrictId('');
|
||||||
|
setCodeHouses('');
|
||||||
|
|
||||||
setCommunity(emptyCommunity);
|
setCommunity(emptyCommunity);
|
||||||
})
|
})
|
||||||
.catch(
|
.catch(
|
||||||
|
@ -229,7 +236,6 @@ const Communities = () => {
|
||||||
<Column field="district" header="Distrito" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
|
<Column field="district" header="Distrito" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
|
||||||
<Column field="phone" header="Telefóno" style={{ flexGrow: 1, flexBasis: '180px' }}></Column>
|
<Column field="phone" header="Telefóno" style={{ flexGrow: 1, flexBasis: '180px' }}></Column>
|
||||||
<Column field="num_houses" header="Número de viviendas" style={{ flexGrow: 1, flexBasis: '180px' }}></Column>
|
<Column field="num_houses" header="Número de viviendas" style={{ flexGrow: 1, flexBasis: '180px' }}></Column>
|
||||||
<Column field="quote" header="Cuota mensual" style={{ flexGrow: 1, flexBasis: '180px' }}></Column>
|
|
||||||
<Column field="name_admin" header="Administrador" style={{ flexGrow: 1, flexBasis: '180px' }}></Column>
|
<Column field="name_admin" header="Administrador" style={{ flexGrow: 1, flexBasis: '180px' }}></Column>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
</div>
|
</div>
|
||||||
|
@ -240,14 +246,14 @@ const Communities = () => {
|
||||||
|
|
||||||
<h5>Registro de comunidad de viviendas</h5>
|
<h5>Registro de comunidad de viviendas</h5>
|
||||||
<div className="p-fluid formgrid grid">
|
<div className="p-fluid formgrid grid">
|
||||||
<div className="field col-12 md:col-6">
|
<div className="field col-12 md:col-12">
|
||||||
<label htmlFor="name">Nombre</label>
|
<label htmlFor="name">Nombre</label>
|
||||||
<div className="p-0 col-12 md:col-12">
|
<div className="p-0 col-12 md:col-12">
|
||||||
<div className="p-inputgroup">
|
<div className="p-inputgroup">
|
||||||
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
||||||
<i className="pi pi-home"></i>
|
<i className="pi pi-home"></i>
|
||||||
</span>
|
</span>
|
||||||
<InputText id="name" value={community.name} onChange={(e) => onInputChange(e, 'name')} required autoFocus className={classNames({ 'p-invalid': submitted && community.name==='' } )} />
|
<InputText id="name" value={community.name} onChange={(e) => onInputChange(e, 'name')} required autoFocus className={classNames( submitted && community.name==='' ? 'p-invalid' : '' )} />
|
||||||
</div>
|
</div>
|
||||||
{submitted && community.name==='' && <small className="p-invalid">Nombre es requirido.</small>}
|
{submitted && community.name==='' && <small className="p-invalid">Nombre es requirido.</small>}
|
||||||
</div>
|
</div>
|
||||||
|
@ -259,9 +265,9 @@ const Communities = () => {
|
||||||
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
||||||
<i className="pi pi-map-marker"></i>
|
<i className="pi pi-map-marker"></i>
|
||||||
</span>
|
</span>
|
||||||
<Dropdown placeholder="--Seleccione Provincia--" value={provinciaId} options={p} onChange={handleProvinces} required autoFocus className={classNames({ 'p-invalid': submitted && (!community.province || community.province === '') } )} />
|
<Dropdown placeholder="--Seleccione Provincia--" value={provinciaId} options={p} onChange={handleProvinces} required autoFocus className={classNames({ 'p-invalid': submitted && !provinciaId } )} />
|
||||||
</div>
|
</div>
|
||||||
{submitted && (!community.province || community.province === '') && <small className="p-invalid">Provincia es requirido.</small>}
|
{submitted && !provinciaId && <small className="p-invalid">Provincia es requirido.</small>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="field col-12 md:col-6">
|
<div className="field col-12 md:col-6">
|
||||||
|
@ -271,9 +277,9 @@ const Communities = () => {
|
||||||
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
||||||
<i className="pi pi-map-marker"></i>
|
<i className="pi pi-map-marker"></i>
|
||||||
</span>
|
</span>
|
||||||
<Dropdown placeholder="--Seleccione Cantón--" value={cantonId} options={c} onChange={handleCanton} required autoFocus className={classNames({ 'p-invalid': submitted && !community.canton } )}/>
|
<Dropdown placeholder="--Seleccione Cantón--" value={cantonId} options={c} onChange={handleCanton} required autoFocus className={classNames({ 'p-invalid': submitted && !cantonId } )}/>
|
||||||
</div>
|
</div>
|
||||||
{submitted && !community.canton && <small className="p-invalid">Cantón es requirido.</small>}
|
{submitted && !cantonId && <small className="p-invalid">Cantón es requirido.</small>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="field col-12 md:col-6">
|
<div className="field col-12 md:col-6">
|
||||||
|
@ -283,9 +289,9 @@ const Communities = () => {
|
||||||
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
||||||
<i className="pi pi-map-marker"></i>
|
<i className="pi pi-map-marker"></i>
|
||||||
</span>
|
</span>
|
||||||
<Dropdown placeholder="--Seleccione Distrito--" value={districtId} options={d} onChange={handleDistrict} required autoFocus className={classNames({ 'p-invalid': submitted && !community.district } )}/>
|
<Dropdown placeholder="--Seleccione Distrito--" value={districtId} options={d} onChange={handleDistrict} required autoFocus className={classNames({ 'p-invalid': submitted && !districtId } )}/>
|
||||||
</div>
|
</div>
|
||||||
{submitted && !community.district && <small className="p-invalid">Distrito es requirido.</small>}
|
{submitted && !districtId && <small className="p-invalid">Distrito es requirido.</small>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="field col-12 md:col-6">
|
<div className="field col-12 md:col-6">
|
||||||
|
@ -312,6 +318,18 @@ const Communities = () => {
|
||||||
{submitted && community.num_houses < 1 && <small className="p-invalid">Número de viviendas es requirido y debe ser mayor que 0.</small>}
|
{submitted && community.num_houses < 1 && <small className="p-invalid">Número de viviendas es requirido y debe ser mayor que 0.</small>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="field col-12 md:col-6">
|
||||||
|
<label htmlFor="numHouse">Ingrese el prefijo para el código de las viviendas</label>
|
||||||
|
<div className="p-0 col-12 md:col-12">
|
||||||
|
<div className="p-inputgroup">
|
||||||
|
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
||||||
|
<i className="pi pi-hashtag"></i>
|
||||||
|
</span>
|
||||||
|
<InputText id="code_houses" value={codeHouses} onChange={handleCodeHouses} required autoFocus className={classNames({ 'p-invalid': submitted && !codeHouses } )} />
|
||||||
|
</div>
|
||||||
|
{submitted && !codeHouses && <small className="p-invalid">El código para las viviendas es requirido.</small>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div className="col-12 md:col-12 py-2">
|
<div className="col-12 md:col-12 py-2">
|
||||||
<Button label="Registrar" icon="pi pi-check" onClick={saveCommunity}></Button>
|
<Button label="Registrar" icon="pi pi-check" onClick={saveCommunity}></Button>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue