Skip to content

Commit 7c7575f

Browse files
committed
refactor(app): move course and challenge detail related files
1 parent 4a01c3c commit 7c7575f

File tree

29 files changed

+200
-408
lines changed

29 files changed

+200
-408
lines changed

src/app/learn/[type]/ChallengesCard.js

-163
This file was deleted.

src/app/learn/[type]/[id]/layout.js src/app/learn/[type]/[id]/CourseDetailPageAdapter.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
export default function LearnDetailsLayout({children}) {
18-
return (
19-
<>{children}</>
20-
);
21-
}
17+
'use client';
18+
19+
export { default } from '#/entry/pages/course-detail';

src/app/learn/[type]/[id]/Time.js

-38
This file was deleted.

src/app/learn/[type]/[id]/[chapter_id]/page.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default async function ChapterPage({ params }) {
4949
const collection = { link: `/learn/${collectionType}`, text: collectionTextMap[collectionType] };
5050

5151
const datas = await Promise.all([
52-
get(`v1/learn/course/${params.type === 'courses' ? 'opencourse' : 'challenges'}/${params.id}`, {isServer: true}),
52+
get(`v1/learn/course/${collectionType === 'courses' ? 'opencourse' : 'challenges'}/${params.id}`, {isServer: true}),
5353
get(`ts/v1/learn/general/course/single/${params.chapter_id}`, {isServer: true}),
5454
]);
5555
const [{ data }, { data: lessonData }] = [...datas];

src/app/learn/[type]/[id]/loading.js

-66
This file was deleted.

src/app/learn/[type]/[id]/page.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import { PreviewAlert } from '@/components/PreviewAlert';
1818
import { get } from '@/utils/request';
1919

20-
import CourseOrChallengeDetail from './CourseOrChallengeDetail';
20+
import CourseDetailPageAdapter from './CourseDetailPageAdapter';
2121
import GrowPath from './GrowPath';
2222

2323
export async function generateMetadata({ params }) {
@@ -74,7 +74,7 @@ export default async function LearnDetailsPage({ params, searchParams }) {
7474
return learnType !== 'career_path' ? (
7575
<>
7676
<PreviewAlert searchParams={searchParams} />
77-
<CourseOrChallengeDetail params={params} data={data} permission={permission} related={related} />
77+
<CourseDetailPageAdapter params={params} data={data} permission={permission} related={related} />
7878
</>
7979
) : <GrowPath params={params} data={data} permission={permission} />;
8080
}

src/domain/challenge/views/challenge-list/ChallengeItem.js

+2-47
Original file line numberDiff line numberDiff line change
@@ -15,62 +15,17 @@
1515
*/
1616

1717
import clsx from 'clsx';
18-
import Image from 'next/image';
1918
import Link from 'next/link';
20-
import LocationIcon from 'public/images/location.svg';
21-
import TicketPic from 'public/images/ticket.png';
22-
import TimeIcon from 'public/images/time.svg';
2319
import ContentEditable from 'react-contenteditable';
2420

2521
import { USDTIcon } from '@/components/Icons';
2622
import { ArrowRightLineIcon } from '@/components/Icons';
2723
import { HTMLDecode } from '@/utils';
28-
import { formatTime } from '@/utils/date';
29-
30-
import { countries } from '#/lib/countries';
3124

3225
import { CardTitleWidget } from '../../../course';
26+
import DatePlaceWidget from '../../widgets/date-place';
3327
import TagListWidget from '../../widgets/tag-list';
3428

35-
export function TimeAndLocation({data, from, openTicket, permission, type}) {
36-
// console.log(data)
37-
38-
return (
39-
<>
40-
<div className="my-2 flex items-center justify-between">
41-
<div className="flex items-center">
42-
<Image src={TimeIcon} alt="" />
43-
<p className="text-sm opacity-60 ml-2">Time</p>
44-
</div>
45-
<div className="h-4">
46-
<p className="text-sm text-gray">
47-
{formatTime(data.challenges_extra.course_challenges_extra_start_date * 1000, 'YYYY/MM/DD')} -{' '}
48-
{formatTime(data.challenges_extra.course_challenges_extra_end_date * 1000, 'MM/DD')}
49-
{data.challenges_extra.course_challenges_extra_time_zone?.label?.substr(0, 11) && <span className="text-xs h-4 py-[2px]">{data.challenges_extra.course_challenges_extra_time_zone?.label?.substr(0, 11)}</span>}
50-
</p>
51-
</div>
52-
</div>
53-
<div className="mt-2 flex items-center justify-between gap-10">
54-
<div className="flex items-center">
55-
<Image src={LocationIcon} alt="" />
56-
<p className="text-sm opacity-60 ml-2">Location</p>
57-
</div>
58-
<p className="text-sm text-gray flex-1 text-right flex items-center justify-end gap-1">
59-
{
60-
data?.challenges_extra.course_challenges_extra_online ?
61-
'Online'
62-
:
63-
data?.challenges_extra.course_challenges_extra_country ?
64-
countries.find(f => f.code === data?.challenges_extra.course_challenges_extra_country)?.name
65-
+ ', ' + data?.challenges_extra.course_challenges_extra_city : ''
66-
}
67-
{!data?.challenges_extra.course_challenges_extra_online && from === 'rc' && (permission?.course_user_permission_status === 1 && type === 'challenges') && <Image onClick={openTicket} height={12} src={TicketPic} alt="" className="cursor-pointer" />}
68-
</p>
69-
</div>
70-
</>
71-
);
72-
}
73-
7429
function ChallengeItem({ data }) {
7530
return (
7631
<Link
@@ -91,7 +46,7 @@ function ChallengeItem({ data }) {
9146
disabled={true}
9247
/>
9348
</h6>
94-
<TimeAndLocation data={data} />
49+
<DatePlaceWidget data={data} />
9550
</div>
9651
<div className="flex items-center justify-between py-4 px-6">
9752
<div className="flex items-center gap-14">

src/domain/challenge/views/enrolled-challenge-list/EnrolledChallengeItem.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import Avatar from '@/components/Avatar';
2020
import Image from '@/components/Image';
2121
import { formatTime } from '@/utils/date';
2222

23-
import { ChallengesStatus } from '#/app/learn/[type]/ChallengesStatus';
23+
import StatusTag from '../../widgets/status-tag';
2424

2525
function EnrolledChallengeItem({ data }) {
2626
const router = useRouter();
@@ -51,7 +51,7 @@ function EnrolledChallengeItem({ data }) {
5151

5252
</div>
5353
<div className="flex mt-4 items-center text-sm opacity-80 md:mt-0">
54-
<ChallengesStatus data={data} />
54+
<StatusTag data={data} />
5555
<p>
5656
<span className="hidden md:inline">Time:&nbsp;</span>
5757
{formatTime(data.challenges_extra.course_challenges_extra_start_date * 1000, 'YYYY/MM/DD')} -{' '}

0 commit comments

Comments
 (0)