Skip to content

Commit

Permalink
Merge branch 'UI/Individual-Listing' into UI/colorChanges
Browse files Browse the repository at this point in the history
  • Loading branch information
slaaiblaar committed Oct 22, 2023
2 parents b9e757a + 9ffefb5 commit e967fd2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
12 changes: 6 additions & 6 deletions libs/api/listings/data-access/src/listings.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class ListingsRepository {
let query: admin.firestore.Query;

if(req.userId){
query = collection.where('user_id', '==', req.userId).limit(5);
query = collection.where('user_id', '==', req.userId);
}
else{
query = collection.limit(10);
Expand Down Expand Up @@ -206,7 +206,7 @@ export class ListingsRepository {

return {unapprovedListings : listings};
}

pageSize = 10;
async getFilteredListings(req: GetFilteredListingsRequest): Promise<GetFilteredListingsResponse>{
try{
const listingsCollection = admin.firestore().collection('listings');
Expand Down Expand Up @@ -244,13 +244,13 @@ export class ListingsRepository {
}

if (lastListingDoc?.exists) {
query = query.startAfter(lastListingDoc).limit(5);
query = query.startAfter(lastListingDoc).limit(this.pageSize);
}
let loopLimit = 0;
// let lastListing: Listing | undefined = undefined;
// let lastQualityRating = 0;
let lastSnapshot: DocumentSnapshot | undefined = undefined
while (response.listings.length < 5 && loopLimit < 25) {
while (response.listings.length < 10 && loopLimit < 25) {
const queryData = await query.get();
++loopLimit;
// queryData.forEach((docSnapshot) => {
Expand Down Expand Up @@ -302,12 +302,12 @@ export class ListingsRepository {
}

response.listings.push(data);
if(response.listings.length >= 5){
if(response.listings.length >= this.pageSize){
return response;
}
}
if (lastSnapshot)
query = query.startAfter(lastSnapshot).limit(5 - response.listings.length);
query = query.startAfter(lastSnapshot).limit(this.pageSize - response.listings.length);
}
return response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</div>
<div class="drag-drop-area" (click)="fileInput.click()">
<ion-icon name="add-circle-outline" class="icon-on-top"></ion-icon>
<ion-label class="house-text">Click here to add an image of your property<span class="required-indicator" *ngIf="!photos.length">*</span></ion-label>
<ion-label class="house-text">Click here to add images of your property<span class="required-indicator" *ngIf="!photos.length">*</span></ion-label>

</div>
</ion-col>
Expand Down
9 changes: 4 additions & 5 deletions libs/app/search/feature/src/search.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,10 @@
</div>
</ng-container>
<ng-template #listingsLoaded>
<ng-container *ngIf="listings.length === 0; else foundListings">
<!-- <div style="display: flex; justify-content: space-between; font-weight: 500">
<p>Enter a search query to begin your search</p>
<ion-icon style="font-size: 24; padding-left: 10px;" name="search-outline"></ion-icon>
</div> -->
<ng-container *ngIf="listings.length === 0 && searchQuery!=='' && searched; else foundListings">
<div style="display: flex; justify-content: space-between; font-weight: 500">
<p>No Search Results Found in {{searchQuery}}</p>
</div>
</ng-container>
<ng-template #foundListings>
<div class="lists" id="lists">
Expand Down
24 changes: 18 additions & 6 deletions libs/app/search/feature/src/search.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class SearchPage implements OnDestroy, AfterViewInit {
private markers: any[] = [];
public listings: Listing[] = [];
public allListings: Listing[] = [];
public noResults = false;

public activeTab = 'Any';
public searchQuery = '';
Expand Down Expand Up @@ -89,7 +90,7 @@ export class SearchPage implements OnDestroy, AfterViewInit {
public smallestProp = 99999999;
public largestProp = 0;
cardView = new Map();

searched = false;
recommendationMinimum = 100000;


Expand Down Expand Up @@ -198,6 +199,7 @@ export class SearchPage implements OnDestroy, AfterViewInit {
// this.predictions = this.gmapsService.regionPredictions;
// if timeout is already set, reset remaining duration
clearTimeout(this.timeout);
this.searched = false;
if (this.searchQuery.length == 0) {
this.searchLoading = false;
this.predictions = [];
Expand Down Expand Up @@ -468,9 +470,10 @@ async loadMap() {
}

Templistings: Listing[] = [];

pageSize = 10;
async searchProperties(nextPage?: boolean, previousPage?: boolean) {
this.predictions = [];
this.searched = false;
if(!this.searchQuery){
const toast = await this.toastController.create({
message: 'Please enter an area for us to search in',
Expand Down Expand Up @@ -503,14 +506,14 @@ async loadMap() {
if (previousPage) {
if (this.currentPage > 0) {
this.currentPage--;
this.listings = this.allListings.slice(this.currentPage * 5, this.currentPage * 5 + 5);
this.listings = this.allListings.slice(this.currentPage * this.pageSize, this.currentPage * this.pageSize + this.pageSize);
}
return;
}
if (nextPage) {
if (this.currentPage * 5 + 5 < this.allListings.length) {
if (this.currentPage * this.pageSize + this.pageSize < this.allListings.length) {
this.currentPage++;
this.listings = this.allListings.slice(this.currentPage * 5, this.currentPage * 5 + 5);
this.listings = this.allListings.slice(this.currentPage * this.pageSize, this.currentPage * this.pageSize + this.pageSize);
return;
}
}
Expand Down Expand Up @@ -573,7 +576,7 @@ async loadMap() {
// this.allListings = [];
this.allListings = this.allListings.concat(response.listings);
if (nextPage) this.currentPage++;
this.listings = this.allListings.slice(this.currentPage * 5, this.currentPage * 5 + 5);
this.listings = this.allListings.slice(this.currentPage * this.pageSize, this.currentPage * this.pageSize + this.pageSize);

const temp = [];

Expand Down Expand Up @@ -642,11 +645,20 @@ async loadMap() {

setTimeout(() => {
this.searching = false;
this.searched = true;
document.getElementById("searchButton")?.setAttribute("disabled", "false")
}, 1500)
}
}

//no result that returns a boolean
noResult(){
if(this.searchQuery!='' && this.listings.length == 0){
return true;
}
return false;
}

async addMarkersToMap() {
for (const listing of this.listings) {
const coordinates = listing.geometry
Expand Down

0 comments on commit e967fd2

Please sign in to comment.