up to seed

This commit is contained in:
dimitar committed 2025-01-18 21:16:06 +01:00
1 parent fe95ee5887
commit 91e5838b00
4 files changed
+37 -4

No files matched your search

+34 -2
View File
@@ -1,11 +1,18 @@
import {Account, Avatars, Client, OAuthProvider} from "react-native-appwrite";
import {Account, Avatars, Client, Databases, OAuthProvider, Query} from "react-native-appwrite";
import * as Linking from "expo-linking"
import {openAuthSessionAsync} from "expo-web-browser";
import {attribute} from "postcss-selector-parser";
import limit from "ajv-formats/src/limit";
export const config = {
platform: 'com.placebomk.mobilemk',
endpoint: process.env.EXPO_PUBLIC_APPWRITE_ENDPOINT,
projectId: process.env.EXPO_PUBLIC_APPWRITE_PROJECT_ID,
databaseId: process.env.EXPO_PUBLIC_APPWRITE_DATABASE_ID,
oglasuvacId: process.env.EXPO_PUBLIC_APPWRITE_OGLASUVAC_COLLECTION_ID,
galleryId: process.env.EXPO_PUBLIC_APPWRITE_GALERIES_COLLECTION_ID,
reviewId: process.env.EXPO_PUBLIC_APPWRITE_REVIEWS_COLLECTION_ID,
vehicleId: process.env.EXPO_PUBLIC_APPWRITE_VEHICLE_COLLECTION_ID,
}
export const client = new Client();
@@ -17,7 +24,7 @@ client
export const avatar = new Avatars(client);
export const account = new Account(client);
export const databases = new Databases(client);
export async function login (){
// Your code here to authenticate the user and return their JWT token.
@@ -79,4 +86,29 @@ export async function logOut(): Promise<boolean> {
console.error("Failed to log out user:", error);
return false;
}
}
export async function getData() {
try {
const result =await databases.listDocuments(
config.databaseId!,
config.vehicleId!,
[Query.orderAsc(`$createdAt`), Query.limit(5)],
)
console.log(result.documents)
return result.documents;
}
catch (error) {
console.error("Failed to fetch data:", error);
return [];
}
}
export async function getVehicles({filter, query, limit}: {
filter?: string;
query?: string;
limit?: number;
}){
}