Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/issue 1447 #1388

Merged
merged 3 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/app/api/news/news.api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Agent from '@api/agent.api';
import { API_ROUTES } from '@constants/api-routes.constants';
import News, { NewsWithUrl } from '@models/news/news.model';
import News, { NewsWithUrl, NewsCreate, NewsUpdate } from '@models/news/news.model';

const NewsApi = {
getById: (id: number) => Agent.get<News>(`${API_ROUTES.NEWS.GET}/${id}`),
Expand All @@ -21,11 +21,11 @@ const NewsApi = {
)),
),

create: (news: News) => Agent.post<News>(`${API_ROUTES.NEWS.CREATE}`, news),
create: (news: NewsCreate) => Agent.post<News>(`${API_ROUTES.NEWS.CREATE}`, news),

delete: (id: number) => Agent.delete(`${API_ROUTES.NEWS.DELETE}/${id}`),

update: (news: News) => Agent.put<News>(`${API_ROUTES.NEWS.UPDATE}`, news),
update: (news: NewsUpdate) => Agent.put<News>(`${API_ROUTES.NEWS.UPDATE}`, news),
};

export default NewsApi;
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ const NewsModal: React.FC<{
if (newsItem) {
news.id = newsItem.id;
news.imageId = imageId.current as number;
news.image = image.current;

await newsStore.updateNews(news);
} else {
Expand Down
12 changes: 9 additions & 3 deletions src/models/news/news.model.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import Image from '@models/media/image.model';
import dayjs from 'dayjs';

export default interface News {
id: number;
export interface NewsCreate {
title: string;
text: string;
url: string;
imageId: number;
image?: Image;
creationDate: dayjs.Dayjs;
}

export interface NewsUpdate extends NewsCreate {
id: number;
}

export default interface News extends NewsUpdate {
image?: Image;
}

export interface RandomNews {
title: string;
randomNewsUrl: string;
Expand Down