* fix: remove unused imports and variables (part 1) Resolve oxlint no-unused-vars warnings in packages/*, apps/admin, apps/space, apps/live, and apps/web (non-core). * fix: resolve CI check failures * fix: resolve check:types failures * fix: resolve check:types and check:format failures - Use destructuring alias for activeCycleResolvedPath - Format propel tab-navigation file * fix: format propel button helper with oxfmt Reorder Tailwind classes to match oxfmt canonical ordering.
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
/**
|
|
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
* See the LICENSE file for details.
|
|
*/
|
|
|
|
import { clone } from "lodash-es";
|
|
import { action, computed, makeObservable, observable, runInAction } from "mobx";
|
|
// plane imports
|
|
import { SitesStateService } from "@plane/services";
|
|
import type { IState } from "@plane/types";
|
|
// helpers
|
|
import { sortStates } from "@/helpers/state.helper";
|
|
// store
|
|
import type { RootStore } from "./root.store";
|
|
|
|
export interface IStateStore {
|
|
// observables
|
|
states: IState[] | undefined;
|
|
//computed
|
|
sortedStates: IState[] | undefined;
|
|
// computed actions
|
|
getStateById: (stateId: string | undefined) => IState | undefined;
|
|
// fetch actions
|
|
fetchStates: (anchor: string) => Promise<IState[]>;
|
|
}
|
|
|
|
export class StateStore implements IStateStore {
|
|
states: IState[] | undefined = undefined;
|
|
stateService: SitesStateService;
|
|
rootStore: RootStore;
|
|
|
|
constructor(_rootStore: RootStore) {
|
|
makeObservable(this, {
|
|
// observables
|
|
states: observable,
|
|
// computed
|
|
sortedStates: computed,
|
|
// fetch action
|
|
fetchStates: action,
|
|
});
|
|
this.stateService = new SitesStateService();
|
|
this.rootStore = _rootStore;
|
|
}
|
|
|
|
get sortedStates() {
|
|
if (!this.states) return;
|
|
return sortStates(clone(this.states));
|
|
}
|
|
|
|
getStateById = (stateId: string | undefined) => this.states?.find((state) => state.id === stateId);
|
|
|
|
fetchStates = async (anchor: string) => {
|
|
const statesResponse = await this.stateService.list(anchor);
|
|
runInAction(() => {
|
|
this.states = statesResponse;
|
|
});
|
|
return statesResponse;
|
|
};
|
|
}
|