search related fix
This commit is contained in:
parent
919ff7189f
commit
65911c3692
12
.env
12
.env
|
|
@ -17,11 +17,11 @@
|
|||
# old working .env file
|
||||
|
||||
# Production Dev
|
||||
EXPO_PUBLIC_API_URL=https://api.acupedia.in/api
|
||||
EXPO_PUBLIC_STOREFRONT_URL=https://acupedia.in/store
|
||||
EXPO_PUBLIC_CONTENT_PREVIEW_ENABLED=true
|
||||
# EXPO_PUBLIC_API_URL=https://api.acupedia.in/api
|
||||
# EXPO_PUBLIC_STOREFRONT_URL=https://acupedia.in/store
|
||||
# EXPO_PUBLIC_CONTENT_PREVIEW_ENABLED=true
|
||||
|
||||
# Local Dev
|
||||
# EXPO_PUBLIC_API_URL=http://localhost:8000/api
|
||||
# EXPO_PUBLIC_STOREFRONT_URL=http://localhost:3000
|
||||
# EXPO_PUBLIC_CONTENT_PREVIEW_ENABLED=true
|
||||
EXPO_PUBLIC_API_URL=http://localhost:8000/api
|
||||
EXPO_PUBLIC_STOREFRONT_URL=http://localhost:3000
|
||||
EXPO_PUBLIC_CONTENT_PREVIEW_ENABLED=true
|
||||
|
|
@ -34,6 +34,7 @@ yarn-error.*
|
|||
.env*.local
|
||||
.idea/
|
||||
.env
|
||||
package-locked.json
|
||||
|
||||
# typescript
|
||||
*.tsbuildinfo
|
||||
|
|
|
|||
11
app.json
11
app.json
|
|
@ -26,7 +26,6 @@
|
|||
},
|
||||
"predictiveBackGestureEnabled": false,
|
||||
"package": "com.anonymous.acupedia",
|
||||
"usesCleartextTraffic": true,
|
||||
"allowBackup": false
|
||||
},
|
||||
"web": {
|
||||
|
|
@ -42,6 +41,14 @@
|
|||
"image": "./assets/images/splash-icon.png",
|
||||
"imageWidth": 76
|
||||
}
|
||||
],
|
||||
[
|
||||
"expo-build-properties",
|
||||
{
|
||||
"android": {
|
||||
"usesCleartextTraffic": true
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
"experiments": {
|
||||
|
|
@ -49,4 +56,4 @@
|
|||
"reactCompiler": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
31
package.json
31
package.json
|
|
@ -1,31 +1,32 @@
|
|||
{
|
||||
"name": "my-app",
|
||||
"name": "AcuPedia",
|
||||
"main": "expo-router/entry",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@expo-google-fonts/inter": "^0.4.2",
|
||||
"@expo/ui": "~57.0.16",
|
||||
"@expo/vector-icons": "^15.0.2",
|
||||
"@react-native-async-storage/async-storage": "2.2.0",
|
||||
"@expo/vector-icons": "^15.1.1",
|
||||
"@react-native-async-storage/async-storage": "~2.2.0",
|
||||
"@react-native-community/netinfo": "12.0.1",
|
||||
"@tanstack/react-query": "^5.101.2",
|
||||
"axios": "^1.18.1",
|
||||
"expo": "~57.0.20",
|
||||
"expo-constants": "~57.0.17",
|
||||
"expo-device": "~57.0.1",
|
||||
"expo-font": "~57.0.3",
|
||||
"expo": "~57.0.3",
|
||||
"expo-build-properties": "~57.0.22",
|
||||
"expo-constants": "~57.0.19",
|
||||
"expo-device": "~57.0.2",
|
||||
"expo-font": "~57.0.4",
|
||||
"expo-glass-effect": "~57.0.1",
|
||||
"expo-image": "~57.0.4",
|
||||
"expo-linear-gradient": "~57.0.1",
|
||||
"expo-linking": "~57.0.9",
|
||||
"expo-router": "~57.0.19",
|
||||
"expo-linear-gradient": "~57.0.2",
|
||||
"expo-linking": "~57.0.11",
|
||||
"expo-router": "~57.0.23",
|
||||
"expo-screen-capture": "~57.0.3",
|
||||
"expo-secure-store": "~57.0.2",
|
||||
"expo-splash-screen": "~57.0.8",
|
||||
"expo-secure-store": "~57.0.4",
|
||||
"expo-splash-screen": "~57.0.9",
|
||||
"expo-status-bar": "~57.0.1",
|
||||
"expo-symbols": "~57.0.2",
|
||||
"expo-system-ui": "~57.0.3",
|
||||
"expo-web-browser": "~57.0.2",
|
||||
"expo-system-ui": "~57.0.4",
|
||||
"expo-web-browser": "~57.0.3",
|
||||
"react": "19.2.3",
|
||||
"react-dom": "19.2.3",
|
||||
"react-native": "0.86.3",
|
||||
|
|
@ -35,7 +36,7 @@
|
|||
"react-native-screens": "~4.26.0",
|
||||
"react-native-size-matters": "^0.4.2",
|
||||
"react-native-toast-message": "^2.3.3",
|
||||
"react-native-web": "~0.21.0",
|
||||
"react-native-web": "~0.21.3",
|
||||
"react-native-worklets": "0.10.1",
|
||||
"zustand": "^4.5.7"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@ import type {
|
|||
SearchScope,
|
||||
} from "../types/search.types";
|
||||
|
||||
function capabilityQuery(scope?: SearchScope): string {
|
||||
function capabilityQuery(scope?: SearchScope, preview = false): string {
|
||||
const params: string[] = [];
|
||||
if (preview) params.push("preview=true");
|
||||
if (scope?.module_codes?.length) {
|
||||
params.push(`module_codes=${encodeURIComponent(scope.module_codes.join(","))}`);
|
||||
}
|
||||
|
|
@ -21,9 +22,10 @@ function capabilityQuery(scope?: SearchScope): string {
|
|||
|
||||
export async function getSearchCapabilities(
|
||||
scope?: SearchScope,
|
||||
preview = false,
|
||||
): Promise<SearchCapabilitiesResponse> {
|
||||
const response = await apiClient.get<SearchCapabilitiesResponse>(
|
||||
`/search/capabilities${capabilityQuery(scope)}`,
|
||||
`/search/capabilities${capabilityQuery(scope, preview)}`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
|
@ -34,20 +36,24 @@ function apiFilters(filters: FacetValuesRequest["active_filters"]) {
|
|||
|
||||
export async function getFacetValues(
|
||||
payload: FacetValuesRequest,
|
||||
preview = false,
|
||||
): Promise<FacetValuesResponse> {
|
||||
const response = await apiClient.post<FacetValuesResponse>(
|
||||
"/search/facet-values",
|
||||
{ ...payload, active_filters: apiFilters(payload.active_filters) },
|
||||
{ params: { preview } },
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function searchContents(
|
||||
payload: FacetedSearchRequest,
|
||||
preview = false,
|
||||
): Promise<FacetedSearchResponse> {
|
||||
const response = await apiClient.post<FacetedSearchResponse>(
|
||||
"/search/contents",
|
||||
{ ...payload, filters: apiFilters(payload.filters) },
|
||||
{ params: { preview } },
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useSettingsStore } from "@/store/settings.store";
|
||||
import { getFacetValues } from "../api/search.api";
|
||||
import type { FacetValuesRequest } from "../types/search.types";
|
||||
|
||||
|
|
@ -6,6 +7,7 @@ export function useFacetValues(
|
|||
request: FacetValuesRequest | null,
|
||||
enabled = true,
|
||||
) {
|
||||
const preview = useSettingsStore((state) => state.contentPreviewEnabled);
|
||||
return useQuery({
|
||||
queryKey: [
|
||||
"search",
|
||||
|
|
@ -17,8 +19,9 @@ export function useFacetValues(
|
|||
request?.filter_logic ?? "and",
|
||||
request?.active_filters ?? [],
|
||||
request?.limit ?? 25,
|
||||
preview,
|
||||
],
|
||||
queryFn: () => getFacetValues(request!),
|
||||
queryFn: () => getFacetValues(request!, preview),
|
||||
enabled: enabled && request !== null,
|
||||
staleTime: 30 * 1000,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { useInfiniteQuery } from "@tanstack/react-query";
|
||||
import { useSettingsStore } from "@/store/settings.store";
|
||||
import { searchContents } from "../api/search.api";
|
||||
import type { FacetedSearchRequest } from "../types/search.types";
|
||||
|
||||
|
|
@ -6,6 +7,7 @@ export function useFacetedSearch(
|
|||
request: Omit<FacetedSearchRequest, "page">,
|
||||
enabled = true,
|
||||
) {
|
||||
const preview = useSettingsStore((state) => state.contentPreviewEnabled);
|
||||
return useInfiniteQuery({
|
||||
queryKey: [
|
||||
"search",
|
||||
|
|
@ -17,8 +19,10 @@ export function useFacetedSearch(
|
|||
request.filter_logic,
|
||||
request.sort,
|
||||
request.page_size,
|
||||
preview,
|
||||
],
|
||||
queryFn: ({ pageParam }) => searchContents({ ...request, page: pageParam }),
|
||||
queryFn: ({ pageParam }) =>
|
||||
searchContents({ ...request, page: pageParam }, preview),
|
||||
initialPageParam: 1,
|
||||
enabled,
|
||||
getNextPageParam: (last) =>
|
||||
|
|
|
|||
|
|
@ -1,16 +1,19 @@
|
|||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useSettingsStore } from "@/store/settings.store";
|
||||
import { getSearchCapabilities } from "../api/search.api";
|
||||
import type { SearchScope } from "../types/search.types";
|
||||
|
||||
export function useSearchCapabilities(scope?: SearchScope) {
|
||||
const preview = useSettingsStore((state) => state.contentPreviewEnabled);
|
||||
return useQuery({
|
||||
queryKey: [
|
||||
"search",
|
||||
"capabilities",
|
||||
scope?.module_codes ?? null,
|
||||
scope?.content_kinds ?? null,
|
||||
preview,
|
||||
],
|
||||
queryFn: () => getSearchCapabilities(scope),
|
||||
queryFn: () => getSearchCapabilities(scope, preview),
|
||||
staleTime: 30 * 60 * 1000,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue