Skip to content

Commit

Permalink
feat: 🎸 Added .author and .imageAltText on NewsItem (kolplattformen#42)
Browse files Browse the repository at this point in the history
* feat: 🎸 Added .author and .imageAltText on NewsItem

* feat: 🎸 getNewsDetail returns single news article
  • Loading branch information
JohanObrink authored Feb 8, 2021
1 parent f076e11 commit 6e84a63
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ export class Api extends EventEmitter {
return parse.news(data)
}

async getNewsDetails(child: Child, item: NewsItem): Promise<any> {
const url = routes.newsDetails(child.id, item.id)
const response = await this.fetch(`news_${item.id}`, url, this.session)
const data = await response.json()
return data
}

async getMenu(child: Child): Promise<MenuItem[]> {
if (this.isFake) return fake.menu(child)

Expand Down
4 changes: 4 additions & 0 deletions lib/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export const news = (childId: string) => (
`https://etjanst.stockholm.se/vardnadshavare/inloggad2/News/GetNewsOverview?childId=${childId}`
)

export const newsDetails = (childId: string, newsId: string) => (
`https://etjanst.stockholm.se/vardnadshavare/inloggad2/News/GetNewsArticle?newsItemId=${newsId}&childId=${childId}`
)

export const image = (url: string) => (
`https://etjanst.stockholm.se/vardnadshavare/inloggad2/NewsBanner?url=${url}`
)
Expand Down
2 changes: 1 addition & 1 deletion lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export interface NewsItem {
modified?: string
imageUrl?: string
fullImageUrl?: string
imageAltText: string
imageAltText?: string
}

/**
Expand Down

0 comments on commit 6e84a63

Please sign in to comment.