Skip to content

Commit

Permalink
added query to data endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
ZibanPirate committed Oct 23, 2021
1 parent 8eccc6d commit 820ea9b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions common/src/types/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,29 @@ import {
GetTeamResponseDto,
GetUserResponseDto,
} from "../api/responses";
import { Language } from "../config/languages";

export interface Endpoints {
"data:articles/list.c.json": {
response: Article[]; // TODO-ZM: should be: Pick<Article, "title" | "slug">[] instead
query: [["language", Language["code"]]];
};
"data:articles/:slug.json": {
response: Article;
params: { slug: string };
query: [["language", Language["code"]]];
};
"data:articles/top-articles.c.json": {
response: Article[]; // TODO-ZM: should be: Pick<Article, "title" | "slug">[] instead
};
"data:documentation/list.c.json": {
response: Pick<Document, "title" | "slug">[];
query: [["language", Language["code"]]];
};
"data:documentation/:slug.json": {
response: Document;
params: { slug: string };
query: [["language", Language["code"]]];
};
"data:projects/list.c.json": {
response: Pick<Project, "title" | "description" | "image" | "githubURI">[];
Expand Down
7 changes: 5 additions & 2 deletions mobile/src/redux/actions/articles-screen/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const fetchArticles = (): ThunkResult<ArticlesScreenState> => async (disp
payload: { refreshing: true },
});
try {
const articles = await fetchV2("data:articles/list.c.json", {});
const articles = await fetchV2("data:articles/list.c.json", { query: [["language", "en"]] });
dispatch({
type: "UPDATE_ARTICLES_SCREEN",
payload: {
Expand All @@ -38,7 +38,10 @@ export const fetchArticle =
});
try {
const { articles } = getState().articlesScreen;
const article = await fetchV2(`data:articles/:slug.json`, { params: { slug } });
const article = await fetchV2(`data:articles/:slug.json`, {
params: { slug },
query: [["language", "en"]],
});
dispatch({
type: "UPDATE_ARTICLES_SCREEN",
payload: {
Expand Down
9 changes: 7 additions & 2 deletions mobile/src/redux/actions/learn-screen/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export const fetchDocuments = (): ThunkResult<LearnScreenState> => async (dispat
payload: { refreshing: true },
});
try {
const documents = await fetchV2("data:documentation/list.c.json", {});
const documents = await fetchV2("data:documentation/list.c.json", {
query: [["language", "en"]],
});
dispatch({
type: "UPDATE_LEARN_SCREEN",
payload: {
Expand All @@ -39,7 +41,10 @@ export const fetchDocument =
});
try {
const { documents } = getState().learnScreen;
const document = await fetchV2("data:documentation/:slug.json", { params: { slug } });
const document = await fetchV2("data:documentation/:slug.json", {
params: { slug },
query: [["language", "en"]],
});
dispatch({
type: "UPDATE_LEARN_SCREEN",
payload: {
Expand Down

0 comments on commit 820ea9b

Please sign in to comment.