move from ArticleModel[] to ArticlesModel
This commit is contained in:
@@ -15,7 +15,7 @@ import Profile from './components/Profile';
|
|||||||
import { useArticles } from './providers/Article';
|
import { useArticles } from './providers/Article';
|
||||||
import { useAuth } from './providers/Author';
|
import { useAuth } from './providers/Author';
|
||||||
import { View, useViewRouter } from "./types/views";
|
import { View, useViewRouter } from "./types/views";
|
||||||
import { ArticleModel } from "./types/models";
|
import { ArticlesModel } from "./types/models";
|
||||||
import { ArticleViewProps, ArticleEditorProps } from "./types/props";
|
import { ArticleViewProps, ArticleEditorProps } from "./types/props";
|
||||||
|
|
||||||
function HomeView({ currentUser, open_login, open_profile, open_create, articles, openArticle }: any) {
|
function HomeView({ currentUser, open_login, open_profile, open_create, articles, openArticle }: any) {
|
||||||
@@ -59,7 +59,7 @@ export default function Blog(props: { disableCustomTheme?: boolean }) {
|
|||||||
|
|
||||||
type RouterContext = {
|
type RouterContext = {
|
||||||
ui: any;
|
ui: any;
|
||||||
articles: ArticleModel[];
|
articles: ArticlesModel;
|
||||||
currentUser: any;
|
currentUser: any;
|
||||||
openArticle: (index: number) => void;
|
openArticle: (index: number) => void;
|
||||||
};
|
};
|
||||||
@@ -96,14 +96,14 @@ export default function Blog(props: { disableCustomTheme?: boolean }) {
|
|||||||
open_editor: 'onEdit',
|
open_editor: 'onEdit',
|
||||||
},
|
},
|
||||||
extraProps: ({ ui, articles }) => ({
|
extraProps: ({ ui, articles }) => ({
|
||||||
article: articles[ui.selectedArticle!],
|
article: articles.readByIndex(ui.selectedArticle),
|
||||||
}) satisfies Partial<ArticleViewProps>,
|
}) satisfies Partial<ArticleViewProps>,
|
||||||
},
|
},
|
||||||
|
|
||||||
editor: {
|
editor: {
|
||||||
component: ArticleEditor,
|
component: ArticleEditor,
|
||||||
extraProps: ({ ui, articles }) => ({
|
extraProps: ({ ui, articles }) => ({
|
||||||
article: ui.selectedArticle !== null ? articles[ui.selectedArticle] : null,
|
article: ui.selectedArticle !== null ? articles.readByIndex(ui.selectedArticle) : null,
|
||||||
}) satisfies Partial<ArticleEditorProps>,
|
}) satisfies Partial<ArticleEditorProps>,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import OutlinedInput from '@mui/material/OutlinedInput';
|
|||||||
import SearchRoundedIcon from '@mui/icons-material/SearchRounded';
|
import SearchRoundedIcon from '@mui/icons-material/SearchRounded';
|
||||||
import RssFeedRoundedIcon from '@mui/icons-material/RssFeedRounded';
|
import RssFeedRoundedIcon from '@mui/icons-material/RssFeedRounded';
|
||||||
|
|
||||||
import { ArticleModel } from "../types/models";
|
import {ArticlesModel, createArticlesModelObject} from "../types/models";
|
||||||
import { MainContentProps } from "../types/props";
|
import { MainContentProps } from "../types/props";
|
||||||
import ArticleCardsGrid from "./ArticleCards/ArticleCardsGrid";
|
import ArticleCardsGrid from "./ArticleCards/ArticleCardsGrid";
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ export default function MainContent({
|
|||||||
onSelectArticle,
|
onSelectArticle,
|
||||||
}: MainContentProps) {
|
}: MainContentProps) {
|
||||||
|
|
||||||
const [visibleArticles, setVisibleArticles] = React.useState<ArticleModel[]>(articles);
|
const [visibleArticles, setVisibleArticles] = React.useState<ArticlesModel>(articles);
|
||||||
const [activeTag, setActiveTag] = React.useState<string>('all');
|
const [activeTag, setActiveTag] = React.useState<string>('all');
|
||||||
|
|
||||||
const filterArticlesByTag = (tag: string) => {
|
const filterArticlesByTag = (tag: string) => {
|
||||||
@@ -58,11 +58,11 @@ export default function MainContent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 🔵 Filter by selected tag
|
// 🔵 Filter by selected tag
|
||||||
const filtered = articles.filter((article) => article.tag === tag);
|
const filtered = articles.articlesList.filter((article) => article.tag === tag);
|
||||||
console.log('👀 All Articles:', articles);
|
console.log('👀 All Articles:', articles);
|
||||||
console.log(`👀 Filtered (${tag}):`, filtered);
|
console.log(`👀 Filtered (${tag}):`, filtered);
|
||||||
|
|
||||||
setVisibleArticles(filtered);
|
setVisibleArticles(createArticlesModelObject(filtered));
|
||||||
setActiveTag(tag);
|
setActiveTag(tag);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user