feat: update
This commit is contained in:
@@ -36,3 +36,44 @@ export const getInterestById = async (id: string) =>
|
||||
"xc-token": getNocoDbConfiguration().token,
|
||||
},
|
||||
});
|
||||
|
||||
export const updateInterest = async (id: string, data: Partial<Interest>) => {
|
||||
// Create a clean data object that matches the InterestsRequest schema
|
||||
// Remove any properties that are not in the schema or shouldn't be sent
|
||||
const cleanData: Record<string, any> = {};
|
||||
|
||||
// Only include fields that are part of the InterestsRequest schema
|
||||
const allowedFields = [
|
||||
"Full Name", "Yacht Name", "Length", "Address", "Email Address",
|
||||
"Sales Process Level", "Phone Number", "Extra Comments", "Berth Size Desired",
|
||||
"LOI-NDA Document", "Date Added", "Width", "Depth", "Created At",
|
||||
"Request More Information", "Source", "Place of Residence",
|
||||
"Contact Method Preferred", "Request Form Sent", "Berth Number",
|
||||
"EOI Time Sent", "Lead Category", "Request More Info - To Sales",
|
||||
"EOI Send to Sales", "Time LOI Sent"
|
||||
];
|
||||
|
||||
// Filter the data to only include allowed fields
|
||||
for (const field of allowedFields) {
|
||||
if (field in data) {
|
||||
cleanData[field] = data[field];
|
||||
}
|
||||
}
|
||||
|
||||
return $fetch<Interest>(createTableUrl(Table.Interest), {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
"xc-token": getNocoDbConfiguration().token,
|
||||
},
|
||||
body: {
|
||||
Id: id, // This identifies the record to update
|
||||
...cleanData // These are the fields to update
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const triggerWebhook = async (url: string, payload: any) =>
|
||||
$fetch(url, {
|
||||
method: 'POST',
|
||||
body: payload,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user