mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-06-06 18:31:00 +00:00
cleanup content menu bar, added free and paid categories as well
This commit is contained in:
parent
efe867e9d9
commit
a9d2d5a304
@ -82,8 +82,8 @@ export function CourseTemplate({ course }) {
|
|||||||
</div>
|
</div>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
</div>
|
</div>
|
||||||
<CardContent className={`${isMobile ? "px-3" : ""} pt-6 pb-2 w-full flex flex-row justify-between items-center`}>
|
<CardContent className={`${isMobile ? "px-3" : ""} pt-6 pb-2 w-full flex flex-row justify-between items-start`}>
|
||||||
<div className="flex flex-wrap gap-2 max-w-[70%]">
|
<div className="flex flex-wrap gap-2 max-w-[65%]">
|
||||||
{course && course.topics && course.topics.map((topic, index) => (
|
{course && course.topics && course.topics.map((topic, index) => (
|
||||||
<Tag size="small" key={index} className="px-2 py-1 text-sm text-[#f8f8ff]">
|
<Tag size="small" key={index} className="px-2 py-1 text-sm text-[#f8f8ff]">
|
||||||
{topic}
|
{topic}
|
||||||
|
@ -71,8 +71,8 @@ export function DocumentTemplate({ document, isLesson }) {
|
|||||||
</div>
|
</div>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
</div>
|
</div>
|
||||||
<CardContent className={`${isMobile ? "px-3" : ""} pt-6 pb-2 w-full flex flex-row justify-between items-center`}>
|
<CardContent className={`${isMobile ? "px-3" : ""} pt-6 pb-2 w-full flex flex-row justify-between items-start`}>
|
||||||
<div className="flex flex-wrap gap-2 max-w-[70%]">
|
<div className="flex flex-wrap gap-2 max-w-[65%]">
|
||||||
{isLesson && <Tag size="small" className="px-2 py-1 text-sm text-[#f8f8ff]" value="lesson" />}
|
{isLesson && <Tag size="small" className="px-2 py-1 text-sm text-[#f8f8ff]" value="lesson" />}
|
||||||
{document?.topics?.map((topic, index) => (
|
{document?.topics?.map((topic, index) => (
|
||||||
<Tag size="small" key={index} className="px-2 py-1 text-sm text-[#f8f8ff]">
|
<Tag size="small" key={index} className="px-2 py-1 text-sm text-[#f8f8ff]">
|
||||||
|
@ -72,8 +72,8 @@ export function VideoTemplate({ video, isLesson }) {
|
|||||||
</div>
|
</div>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
</div>
|
</div>
|
||||||
<CardContent className={`${isMobile ? "px-3" : ""} pt-6 pb-2 w-full flex flex-row justify-between items-center`}>
|
<CardContent className={`${isMobile ? "px-3" : ""} pt-6 pb-2 w-full flex flex-row justify-between items-start`}>
|
||||||
<div className="flex flex-wrap gap-2 max-w-[70%]">
|
<div className="flex flex-wrap gap-2 max-w-[65%]">
|
||||||
{isLesson && <Tag size="small" className="px-3 py-1 text-sm text-[#f8f8ff]" value="lesson" />}
|
{isLesson && <Tag size="small" className="px-3 py-1 text-sm text-[#f8f8ff]" value="lesson" />}
|
||||||
{video?.topics?.map((topic, index) => (
|
{video?.topics?.map((topic, index) => (
|
||||||
<Tag size="small" key={index} className="px-3 py-1 text-sm text-[#f8f8ff]">
|
<Tag size="small" key={index} className="px-3 py-1 text-sm text-[#f8f8ff]">
|
||||||
|
@ -12,8 +12,10 @@ import { useRouter } from 'next/router';
|
|||||||
|
|
||||||
const MenuTab = ({ items, selectedTopic, onTabChange }) => {
|
const MenuTab = ({ items, selectedTopic, onTabChange }) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
// spread the items except for 'document' 'video' and 'course'
|
// Reorder items to put 'Free' and 'Paid' after 'Courses', 'Videos', and 'Documents'
|
||||||
const allItems = ['All', ...items.filter(item => item !== 'document' && item !== 'video' && item !== 'course')];
|
const priorityItems = ['All', 'Courses', 'Videos', 'Documents', 'Free', 'Paid'];
|
||||||
|
const otherItems = items.filter(item => !priorityItems.includes(item) && item !== 'document' && item !== 'video' && item !== 'course');
|
||||||
|
const allItems = [...priorityItems, ...otherItems];
|
||||||
|
|
||||||
const menuItems = allItems.map((item, index) => {
|
const menuItems = allItems.map((item, index) => {
|
||||||
let icon = 'pi pi-tag';
|
let icon = 'pi pi-tag';
|
||||||
@ -21,6 +23,8 @@ const MenuTab = ({ items, selectedTopic, onTabChange }) => {
|
|||||||
else if (item === 'Documents') icon = 'pi pi-file';
|
else if (item === 'Documents') icon = 'pi pi-file';
|
||||||
else if (item === 'Videos') icon = 'pi pi-video';
|
else if (item === 'Videos') icon = 'pi pi-video';
|
||||||
else if (item === 'Courses') icon = 'pi pi-desktop';
|
else if (item === 'Courses') icon = 'pi pi-desktop';
|
||||||
|
else if (item === 'Free') icon = 'pi pi-lock-open';
|
||||||
|
else if (item === 'Paid') icon = 'pi pi-lock';
|
||||||
|
|
||||||
const queryParam = item === 'all' ? '' : `?tag=${item.toLowerCase()}`;
|
const queryParam = item === 'all' ? '' : `?tag=${item.toLowerCase()}`;
|
||||||
const isActive = router.asPath === `/content${queryParam}`;
|
const isActive = router.asPath === `/content${queryParam}`;
|
||||||
@ -118,7 +122,7 @@ const ContentPage = () => {
|
|||||||
setAllContent(allContent);
|
setAllContent(allContent);
|
||||||
|
|
||||||
const uniqueTopics = new Set(allContent.map(item => item.topics).flat());
|
const uniqueTopics = new Set(allContent.map(item => item.topics).flat());
|
||||||
const priorityItems = ['All', 'Courses', 'Videos', 'Documents'];
|
const priorityItems = ['All', 'Courses', 'Videos', 'Documents', 'Free', 'Paid'];
|
||||||
const otherTopics = Array.from(uniqueTopics).filter(topic => !priorityItems.includes(topic));
|
const otherTopics = Array.from(uniqueTopics).filter(topic => !priorityItems.includes(topic));
|
||||||
const combinedTopics = [...priorityItems.slice(1), ...otherTopics];
|
const combinedTopics = [...priorityItems.slice(1), ...otherTopics];
|
||||||
setAllTopics(combinedTopics);
|
setAllTopics(combinedTopics);
|
||||||
@ -130,10 +134,16 @@ const ContentPage = () => {
|
|||||||
|
|
||||||
const filterContent = (topic, content) => {
|
const filterContent = (topic, content) => {
|
||||||
let filtered = content;
|
let filtered = content;
|
||||||
|
console.log('topic', topic);
|
||||||
|
console.log('content', content);
|
||||||
if (topic !== 'All') {
|
if (topic !== 'All') {
|
||||||
const topicLower = topic.toLowerCase();
|
const topicLower = topic.toLowerCase();
|
||||||
if (['courses', 'videos', 'documents'].includes(topicLower)) {
|
if (['courses', 'videos', 'documents'].includes(topicLower)) {
|
||||||
filtered = content.filter(item => item.type === topicLower.slice(0, -1));
|
filtered = content.filter(item => item.type === topicLower.slice(0, -1));
|
||||||
|
} else if (topicLower === 'free') {
|
||||||
|
filtered = content.filter(item => !item.price || Number(item.price) === 0);
|
||||||
|
} else if (topicLower === 'paid') {
|
||||||
|
filtered = content.filter(item => item.price && Number(item.price) > 0);
|
||||||
} else {
|
} else {
|
||||||
filtered = content.filter(item => item.topics && item.topics.includes(topic.toLowerCase()));
|
filtered = content.filter(item => item.topics && item.topics.includes(topic.toLowerCase()));
|
||||||
}
|
}
|
||||||
@ -167,7 +177,7 @@ const ContentPage = () => {
|
|||||||
<h1 className="text-3xl font-bold mb-4 ml-1">All Content</h1>
|
<h1 className="text-3xl font-bold mb-4 ml-1">All Content</h1>
|
||||||
</div>
|
</div>
|
||||||
<MenuTab
|
<MenuTab
|
||||||
items={['Courses', 'Videos', 'Documents', ...allTopics.filter(topic => !['Courses', 'Videos', 'Documents'].includes(topic))]}
|
items={allTopics}
|
||||||
selectedTopic={selectedTopic}
|
selectedTopic={selectedTopic}
|
||||||
onTabChange={handleTopicChange}
|
onTabChange={handleTopicChange}
|
||||||
className="max-w-[90%] mx-auto"
|
className="max-w-[90%] mx-auto"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user