Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/CU-34ga47h
Browse files Browse the repository at this point in the history
  • Loading branch information
toto04 committed Feb 3, 2023
2 parents b15dc92 + 4f54ff8 commit 4374be6
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 15 deletions.
6 changes: 6 additions & 0 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { SettingsContext, Settings } from "contexts/settings"
import { useLoadTokens } from "utils/loadTokens"
import { HttpClient } from "api/HttpClient"
import { usePalette } from "utils/colors"
import { StatusBar } from "react-native"

const client = HttpClient.getInstance()

Expand Down Expand Up @@ -141,6 +142,11 @@ export default function App() {
},
}}
>
<StatusBar
barStyle={"light-content"}
translucent={true}
backgroundColor={"transparent"}
/>
<OutsideClickProvider>
<SettingsContext.Provider
value={{ settings: settings, setSettings: setSettings }}
Expand Down
12 changes: 0 additions & 12 deletions src/api/articles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,4 @@ export const articles = {
)
return response.data.articles[0]
},

/**
* Retrieves Tags (news categories) from PoliNetwork server.
*/
async getTags(options?: RequestOptions) {
const response = await client.poliNetworkInstance.get<Tags>(
"/v1/tags",

options
)
return response.data.tags
},
}
4 changes: 3 additions & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { articles } from "./articles"
import { auth } from "./auth"
import { tags } from "./tags"
import { timetable } from "./timetable"
import { user } from "./user"
export { RetryType, AuthType, RequestOptions } from "./HttpClient"
Expand All @@ -9,7 +10,7 @@ export { RetryType, AuthType, RequestOptions } from "./HttpClient"
* To make a request:
*
* ```ts
* api.tags.get({retryType : RetryType.RETRY_N_TIMES, maxRetries : 5})
* api.tags.getTags({retryType : RetryType.RETRY_N_TIMES, maxRetries : 5})
* .then(response => {
* const tags: Tag[] = response
* //do something
Expand All @@ -23,6 +24,7 @@ export { RetryType, AuthType, RequestOptions } from "./HttpClient"
export const api = {
articles,
auth,
tags,
timetable,
user,
}
28 changes: 28 additions & 0 deletions src/api/tags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { HttpClient, RequestOptions } from "./HttpClient"

export interface Tags {
tags: Tag[]
}

export interface Tag {
name: string
image: string
}

const client = HttpClient.getInstance()
/**
* Collection of endpoints related to Tags.
*/
export const tags = {
/**
* Retrieves Tags (news categories) from PoliNetwork server.
*/
async getTags(options?: RequestOptions) {
const response = await client.poliNetworkInstance.get<Tags>(
"/v1/tags",

options
)
return response.data.tags
},
}
2 changes: 1 addition & 1 deletion src/components/Home/MainMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const defaultIcons: ButtonInterface[] = [
{ id: 2, title: "PoliAssociazioni", icon: association },
{ id: 3, title: "Aule Libere", icon: free_classrooms },
{ id: 4, title: "Materiali", icon: materials },
{ id: 5, title: "Gruppi WA", icon: groups },
{ id: 5, title: "Gruppi", icon: groups },
{ id: 6, title: "Valutazioni", icon: marks },
{ id: 7, title: "Libretto", icon: grading_book },
{ id: 8, title: "Test e Prove", icon: tests },
Expand Down
2 changes: 1 addition & 1 deletion src/components/Home/News/NewsManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const NewsManager = () => {
useEffect(() => {
// Load tags (news categories) and their last article (one for each tag)
const fetchData = async () => {
const responseTags = await api.articles.getTags()
const responseTags = await api.tags.getTags()
const responseArticles = await getLastArticles(responseTags)
setTags(responseTags)
setLastArticles(responseArticles)
Expand Down

0 comments on commit 4374be6

Please sign in to comment.