-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rajat Saxena
committed
Nov 8, 2024
1 parent
b27eb9e
commit 3adf235
Showing
7 changed files
with
89 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
apps/web/app/dashboard4/(sidebar)/product/[id]/section/[section]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"use client"; | ||
|
||
import DashboardContent from "@components/admin/dashboard-content"; | ||
import useCourse from "@components/admin/products/editor/course-hook"; | ||
import SectionEditor from "@components/admin/products/editor/section"; | ||
import { AddressContext } from "@components/contexts"; | ||
import { | ||
EDIT_SECTION_HEADER, | ||
MANAGE_COURSES_PAGE_HEADING, | ||
} from "@ui-config/strings"; | ||
import { truncate } from "@ui-lib/utils"; | ||
import { useContext } from "react"; | ||
|
||
export default function Page({ | ||
params, | ||
}: { | ||
params: { id: string; section: string }; | ||
}) { | ||
const address = useContext(AddressContext); | ||
const { id, section } = params; | ||
const course = useCourse(id, address); | ||
const breadcrumbs = [ | ||
{ label: MANAGE_COURSES_PAGE_HEADING, href: "/dashboard4/products" }, | ||
{ | ||
label: course ? truncate(course.title || "", 20) || "..." : "...", | ||
href: `/dashboard4/product/${id}?tab=Content`, | ||
}, | ||
{ | ||
label: EDIT_SECTION_HEADER, | ||
href: "#", | ||
}, | ||
]; | ||
|
||
return ( | ||
<DashboardContent breadcrumbs={breadcrumbs}> | ||
<SectionEditor | ||
id={id as string} | ||
section={section as string} | ||
address={address} | ||
prefix="/dashboard4" | ||
/> | ||
</DashboardContent> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 31 additions & 8 deletions
39
apps/web/pages/dashboard/product/[id]/section/[section]/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,47 @@ | ||
import dynamic from "next/dynamic"; | ||
import { useRouter } from "next/router"; | ||
import { EDIT_SECTION_HEADER } from "../../../../../../ui-config/strings"; | ||
import { EDIT_SECTION_HEADER } from "@/ui-config/strings"; | ||
import { connect } from "react-redux"; | ||
import { AppDispatch, AppState } from "@courselit/state-management"; | ||
import { Address } from "@courselit/common-models"; | ||
|
||
const BaseLayout = dynamic( | ||
() => import("../../../../../../components/admin/base-layout"), | ||
); | ||
const BaseLayout = dynamic(() => import("@/components/admin/base-layout")); | ||
|
||
const SectionEditor = dynamic( | ||
() => import("../../../../../../components/admin/products/editor/section"), | ||
() => import("@/components/admin/products/editor/section"), | ||
); | ||
|
||
function EditSection({}) { | ||
function EditSection({ | ||
address, | ||
dispatch, | ||
loading, | ||
}: { | ||
address: Address; | ||
dispatch: AppDispatch; | ||
loading: boolean; | ||
}) { | ||
const router = useRouter(); | ||
const { id, section } = router.query; | ||
|
||
return ( | ||
<BaseLayout title={EDIT_SECTION_HEADER}> | ||
<SectionEditor id={id as string} section={section as string} /> | ||
<SectionEditor | ||
address={address} | ||
id={id as string} | ||
section={section as string} | ||
dispatch={dispatch} | ||
loading={loading} | ||
prefix="/dashboard" | ||
/> | ||
</BaseLayout> | ||
); | ||
} | ||
|
||
export default EditSection; | ||
const mapStateToProps = (state: AppState) => ({ | ||
loading: state.networkAction, | ||
address: state.address, | ||
}); | ||
|
||
const mapDispatchToProps = (dispatch: AppDispatch) => ({ dispatch }); | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(EditSection); |