Skip to content

Commit

Permalink
contact form, translate sector, dates in card
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytakis committed Dec 23, 2020
1 parent be6b5e8 commit 0c68194
Show file tree
Hide file tree
Showing 21 changed files with 930 additions and 507 deletions.
4 changes: 4 additions & 0 deletions src/app/core/interfaces/message.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface Message {
message: string;
code: number;
}
14 changes: 13 additions & 1 deletion src/app/core/services/open-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { MicrocreditCampaign } from '../models/microcredit-campaign.model';
import { OneClickToken } from '../models/one-click-token.model';
import { PaymentDetails } from '../models/payment-details.model';
import { MicrocreditBalance } from '../models/microcredit-balance.model';
import { Message } from '../interfaces/message.interface';

@Injectable({
providedIn: 'root'
Expand All @@ -32,7 +33,7 @@ export class OpenDataService {
* Authentication
*/
oneClickRegistration(email: string): Observable<OneClickToken> {
return this.http.post<any>(`${environment.apiUrl}/auth/one-click/register`, { email: email })
return this.http.post<any>(`${environment.apiUrl}/auth/register/one-click`, { email: email })
.pipe(map(response => {
return response.data;
}));
Expand Down Expand Up @@ -157,4 +158,15 @@ export class OpenDataService {
return response.data;
}));
};

/**
* Communicate
*/
communicate(sender: string, content: string): Observable<Message> {
return this.http.post<any>(`${environment.apiUrl}/community/communicate`, { sender: sender, content: content })
.pipe(map(response => {
return response;
}));
};

}
126 changes: 92 additions & 34 deletions src/app/core/services/static-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { ContactList } from '../interfaces/contact-list.interface';
import { GeneralList } from '../interfaces/general-list.interface';

@Injectable({
providedIn: 'root'
providedIn: 'root'
})
export class StaticDataService {

/**
* Payments List
*/
/**
* Payments List
*/
paymentsList: PaymentList[] = [
{
bic: 'ETHNGRAA',
Expand Down Expand Up @@ -64,10 +64,44 @@ export class StaticDataService {
}
];


/**
* Contacts List
* Sectors List
*/
sectorsList: GeneralList[] = [
{
title: 'PARTNER.SECTOR_CHOICES._',
value: 'Other',
},
{
title: 'PARTNER.SECTOR_CHOICES.A',
value: 'B2B Services & Other Goods and Services',
},
{
title: 'PARTNER.SECTOR_CHOICES.B',
value: 'Durables',
},
{
title: 'PARTNER.SECTOR_CHOICES.C',
value: 'Durables (Technology)',
},
{
title: 'PARTNER.SECTOR_CHOICES.D',
value: 'Education',
},
{
title: 'PARTNER.SECTOR_CHOICES.E',
value: 'Food',
},
{
title: 'PARTNER.SECTOR_CHOICES.F',
value: 'Hotels, Cafés and Restaurants',
},
{
title: 'PARTNER.SECTOR_CHOICES.G',
value: 'Recreation and Culture',
}
];

/**
* Contacts List
*/
Expand Down Expand Up @@ -127,35 +161,59 @@ export class StaticDataService {
},
];

public get getPaymentsList(): PaymentList[] {
return this.paymentsList;
};
/**
* Form Validators
*/
validators = {
contact: {
sender: {
minLength: 4,
maxLength: 256
},
content: {
minLength: 6,
maxLength: 4096
},
}
};

public get getContactsList(): ContactList[] {
return this.contactsList;
};
public get getPaymentsList(): PaymentList[] {
return this.paymentsList;
};

owlOptions = {
loop: true,
mouseDrag: true,
touchDrag: false,
pullDrag: false,
dots: true,
navSpeed: 700,
navText: ['', ''],
responsive: {
0: {
items: 1
},
940: {
items: 3
}
},
margin: 30,
nav: true
}
public get getSectorsList(): GeneralList[] {
return this.sectorsList;
};

public get getContactsList(): ContactList[] {
return this.contactsList;
};

public get getValidators() {
return this.validators;
}

owlOptions = {
loop: true,
mouseDrag: true,
touchDrag: false,
pullDrag: false,
dots: true,
navSpeed: 700,
navText: ['', ''],
responsive: {
0: {
items: 1
},
940: {
items: 3
}
},
margin: 30,
nav: true
}

public get getOwlOprions() {
return this.owlOptions;
};
public get getOwlOprions() {
return this.owlOptions;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div class="card-content-partner-divider"><span></span><span></span><span></span></div>
<div class="partner-heading">
<div class="partner-title">{{partner.name}}</div>
<div class="partner-sector"><span class="mdi mdi-view-dashboard-outline"></span> {{partner.sector}}
<div class="partner-sector"><span class="mdi mdi-view-dashboard-outline"></span> {{translateSector(partner) | translate}}
</div>
</div>
<div class="partner-info">
Expand Down
15 changes: 15 additions & 0 deletions src/app/views/content/community-list/community-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { OwlOptions } from 'ngx-owl-carousel-o';
import { OpenDataService } from '../../../core/services/open-data.service';
import { StaticDataService } from 'src/app/core/services/static-data.service';
import { Partner } from '../../../core/models/partner.model';
import { GeneralList } from '../../../core/interfaces/general-list.interface';

@Component({
selector: 'app-community-list',
Expand All @@ -26,6 +27,7 @@ export class CommunityListComponent implements OnInit, OnDestroy {
private unsubscribe: Subject<any>;

public partners: Partner[];
public sectorsList: GeneralList[];
/*
list = [
{
Expand Down Expand Up @@ -64,6 +66,7 @@ export class CommunityListComponent implements OnInit, OnDestroy {
private staticDataService: StaticDataService,
// private loadData : LoadJsonService
) {
this.sectorsList = this.staticDataService.getSectorsList;
this.customOptions = staticDataService.getOwlOprions;
this.unsubscribe = new Subject();
}
Expand All @@ -81,6 +84,18 @@ export class CommunityListComponent implements OnInit, OnDestroy {
this.loading = false;
}

translateSector(partner: Partner) {
console.log("Here")
console.log(partner);
console.log()
console.log(this.sectorsList.filter((el) => {
return el.value == partner.sector
}))
return this.sectorsList.filter((el) => {
return el.value == partner.sector
})[0].title;
}

shuffleArray(array: Partner[]) {
var m = array.length, t, i;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
<div class="col-sm-12 item-img-container">
<div class="item-img">
<img *ngIf="item.campaign_imageURL" src={{item.campaign_imageURL}} alt={{item.title}} />
<div class="item-expires">έως {{item.expiresAt | date: 'd.M'}}</div>
<div class="item-expires">{{filterCampaign(item)}} <span *ngIf="_date">{{ _date | date: 'd.M'}}</span></div>
<!-- <div class="item-expires">έως {{item.expiresAt | date: 'd.M'}}</div> -->
</div>
</div>
<div class="col-sm-12 item-details">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { OwlOptions } from 'ngx-owl-carousel-o';
import { OpenDataService } from '../../../core/services/open-data.service';
import { StaticDataService } from 'src/app/core/services/static-data.service';
import { MicrocreditCampaign } from '../../../core/models/microcredit-campaign.model';
import { TranslateService } from '@ngx-translate/core';

@Component({
selector: 'app-microcredit-list',
Expand All @@ -20,6 +21,9 @@ export class MicrocreditListComponent implements OnInit {
moved: boolean;
customOptions: OwlOptions;

public _text: string = '';
public _date: number = 0;

loading: boolean = false;
private unsubscribe: Subject<any>;

Expand All @@ -28,6 +32,7 @@ export class MicrocreditListComponent implements OnInit {
constructor(
private cdRef: ChangeDetectorRef,
private openDataService: OpenDataService,
private translate: TranslateService,
private router: Router,
private staticDataService: StaticDataService,
) {
Expand Down Expand Up @@ -61,8 +66,27 @@ export class MicrocreditListComponent implements OnInit {
return array;
}

filterCampaign(campaign: MicrocreditCampaign) {
const now = new Date();
const seconds = parseInt(now.getTime().toString());

if (campaign.startsAt > seconds) {
this._date = campaign.startsAt;
return this.translate.instant('CAMPAIGN.STATUS.EXPECTED');
// this._text = this.translate.instant('CAMPAIGN.STATUS.EXPECTED');
} else if ((campaign.expiresAt > seconds) && (seconds > campaign.startsAt)) {
this._date = campaign.expiresAt;
return this.translate.instant('GENERAL.TO');
// this._text = this.translate.instant('GENERAL.TO');
} else if (seconds > campaign.expiresAt) {
this._date = campaign.redeemEnds;
return this.translate.instant('CAMPAIGN.STATUS.REDEEM_TO');
// this._text = this.translate.instant('CAMPAIGN.STATUS.REDEEM_TO');
}
}

fetchCampaignsData() {
this.openDataService.readAllPublicMicrocreditCampaigns(`0-0-0`)
this.openDataService.readAllPublicMicrocreditCampaigns(`0-0-1`)
.pipe(
tap(
data => {
Expand All @@ -81,7 +105,7 @@ export class MicrocreditListComponent implements OnInit {
}

fetchPartnerCampaignsData(partner_id: string) {
this.openDataService.readAllMicrocreditCampaignsByStore(partner_id, `0-0-0`)
this.openDataService.readAllMicrocreditCampaignsByStore(partner_id, `0-0-1`)
.pipe(
tap(
data => {
Expand Down
4 changes: 2 additions & 2 deletions src/app/views/content/offer-list/offer-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class OfferListComponent implements OnInit {
}

fetchOffersData() {
this.openDataService.readAllOffers(`0-0-0`)
this.openDataService.readAllOffers(`0-0-1`)
.pipe(
tap(
data => {
Expand All @@ -87,7 +87,7 @@ export class OfferListComponent implements OnInit {
}

fetchPartnerOffersData(partner_id: string) {
this.openDataService.readOffersByStore(partner_id, `0-0-0`)
this.openDataService.readOffersByStore(partner_id, `0-0-1`)
.pipe(
tap(
data => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h1>{{ 'SECTIONS.partners-title' | translate }}</h1>
<div class="item-heading">
<div class="item-title">{{item.name}}</div>
<div>
<div class="partner-sector">{{item.sector}}</div>
<div class="partner-sector">{{translateSector(item) | translate}}</div>
</div>
</div>
<div class="item-description">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { tap, takeUntil, finalize } from 'rxjs/operators';

// Services & Models
import { OpenDataService } from '../../../core/services/open-data.service';
import { StaticDataService } from '../../../core/services/static-data.service';
import { Partner } from '../../../core/models/partner.model';
import { GeneralList } from '../../../core/interfaces/general-list.interface';

@Component({
selector: 'app-community-archive',
Expand All @@ -14,14 +16,17 @@ import { Partner } from '../../../core/models/partner.model';
export class CommunityArchiveComponent implements OnInit {
p: number = 1;
public partners: Partner[];
public sectorsList: GeneralList[];

loading: boolean = false;
private unsubscribe: Subject<any>;

constructor(
private cdRef: ChangeDetectorRef,
private openDataService: OpenDataService,
) {
private staticDataService: StaticDataService
) {
this.sectorsList = this.staticDataService.getSectorsList;
this.unsubscribe = new Subject();
}

Expand All @@ -35,6 +40,12 @@ export class CommunityArchiveComponent implements OnInit {
this.loading = false;
}

translateSector(partner: Partner) {
return this.sectorsList.filter((el) => {
return el.value == partner.sector
})[0].title;
}

fetchPartnersData() {
this.openDataService.readPartners(`0-0-0`)
.pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h1 class="single-title">{{partner.name}}</h1>
<div class="row">
<div class="col-md-6">
<div>
<div class="sector"><span class="mdi mdi-view-dashboard-outline"></span> {{partner.sector}}</div>
<div class="sector"><span class="mdi mdi-view-dashboard-outline"></span> {{translateSector(partner) | translate}}</div>
<div><span class="mdi mdi-email"></span> {{partner.email}}</div>
<!-- <div *ngIf="configSubAccess[1]&&partner.contact&&partner.contact.websiteURL"><span
class="mdi mdi-web"></span> <a target="_blank" href="{{partner.contact.websiteURL}}">
Expand Down
Loading

0 comments on commit 0c68194

Please sign in to comment.