Sengi-Windows-MacOS-Linux/src/app/stores/registered-apps.state.ts

34 lines
824 B
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { State, Action, StateContext } from '@ngxs/store';
export class AddRegisteredApp {
static readonly type = '[RegisteredApps] Add app';
constructor(public app: AppInfo) { }
}
export interface RegisteredAppsStateModel {
registeredApps: AppInfo[];
}
@State<RegisteredAppsStateModel>({
name: 'registeredapps',
defaults: {
registeredApps: []
}
})
export class RegisteredAppsState {
@Action(AddRegisteredApp)
AddRegisteredApp(ctx: StateContext<RegisteredAppsStateModel>, action: AddRegisteredApp) {
const state = ctx.getState();
ctx.setState({
registeredApps: [...state.registeredApps, action.app]
});
}
}
export class AppInfo {
id: number;
name: string;
redirect_uri: string;
client_id: string;
client_secret: string;
}