mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-09 19:22:51 +00:00
fix: add openingHours config and catch its errors
This commit is contained in:
1413
package-lock.json
generated
1413
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -89,7 +89,7 @@
|
|||||||
"ngx-logger": "4.1.9",
|
"ngx-logger": "4.1.9",
|
||||||
"ngx-markdown": "9.1.1",
|
"ngx-markdown": "9.1.1",
|
||||||
"ngx-moment": "5.0.0",
|
"ngx-moment": "5.0.0",
|
||||||
"opening_hours": "3.6.0",
|
"opening_hours": "3.7.0",
|
||||||
"rxjs": "6.6.3",
|
"rxjs": "6.6.3",
|
||||||
"tslib": "1.14.1",
|
"tslib": "1.14.1",
|
||||||
"zone.js": "0.11.4"
|
"zone.js": "0.11.4"
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import {Subscription} from 'rxjs';
|
|||||||
import {logger} from '../_helpers/ts-logger';
|
import {logger} from '../_helpers/ts-logger';
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires, unicorn/prefer-module
|
// eslint-disable-next-line @typescript-eslint/no-var-requires, unicorn/prefer-module
|
||||||
const openingHoursFn = require('opening_hours');
|
const ohFunction = require('opening_hours');
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@Pipe({
|
@Pipe({
|
||||||
@@ -96,7 +96,7 @@ export class StringSplitPipe implements PipeTransform {
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
@Pipe({
|
@Pipe({
|
||||||
name: 'openingHours',
|
name: 'openingHours',
|
||||||
pure: false,
|
pure: true,
|
||||||
})
|
})
|
||||||
export class OpeningHoursPipe implements PipeTransform, OnDestroy {
|
export class OpeningHoursPipe implements PipeTransform, OnDestroy {
|
||||||
locale: string;
|
locale: string;
|
||||||
@@ -140,10 +140,20 @@ export class OpeningHoursPipe implements PipeTransform, OnDestroy {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const openingHours = new openingHoursFn(aString);
|
let openingHours;
|
||||||
|
|
||||||
if ((openingHours.getWarnings() as string[]).length > 0) {
|
try {
|
||||||
logger.warn((openingHours.getWarnings() as string[]).join('. '));
|
openingHours = new ohFunction(aString, {
|
||||||
|
address: {
|
||||||
|
country_code: 'de',
|
||||||
|
state: 'Hessen',
|
||||||
|
},
|
||||||
|
lon: 8.667_97,
|
||||||
|
lat: 50.129_16,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
logger.warn(error);
|
||||||
|
this.value = '';
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user