import { Injectable } from '@angular/core';
import { DictionariesService } from '@modules/components/page-filters/services/dictionaries-service';
import { BehaviorSubject } from 'rxjs';

@Injectable({
    providedIn: 'root',
})
export class UserLocationService {
    location = new BehaviorSubject<string | null>(null);

    constructor(private dictionaries: DictionariesService) {}

    locate() {
        this.dictionaries.locate().then((city) => {
            if (city) {
                this.location.next(city.code);
            }
        });
    }
}
