2025-10-12 17:42:17 +00:00
|
|
|
import { baseAPI } from "@/lib/API";
|
|
|
|
|
import { createAsyncThunk, createSlice } from "@reduxjs/toolkit";
|
|
|
|
|
|
|
|
|
|
export const fetchAbout = createAsyncThunk(
|
|
|
|
|
"about/fetchAbout",
|
2026-02-11 20:45:37 +00:00
|
|
|
async ({ locale }: { locale: string }) => {
|
2025-10-12 17:42:17 +00:00
|
|
|
const res = await fetch(`${baseAPI}settings/about_us`, {
|
|
|
|
|
headers: {
|
2026-02-11 20:45:37 +00:00
|
|
|
"Accept-Language": locale,
|
2025-10-12 17:42:17 +00:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const data = await res.json();
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
interface AboutType {
|
|
|
|
|
aboutData: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const initialState: AboutType = {
|
|
|
|
|
aboutData: "",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const aboutSlice = createSlice({
|
|
|
|
|
name: "aboutUs",
|
|
|
|
|
initialState,
|
|
|
|
|
reducers: {
|
|
|
|
|
setAboutUsData(state, action) {
|
|
|
|
|
state.aboutData = action.payload;
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
extraReducers: (builder) => {
|
2026-02-11 20:45:37 +00:00
|
|
|
builder.addCase(fetchAbout.pending, (state) => {});
|
2025-10-12 17:42:17 +00:00
|
|
|
|
|
|
|
|
builder.addCase(fetchAbout.fulfilled, (state, action) => {
|
|
|
|
|
state.aboutData = action.payload;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
builder.addCase(fetchAbout.rejected, (state) => {
|
|
|
|
|
console.log("error");
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const { setAboutUsData } = aboutSlice.actions;
|
|
|
|
|
|
|
|
|
|
export default aboutSlice.reducer;
|