Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
sujata
/
Akruti-Frontend
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Registry
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 45857fab
authored
2026-03-30 15:55:59 +0530
by
Ravindra Kanojiya
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
updated header slice
1 parent
d4a59b1e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
37 deletions
redux/slices/headerSlice.js
redux/slices/headerSlice.js
View file @
45857fa
// store/HeaderSlice.js
import
{
createSlice
,
createAsyncThunk
}
from
"@reduxjs/toolkit"
;
import
axios
from
"axios"
;
import
qs
from
"qs"
;
export
const
fetchHeader
=
createAsyncThunk
(
"HeaderSlice/fetchHeader"
,
async
()
=>
{
const
query
=
{
populate
:
[
"headerLeft"
,
"headerRight.image"
,
],
};
const
queryString
=
qs
.
stringify
(
query
,
{
encodeValuesOnly
:
true
,
});
const
endpoint
=
`
${
process
.
env
.
NEXT_PUBLIC_BACKEND_API_URL
}
/api/headers?
${
queryString
}
`
;
const
response
=
await
axios
.
get
(
endpoint
);
return
response
.
data
.
data
;
}
"Header/fetchHeader"
,
async
()
=>
{
const
query
=
{
populate
:
[
"headerLeft"
,
"headerRight.image"
],
};
const
queryString
=
qs
.
stringify
(
query
,
{
encodeValuesOnly
:
true
,
});
const
endpoint
=
`
${
process
.
env
.
NEXT_PUBLIC_BACKEND_API_URL
}
/api/headers?
${
queryString
}
`
;
const
response
=
await
axios
.
get
(
endpoint
);
return
response
.
data
.
data
;
}
);
const
HeaderSlice
=
createSlice
({
name
:
"Header"
,
initialState
:
{
status
:
"idle"
,
data
:
[],
error
:
null
,
},
reducers
:
{},
extraReducers
:
(
builder
)
=>
{
builder
.
addCase
(
fetchHeader
.
pending
,
(
state
)
=>
{
state
.
status
=
"loading"
;
})
.
addCase
(
fetchHeader
.
fulfilled
,
(
state
,
action
)
=>
{
state
.
status
=
"succeeded"
;
state
.
data
=
action
.
payload
;
})
.
addCase
(
fetchHeader
.
rejected
,
(
state
,
action
)
=>
{
state
.
status
=
"failed"
;
state
.
error
=
action
.
error
.
message
;
});
},
name
:
"Header"
,
initialState
:
{
status
:
"idle"
,
data
:
[],
error
:
null
,
},
reducers
:
{},
extraReducers
:
(
builder
)
=>
{
builder
.
addCase
(
fetchHeader
.
pending
,
(
state
)
=>
{
state
.
status
=
"loading"
;
})
.
addCase
(
fetchHeader
.
fulfilled
,
(
state
,
action
)
=>
{
state
.
status
=
"succeeded"
;
state
.
data
=
action
.
payload
;
})
.
addCase
(
fetchHeader
.
rejected
,
(
state
,
action
)
=>
{
state
.
status
=
"failed"
;
state
.
error
=
action
.
error
.
message
;
});
},
});
export
default
HeaderSlice
.
reducer
;
export
default
HeaderSlice
.
reducer
;
\ No newline at end of file
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment