1.9.1 • Published 11 months ago

anysolve v1.9.1

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Anysolve

$ npm install anysolve axios zustand

useAllStore (Zustand)

// export module types
export type modulesType = {
  customers: CustomersStoreType;
  itemServices: ItemServicesStoreType;
  news: NewsStoreType;
};


export type allT =
  | CustomersStoreType
  | ItemServicesStoreType
  | NewsStoreType

import { StoreApi, UseBoundStore } from "zustand";
  // export module stores
export default const useAllStore = (
  type: keyof modulesType
): UseBoundStore<StoreApi<allT>> => {
  switch (type) {
    case "customers":
// return customers store
      return useCustomersStore;
    case "itemServices":
      return useServicesStore;
    case "news":
      return useNewsStore;
  }
};

Dialog store

const useDialog = create<DeleteDialog>()((set) => ({
  deleteInfo: {
    isOpen: false,
  },
  setDeleteInfo: (deleteInfo: Delete) => set(() => ({ deleteInfo })),
}));

export default useDialog;

Main class

// apiURLs - object which return modules {name: url}
const apiURLs: {
  [P in keyof modulesType]: string;
} = {
  customers: "customers",
  itemServices: "product",
  news: "news",
};

export class Aos extends BaseAos<modulesType> {
  constructor() {
    super({
      apiUrls: apiURLs,
      services: {
        messageConfig: {
// messageAlert function which return Snakebar (message, type: "danger" | "succes") =>
          messageAlert: messageAlert,
        },
        baseUrl: "https://baseURL",
      },
      store: useAllStore,
//store which
      useDialog: useDialog,
    });
  }
}
1.9.1

11 months ago

1.8.1

1 year ago

1.8.0

1 year ago

1.4.6

1 year ago

1.4.5

1 year ago

1.4.4

1 year ago

1.7.9

1 year ago

1.7.8

1 year ago

1.7.7

1 year ago

1.6.7

1 year ago

1.5.7

1 year ago

1.4.7

1 year ago

0.4.4

1 year ago

0.4.3

1 year ago

0.1.2

1 year ago

0.3.2

1 year ago

0.2.2

1 year ago

0.4.2

1 year ago

0.1.1

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago