Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sweepstake
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Arjun Jhukal
sweepstake
Commits
fb3d2e9c
Commit
fb3d2e9c
authored
Oct 09, 2025
by
Arjun Jhukal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated the functionality for the update page
parent
84e32cf0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
17 deletions
+40
-17
index.tsx
...s/pages/dashboard/adminDashboard/pages/add-page/index.tsx
+40
-17
No files found.
src/components/pages/dashboard/adminDashboard/pages/add-page/index.tsx
View file @
fb3d2e9c
...
@@ -26,6 +26,7 @@ export default function AddPageForm({ id }: { id?: string }) {
...
@@ -26,6 +26,7 @@ export default function AddPageForm({ id }: { id?: string }) {
})
})
const
[
updatedPage
,
{
isLoading
:
updating
}]
=
useUpdatePageByIdMutation
();
const
[
updatedPage
,
{
isLoading
:
updating
}]
=
useUpdatePageByIdMutation
();
console
.
log
(
"single page data"
,
data
);
const
dispatch
=
useAppDispatch
();
const
dispatch
=
useAppDispatch
();
const
router
=
useRouter
();
const
router
=
useRouter
();
const
formik
=
useFormik
({
const
formik
=
useFormik
({
...
@@ -66,23 +67,45 @@ export default function AddPageForm({ id }: { id?: string }) {
...
@@ -66,23 +67,45 @@ export default function AddPageForm({ id }: { id?: string }) {
try
{
if
(
id
)
{
const
response
=
await
createPage
(
formData
).
unwrap
();
try
{
dispatch
(
const
response
=
await
updatedPage
({
id
,
body
:
formData
}).
unwrap
();
showToast
({
dispatch
(
message
:
response
.
message
||
"Page created successfully"
,
showToast
({
variant
:
ToastVariant
.
SUCCESS
message
:
response
.
message
||
"Page created successfully"
,
})
variant
:
ToastVariant
.
SUCCESS
);
})
router
.
push
(
"/pages"
);
);
}
catch
(
e
:
any
)
{
router
.
push
(
"/pages"
);
console
.
error
(
"Error submitting form:"
,
e
);
}
catch
(
e
:
any
)
{
dispatch
(
console
.
error
(
"Error submitting form:"
,
e
);
showToast
({
dispatch
(
message
:
e
.
message
||
"Something went wrong"
,
showToast
({
variant
:
ToastVariant
.
ERROR
message
:
e
.
message
||
"Something went wrong"
,
})
variant
:
ToastVariant
.
ERROR
);
})
);
}
}
else
{
try
{
const
response
=
await
createPage
(
formData
).
unwrap
();
dispatch
(
showToast
({
message
:
response
.
message
||
"Page created successfully"
,
variant
:
ToastVariant
.
SUCCESS
})
);
router
.
push
(
"/pages"
);
}
catch
(
e
:
any
)
{
console
.
error
(
"Error submitting form:"
,
e
);
dispatch
(
showToast
({
message
:
e
.
message
||
"Something went wrong"
,
variant
:
ToastVariant
.
ERROR
})
);
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment