full article instead of index for article and using article._id open select article using readByIndex

This commit is contained in:
2025-11-20 16:33:24 +05:30
parent fe33dca630
commit 2b578fd12e
6 changed files with 9 additions and 9 deletions

View File

@@ -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.readByIndex(ui.selectedArticle), article: articles.readById(ui.selectedArticle._id),
}) satisfies Partial<ArticleViewProps>, }) satisfies Partial<ArticleViewProps>,
}, },
editor: { editor: {
component: ArticleEditor, component: ArticleEditor,
extraProps: ({ ui, articles }) => ({ extraProps: ({ ui, articles }) => ({
article: ui.selectedArticle !== null ? articles.readByIndex(ui.selectedArticle) : null, article: ui.selectedArticle !== null ? articles.readById(ui.selectedArticle._id) : null,
}) satisfies Partial<ArticleEditorProps>, }) satisfies Partial<ArticleEditorProps>,
}, },

View File

@@ -16,7 +16,7 @@ export default function ArticleCardSize12({
return ( return (
<StyledCard <StyledCard
variant="outlined" variant="outlined"
onClick={() => onSelectArticle(index)} onClick={() => onSelectArticle(article)}
onFocus={() => onFocus(index)} onFocus={() => onFocus(index)}
onBlur={onBlur} onBlur={onBlur}
tabIndex={0} tabIndex={0}

View File

@@ -16,7 +16,7 @@ export default function ArticleCardSize2({
return ( return (
<StyledCard <StyledCard
variant="outlined" variant="outlined"
onClick={() => onSelectArticle(index)} onClick={() => onSelectArticle(article)}
onFocus={() => onFocus(index)} onFocus={() => onFocus(index)}
onBlur={onBlur} onBlur={onBlur}
tabIndex={0} tabIndex={0}

View File

@@ -16,7 +16,7 @@ export default function ArticleCardSize4({
return ( return (
<StyledCard <StyledCard
variant="outlined" variant="outlined"
onClick={() => onSelectArticle(index)} onClick={() => onSelectArticle(article)}
onFocus={() => onFocus(index)} onFocus={() => onFocus(index)}
onBlur={onBlur} onBlur={onBlur}
tabIndex={0} tabIndex={0}

View File

@@ -16,7 +16,7 @@ export default function ArticleCardSize6({
return ( return (
<StyledCard <StyledCard
variant="outlined" variant="outlined"
onClick={() => onSelectArticle(index)} onClick={() => onSelectArticle(article)}
onFocus={() => onFocus(index)} onFocus={() => onFocus(index)}
onBlur={onBlur} onBlur={onBlur}
tabIndex={0} tabIndex={0}

View File

@@ -16,7 +16,7 @@ export interface LoginProps {
export interface MainContentProps { export interface MainContentProps {
articles: ArticlesModel; articles: ArticlesModel;
onSelectArticle: (index: number) => void; onSelectArticle: (index: ArticleModel) => void;
} }
export interface ProfileProps { export interface ProfileProps {
@@ -46,14 +46,14 @@ export interface ArticleCardProps {
article: ArticleModel; article: ArticleModel;
index: number; index: number;
focusedCardIndex: number | null; focusedCardIndex: number | null;
onSelectArticle: (index: number) => void; onSelectArticle: (index: ArticleModel) => void;
onFocus: (index: number) => void; onFocus: (index: number) => void;
onBlur: () => void; onBlur: () => void;
} }
export interface ArticleGridProps { export interface ArticleGridProps {
articles: ArticlesModel; articles: ArticlesModel;
onSelectArticle: (index: number) => void; onSelectArticle: (index: ArticleModel) => void;
xs?: number; // default 12 for mobile full-width xs?: number; // default 12 for mobile full-width
md12?: number, // default 12 (full-width) md12?: number, // default 12 (full-width)
md6?: number; // default 6 (half-width) md6?: number; // default 6 (half-width)