Skip to content

Commit

Permalink
refactor: farmer activity and manual tool deployment settings
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismclarke committed May 6, 2024
1 parent fc451ef commit ef9176a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,18 @@ export class ActivityDetailsComponent implements OnInit, OnDestroy {
* with fallback to default video set
*/
private getVideoResource(activity: IActivityEntry) {
const { language, country } = this.configurationService.activeConfiguration.localisation;
const { language_code } = this.configurationService.userSettings();
const { country_code } = this.configurationService.deploymentSettings();
const localisedVideos = jsonNestedProperty<IFarmerVideosById>(
PICSA_FARMER_VIDEO_RESOURCES,
`${language.selected?.code}.360p`
`${language_code}.360p`
);
if (localisedVideos?.[activity.videoId]) {
return localisedVideos[activity.videoId];
}
// HACK - Use default fallbacks for ZM or MW
// TODO - add english versions and make default fallback
return country.code === 'zm'
return country_code === 'zm'
? PICSA_FARMER_VIDEO_RESOURCES.zm_ny['360p'][activity.videoId]
: PICSA_FARMER_VIDEO_RESOURCES.mw_ny['360p'][activity.videoId];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<ng-container *ngTemplateOutlet="manualDownload; context: { version: 'extension' }"></ng-container>
<picsa-manual-steps-container
[style.visibility]="pdfSrc ? 'visible' : 'hidden'"
[pageMapping]="localisation"
[pageMapping]="languageCode"
[stepData]="contents.extension"
[@fadeInOut]="extensionTab.isActive ? 'in' : 'out'"
></picsa-manual-steps-container>
Expand All @@ -27,7 +27,7 @@
<ng-container *ngTemplateOutlet="manualDownload; context: { version: 'farmer' }"></ng-container>
<picsa-manual-steps-container
[style.visibility]="pdfSrc ? 'visible' : 'hidden'"
[pageMapping]="localisation"
[pageMapping]="languageCode"
[stepData]="contents.farmer"
[@fadeInOut]="farmerTab.isActive ? 'in' : 'out'"
></picsa-manual-steps-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, O
import { ActivatedRoute } from '@angular/router';
import { marker as translateMarker } from '@biesbjerg/ngx-translate-extract-marker';
import { ConfigurationService } from '@picsa/configuration/src';
import { ILanguageCode } from '@picsa/data/deployments';
import { IResourceFile } from '@picsa/resources/src/app/schemas';
import { ResourcesToolService } from '@picsa/resources/src/app/services/resources-tool.service';
import { FadeInOut, FlyInOut } from '@picsa/shared/animations';
Expand Down Expand Up @@ -42,7 +43,7 @@ export class HomeComponent implements OnDestroy, AfterViewInit {
extension: null,
};

public localisation: string;
public languageCode: ILanguageCode;

public page?: number = undefined;
public pdfSrc?: string;
Expand Down Expand Up @@ -73,7 +74,7 @@ export class HomeComponent implements OnDestroy, AfterViewInit {
});
const version = this.getManualVersion();
this.initialTabIndex = TAB_MAPPING[version];
this.localisation = this.ConfigurationService.activeConfiguration.localisation.language.selected?.code || 'en';
this.languageCode = this.ConfigurationService.userSettings().language_code;
}

async ngAfterViewInit() {
Expand All @@ -97,7 +98,7 @@ export class HomeComponent implements OnDestroy, AfterViewInit {
private async loadManual() {
await this.resourcesService.ready();
const version = this.getManualVersion();
const manualResource = LOCALISED_VERSIONS[version][this.localisation] || LOCALISED_VERSIONS[version].en;
const manualResource = LOCALISED_VERSIONS[version][this.languageCode] || LOCALISED_VERSIONS[version].en;
if (this.pdfSrc) {
return;
}
Expand Down

0 comments on commit ef9176a

Please sign in to comment.