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