fix: environment config changes in the API are replicated in web and space app (#2699)
* fix: envconfig type changes * chore: configuration variables (#2692) * chore: update avatar group logic (#2672) * chore: configuration variables --------- * fix: replacing slack client id with env config --------- Co-authored-by: Nikhil <118773738+pablohashescobar@users.noreply.github.com>
This commit is contained in:
parent
1986c0dfd4
commit
26de35bd8d
14 changed files with 189 additions and 89 deletions
47
web/store/app-config.store.ts
Normal file
47
web/store/app-config.store.ts
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import { observable, action, makeObservable, runInAction } from "mobx";
|
||||
// types
|
||||
import { RootStore } from "./root";
|
||||
import { IAppConfig } from "types/app";
|
||||
// services
|
||||
import { AppConfigService } from "services/app_config.service";
|
||||
|
||||
export interface IAppConfigStore {
|
||||
envConfig: IAppConfig | null;
|
||||
// action
|
||||
fetchAppConfig: () => Promise<any>;
|
||||
}
|
||||
|
||||
class AppConfigStore implements IAppConfigStore {
|
||||
// observables
|
||||
envConfig: IAppConfig | null = null;
|
||||
|
||||
// root store
|
||||
rootStore;
|
||||
// service
|
||||
appConfigService;
|
||||
|
||||
constructor(_rootStore: RootStore) {
|
||||
makeObservable(this, {
|
||||
// observables
|
||||
envConfig: observable.ref,
|
||||
// actions
|
||||
fetchAppConfig: action,
|
||||
});
|
||||
this.appConfigService = new AppConfigService();
|
||||
|
||||
this.rootStore = _rootStore;
|
||||
}
|
||||
fetchAppConfig = async () => {
|
||||
try {
|
||||
const config = await this.appConfigService.envConfig();
|
||||
runInAction(() => {
|
||||
this.envConfig = config;
|
||||
});
|
||||
return config;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default AppConfigStore;
|
||||
Loading…
Add table
Add a link
Reference in a new issue