exports.id = 1;
exports.ids = [1];
exports.modules = {

/***/ 7502:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "O": () => (/* binding */ getHomePageNewsCategory),
/* harmony export */   "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var _lib_timeDifference__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9483);
/* harmony import */ var _reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5184);
/* harmony import */ var _reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_0__);


// Slice
const slice = (0,_reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_0__.createSlice)({
    name: "homePageNewsCategory",
    initialState: {
        homePageNewsCategory: [],
        homePageNewsCategoryStatus: false
    },
    reducers: {
        setHomePageNewsCategory: (state, action)=>{
            state.homePageNewsCategory = action.payload;
            state.homePageNewsCategoryStatus = true;
        }
    }
});
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (slice.reducer);
// Actions
const setLocalStorageData = (par)=>{
    var now = new Date();
    localStorage.setItem("homePageNewsCategory", JSON.stringify({
        items: par,
        time: now
    }));
};
const getLocalStorageData = ()=>{
    const getData = localStorage.getItem("homePageNewsCategory");
    const data = JSON.parse(getData);
    if (data && data?.items?.length > 0) {
        return data;
    } else {
        return false;
    }
};
const { setHomePageNewsCategory  } = slice.actions;
const getHomePageNewsCategory = ()=>async (dispatch)=>{
        const data = getLocalStorageData();
        const storageDate = new Date(data?.time);
        const time = (0,_lib_timeDifference__WEBPACK_IMPORTED_MODULE_1__/* .minuteDifference */ .I)(storageDate);
        try {
            if (data && time < 5) {
                dispatch(setHomePageNewsCategory(data?.items));
            } else {
                try {
                    const request = await fetch(`${"https://api.trsondakika.com/api"}/getHomePageNewsCategory?language=${"tr"}`, {
                        method: "GET",
                        headers: {
                            "Content-Type": "application/json"
                        }
                    });
                    const response = await request.json();
                    setLocalStorageData(response?.categories);
                    dispatch(setHomePageNewsCategory(response?.categories));
                } catch (e) {
                    return console.error(e.message);
                }
            }
        } catch (e1) {
            console.log("getHomePageNewsCategory error:", e1);
        }
    };


/***/ }),

/***/ 8722:
/***/ (() => {



/***/ })

};
;