Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with the admin dashboard #58

Open
KyleMacklane opened this issue Oct 2, 2024 · 1 comment
Open

Problem with the admin dashboard #58

KyleMacklane opened this issue Oct 2, 2024 · 1 comment

Comments

@KyleMacklane
Copy link

The admin dashboard was working just fine but recently it started misbehaving like the new appointments dont show up however much you try making them, even when you try to schedule or cancel an appointment, nothing happens
Anyone facing the same error?
Screenshot 2024-10-02 182319

@KyleMacklane
Copy link
Author

Here again, i think the problem is with the updated node-appwrite version, i downgraded the version and everything worked :)
another thing is to make necessary changes to make the version work, here's the detailed work flow of the code
`"use server";

import { ID, InputFile, Query } from "node-appwrite";

import {
BUCKET_ID,
DATABASE_ID,
ENDPOINT,
PATIENT_COLLECTION_ID,
PROJECT_ID,
databases,
storage,
users,
} from "../appwrite.config";
import { parseStringify } from "../utils";

// CREATE APPWRITE USER
export const createUser = async (user: CreateUserParams) => {
try {
// Create new user -> https://appwrite.io/docs/references/1.5.x/server-nodejs/users#create
const newuser = await users.create(
ID.unique(),
user.email,
user.phone,
undefined,
user.name
);

return parseStringify(newuser);

} catch (error: any) {
// Check existing user
if (error && error?.code === 409) {
const existingUser = await users.list([
Query.equal("email", [user.email]),
]);

  return existingUser.users[0];
}
console.error("An error occurred while creating a new user:", error);

}
};

// GET USER
export const getUser = async (userId: string) => {
try {
const user = await users.get(userId);

return parseStringify(user);

} catch (error) {
console.error(
"An error occurred while retrieving the user details:",
error
);
}
};

// REGISTER PATIENT
export const registerPatient = async ({
identificationDocument,
...patient
}: RegisterUserParams) => {
try {
// Upload file -> // https://appwrite.io/docs/references/cloud/client-web/storage#createFile
let file;
if (identificationDocument) {
const inputFile =
identificationDocument &&
InputFile.fromBlob(
identificationDocument?.get("blobFile") as Blob,
identificationDocument?.get("fileName") as string
);

  file = await storage.createFile(BUCKET_ID!, ID.unique(), inputFile);
}

// Create new patient document -> https://appwrite.io/docs/references/cloud/server-nodejs/databases#createDocument
const newPatient = await databases.createDocument(
  DATABASE_ID!,
  PATIENT_COLLECTION_ID!,
  ID.unique(),
  {
    identificationDocumentId: file?.$id ? file.$id : null,
    identificationDocumentUrl: file?.$id
      ? `${ENDPOINT}/storage/buckets/${BUCKET_ID}/files/${file.$id}/view??project=${PROJECT_ID}`
      : null,
    ...patient,
  }
);

return parseStringify(newPatient);

} catch (error) {
console.error("An error occurred while creating a new patient:", error);
}
};

// GET PATIENT
export const getPatient = async (userId: string) => {
try {
const patients = await databases.listDocuments(
DATABASE_ID!,
PATIENT_COLLECTION_ID!,
[Query.equal("userId", [userId])]
);

return parseStringify(patients.documents[0]);

} catch (error) {
console.error(
"An error occurred while retrieving the patient details:",
error
);
}
};
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant