forked from fahrPool/fahrPool
feat: Telefon/E-Mail in Orte-Mutations und -Queries aufnehmen
This commit is contained in:
parent
086d7459ee
commit
67abe86edd
|
|
@ -5,6 +5,8 @@ export type Ort = {
|
||||||
id: string;
|
id: string;
|
||||||
adresse: string;
|
adresse: string;
|
||||||
ansprechpartner: string;
|
ansprechpartner: string;
|
||||||
|
telefon: string | null;
|
||||||
|
email: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Fahrzeug = {
|
export type Fahrzeug = {
|
||||||
|
|
@ -33,11 +35,14 @@ export type Auftrag = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const AUFTRAG_SELECT =
|
const AUFTRAG_SELECT =
|
||||||
"id, status, zugewiesen_an, start_zeit, start_km, end_km, uebergabe_bestaetigt_at, vorgaenger_auftrag_id, created_at, abholort:orte!auftraege_abholort_id_fkey(id, adresse, ansprechpartner), zielort:orte!auftraege_zielort_id_fkey(id, adresse, ansprechpartner), fahrzeug:fahrzeuge(id, kennzeichen, marke, modell), erstellt_von:profiles!auftraege_erstellt_von_fkey(id, name)";
|
"id, status, zugewiesen_an, start_zeit, start_km, end_km, uebergabe_bestaetigt_at, vorgaenger_auftrag_id, created_at, abholort:orte!auftraege_abholort_id_fkey(id, adresse, ansprechpartner, telefon, email), zielort:orte!auftraege_zielort_id_fkey(id, adresse, ansprechpartner, telefon, email), fahrzeug:fahrzeuge(id, kennzeichen, marke, modell), erstellt_von:profiles!auftraege_erstellt_von_fkey(id, name)";
|
||||||
|
|
||||||
export async function listOrte(): Promise<Ort[]> {
|
export async function listOrte(): Promise<Ort[]> {
|
||||||
const supabase = await createClient();
|
const supabase = await createClient();
|
||||||
const { data } = await supabase.from("orte").select("id, adresse, ansprechpartner").order("adresse");
|
const { data } = await supabase
|
||||||
|
.from("orte")
|
||||||
|
.select("id, adresse, ansprechpartner, telefon, email")
|
||||||
|
.order("adresse");
|
||||||
return data ?? [];
|
return data ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,20 @@ export type MutationResult = { success: true; id: string } | { success: false; e
|
||||||
export async function insertOrt(input: {
|
export async function insertOrt(input: {
|
||||||
adresse: string;
|
adresse: string;
|
||||||
ansprechpartner: string;
|
ansprechpartner: string;
|
||||||
|
telefon: string | null;
|
||||||
|
email: string | null;
|
||||||
createdBy: string;
|
createdBy: string;
|
||||||
}): Promise<MutationResult> {
|
}): Promise<MutationResult> {
|
||||||
const supabase = await createClient();
|
const supabase = await createClient();
|
||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from("orte")
|
.from("orte")
|
||||||
.insert({ adresse: input.adresse, ansprechpartner: input.ansprechpartner, created_by: input.createdBy })
|
.insert({
|
||||||
|
adresse: input.adresse,
|
||||||
|
ansprechpartner: input.ansprechpartner,
|
||||||
|
telefon: input.telefon,
|
||||||
|
email: input.email,
|
||||||
|
created_by: input.createdBy,
|
||||||
|
})
|
||||||
.select("id")
|
.select("id")
|
||||||
.single();
|
.single();
|
||||||
|
|
||||||
|
|
@ -24,11 +32,18 @@ export async function updateOrtZeile(input: {
|
||||||
id: string;
|
id: string;
|
||||||
adresse: string;
|
adresse: string;
|
||||||
ansprechpartner: string;
|
ansprechpartner: string;
|
||||||
|
telefon: string | null;
|
||||||
|
email: string | null;
|
||||||
}): Promise<MutationResult> {
|
}): Promise<MutationResult> {
|
||||||
const supabase = await createClient();
|
const supabase = await createClient();
|
||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from("orte")
|
.from("orte")
|
||||||
.update({ adresse: input.adresse, ansprechpartner: input.ansprechpartner })
|
.update({
|
||||||
|
adresse: input.adresse,
|
||||||
|
ansprechpartner: input.ansprechpartner,
|
||||||
|
telefon: input.telefon,
|
||||||
|
email: input.email,
|
||||||
|
})
|
||||||
.eq("id", input.id)
|
.eq("id", input.id)
|
||||||
.select("id")
|
.select("id")
|
||||||
.single();
|
.single();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue