diff --git a/backend/app/Http/Resources/ArticleResource.php b/backend/app/Http/Resources/ArticleResource.php index 653eb41..506cf14 100644 --- a/backend/app/Http/Resources/ArticleResource.php +++ b/backend/app/Http/Resources/ArticleResource.php @@ -5,13 +5,11 @@ use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; +/** + * @property int $id + */ class ArticleResource extends JsonResource { - /** - * Transform the resource into an array. - * - * @return array - */ public function toArray(Request $request): array { return [ @@ -27,10 +25,11 @@ public function toArray(Request $request): array 'approved_by' => $this->approved_by, 'fetched_at' => $this->fetched_at?->toISOString(), 'validated_at' => $this->validated_at?->toISOString(), + 'is_published' => $this->relationLoaded('articlePublication') && $this->articlePublication !== null, 'created_at' => $this->created_at->toISOString(), 'updated_at' => $this->updated_at->toISOString(), 'feed' => new FeedResource($this->whenLoaded('feed')), 'article_publication' => new ArticlePublicationResource($this->whenLoaded('articlePublication')), ]; } -} \ No newline at end of file +} diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index 41329e8..d6f3ce4 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -41,6 +41,7 @@ export interface Article { published_at: string | null; author: string | null; approval_status: 'pending' | 'approved' | 'rejected'; + is_published: boolean; created_at: string; updated_at: string; feed?: Feed; diff --git a/frontend/src/pages/Articles.tsx b/frontend/src/pages/Articles.tsx index 2320049..ce1ba92 100644 --- a/frontend/src/pages/Articles.tsx +++ b/frontend/src/pages/Articles.tsx @@ -57,8 +57,19 @@ const Articles: React.FC = () => { refreshMutation.mutate(); }; - const getStatusBadge = (status: string) => { - switch (status) { + const getStatusBadge = (article: Article) => { + // Show "Published" status if the article has been published + if (article.is_published) { + return ( + + + Published + + ); + } + + // Otherwise show the approval status + switch (article.approval_status) { case 'approved': return ( @@ -162,7 +173,7 @@ const Articles: React.FC = () => {
- {getStatusBadge(article.approval_status)} + {getStatusBadge(article)} {article.url && (