123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- import { mock, query } from '../helpers';
- import { actionPromise } from '../reducers';
- export const actionRootCats = () => async (dispatch, getState) => {
- dispatch(
- actionPromise(
- 'rootCats',
- new Promise((resolve) => {
- setTimeout(
- Math.random() > 0.01
- ? resolve({
- data: [
- {
- id: 1,
- name: 'Categoty 1',
- },
- {
- id: 2,
- name: 'Categoty 2',
- },
- {
- id: 3,
- name: 'Categoty 3',
- },
- {
- id: 4,
- name: 'Categoty 4',
- },
- ],
- })
- : resolve({
- errors: [{ message: 'Error adsasdadas' }],
- }),
- 400
- );
- })
- // .then((res) => res.json())
- .then((data) => {
- console.log(data);
- if (data.errors) {
- throw new Error(JSON.stringify(data.errors));
- } else return data.data;
- })
- )
- );
- };
- // () => ({
- // data: [
- // {
- // id: 1,
- // name: 'Categoty 1',
- // },
- // {
- // id: 2,
- // name: 'Categoty 2',
- // },
- // {
- // id: 3,
- // name: 'Categoty 3',
- // },
- // {
- // id: 4,
- // name: 'Categoty 4',
- // },
- // ],
- // }),
- // .then((data) => {
- // if (data.errors) {
- // throw new Error(JSON.stringify(data.errors));
- // } else return Object.values(data.data)[0];
- // })
- // fetch(backendURL + "/api/reception/patient/", {
- // method: "GET",
- // headers: {
- // "Content-Type": "application/json",
- // ...(localStorage.authToken ? { Authorization: "Bearer " + localStorage.authToken } : {}),
- // },
- // });
- // actionPromise("patientAll", fetch(url, {
- // type:"GET",
- // headers: {
- // "Content-Type": "application/json",
- // ...(localStorage.authToken ? { Authorization: "Bearer " + localStorage.authToken } : {}),
- // },
- // body: data,
- // })
- // .then((res) => res.json())
- // .then((data) => {
- // if (typeof data === "string") {
- // throw new Error(data);
- // } else return Object.values(data);
- // }))
|