feat(pets): add profile and medical records
This commit is contained in:
@@ -196,6 +196,33 @@ export async function deleteAppointmentForScope(scope: Scope, input: { id: strin
|
||||
await db.delete(petAppointments).where(eq(petAppointments.id, id));
|
||||
}
|
||||
|
||||
export async function createAppointment(input: z.input<typeof appointmentInput>) {
|
||||
const { household, user } = await getCurrentSession();
|
||||
const row = await createAppointmentForScope(
|
||||
{ householdId: household.id, userId: user.id },
|
||||
input,
|
||||
);
|
||||
revalidatePet(row.petId);
|
||||
return row;
|
||||
}
|
||||
export async function updateAppointment(
|
||||
input: { id: string } & z.input<typeof appointmentUpdateInput>,
|
||||
) {
|
||||
const { household, user } = await getCurrentSession();
|
||||
const row = await updateAppointmentForScope(
|
||||
{ householdId: household.id, userId: user.id },
|
||||
input,
|
||||
);
|
||||
revalidatePet(row.petId);
|
||||
return row;
|
||||
}
|
||||
export async function deleteAppointment(input: { id: string }) {
|
||||
const { household, user } = await getCurrentSession();
|
||||
const row = await requireAppointment({ householdId: household.id, userId: user.id }, input.id);
|
||||
await deleteAppointmentForScope({ householdId: household.id, userId: user.id }, input);
|
||||
revalidatePet(row.petId);
|
||||
}
|
||||
|
||||
export async function createVaccinationForScope(
|
||||
scope: Scope,
|
||||
input: z.input<typeof vaccinationInput>,
|
||||
@@ -258,6 +285,22 @@ export async function deleteVaccinationForScope(scope: Scope, input: { id: strin
|
||||
await db.delete(petVaccinations).where(eq(petVaccinations.id, id));
|
||||
}
|
||||
|
||||
export async function createVaccination(input: z.input<typeof vaccinationInput>) {
|
||||
const { household, user } = await getCurrentSession();
|
||||
const row = await createVaccinationForScope(
|
||||
{ householdId: household.id, userId: user.id },
|
||||
input,
|
||||
);
|
||||
revalidatePet(row.petId);
|
||||
return row;
|
||||
}
|
||||
export async function deleteVaccination(input: { id: string }) {
|
||||
const { household, user } = await getCurrentSession();
|
||||
const row = await requireVaccination({ householdId: household.id, userId: user.id }, input.id);
|
||||
await deleteVaccinationForScope({ householdId: household.id, userId: user.id }, input);
|
||||
revalidatePet(row.petId);
|
||||
}
|
||||
|
||||
export async function createPrescriptionForScope(
|
||||
scope: Scope,
|
||||
input: z.input<typeof prescriptionInput>,
|
||||
@@ -320,3 +363,19 @@ export async function deletePrescriptionForScope(scope: Scope, input: { id: stri
|
||||
await cancelReminder("pets.prescription", id);
|
||||
await db.delete(petPrescriptions).where(eq(petPrescriptions.id, id));
|
||||
}
|
||||
|
||||
export async function createPrescription(input: z.input<typeof prescriptionInput>) {
|
||||
const { household, user } = await getCurrentSession();
|
||||
const row = await createPrescriptionForScope(
|
||||
{ householdId: household.id, userId: user.id },
|
||||
input,
|
||||
);
|
||||
revalidatePet(row.petId);
|
||||
return row;
|
||||
}
|
||||
export async function deletePrescription(input: { id: string }) {
|
||||
const { household, user } = await getCurrentSession();
|
||||
const row = await requirePrescription({ householdId: household.id, userId: user.id }, input.id);
|
||||
await deletePrescriptionForScope({ householdId: household.id, userId: user.id }, input);
|
||||
revalidatePet(row.petId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user