2023-09-14 09:01:24 -05:00
|
|
|
import { BaseCRUDAPIReadOnly } from "~/lib/api/base/base-clients";
|
|
|
|
import { RecipeCategory, RecipeTag, RecipeTool } from "~/lib/api/types/recipe";
|
|
|
|
import { ApiRequestInstance } from "~/lib/api/types/non-generated";
|
|
|
|
|
|
|
|
const prefix = "/api";
|
2024-08-22 10:14:32 -05:00
|
|
|
const exploreGroupSlug = (groupSlug: string | number) => `${prefix}/explore/groups/${groupSlug}`
|
2023-09-14 09:01:24 -05:00
|
|
|
|
|
|
|
const routes = {
|
2024-08-22 10:14:32 -05:00
|
|
|
categoriesGroupSlug: (groupSlug: string | number) => `${exploreGroupSlug(groupSlug)}/organizers/categories`,
|
|
|
|
categoriesGroupSlugCategoryId: (groupSlug: string | number, categoryId: string | number) => `${exploreGroupSlug(groupSlug)}/organizers/categories/${categoryId}`,
|
|
|
|
tagsGroupSlug: (groupSlug: string | number) => `${exploreGroupSlug(groupSlug)}/organizers/tags`,
|
|
|
|
tagsGroupSlugTagId: (groupSlug: string | number, tagId: string | number) => `${exploreGroupSlug(groupSlug)}/organizers/tags/${tagId}`,
|
|
|
|
toolsGroupSlug: (groupSlug: string | number) => `${exploreGroupSlug(groupSlug)}/organizers/tools`,
|
|
|
|
toolsGroupSlugToolId: (groupSlug: string | number, toolId: string | number) => `${exploreGroupSlug(groupSlug)}/organizers/tools`,
|
2023-09-14 09:01:24 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
export class PublicCategoriesApi extends BaseCRUDAPIReadOnly<RecipeCategory> {
|
2025-06-20 00:09:12 +07:00
|
|
|
constructor(requests: ApiRequestInstance, groupSlug: string) {
|
|
|
|
super(
|
|
|
|
requests,
|
|
|
|
routes.categoriesGroupSlug(groupSlug),
|
|
|
|
(itemId: string | number) => routes.categoriesGroupSlugCategoryId(groupSlug, itemId)
|
|
|
|
);
|
2023-09-14 09:01:24 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class PublicTagsApi extends BaseCRUDAPIReadOnly<RecipeTag> {
|
2025-06-20 00:09:12 +07:00
|
|
|
constructor(requests: ApiRequestInstance, groupSlug: string) {
|
|
|
|
super(
|
|
|
|
requests,
|
|
|
|
routes.tagsGroupSlug(groupSlug),
|
|
|
|
(itemId: string | number) => routes.tagsGroupSlugTagId(groupSlug, itemId)
|
|
|
|
);
|
2023-09-14 09:01:24 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class PublicToolsApi extends BaseCRUDAPIReadOnly<RecipeTool> {
|
2025-06-20 00:09:12 +07:00
|
|
|
constructor(requests: ApiRequestInstance, groupSlug: string) {
|
|
|
|
super(
|
|
|
|
requests,
|
|
|
|
routes.toolsGroupSlug(groupSlug),
|
|
|
|
(itemId: string | number) => routes.toolsGroupSlugToolId(groupSlug, itemId)
|
|
|
|
);
|
2023-09-14 09:01:24 -05:00
|
|
|
}
|
|
|
|
}
|