Fix EOI generation and interest update authentication

- Make Address field optional in EOI document generation with "Not Provided" default
- Accept both x-tag headers ("094ut234" and "pjnvü1230") for interest updates
- Update required fields validation to exclude Address
- Improve error messages to guide users on updating missing fields
This commit is contained in:
Matt 2025-06-09 22:56:10 +02:00
parent 5f10e9fb54
commit 77b6aa2752
3 changed files with 16 additions and 6 deletions

View File

@ -17,10 +17,18 @@
- Prevented unnecessary email fetches when no session exists
### 3. EOI Generation Issues
- **Problem**: EOI generation may fail due to missing Documenso configuration
- **Problem**: EOI generation was failing due to missing Address field and configuration issues
- **Solution**:
- Made Address field optional with default value "Not Provided"
- Added environment variable validation for `NUXT_DOCUMENSO_API_KEY` and `NUXT_DOCUMENSO_BASE_URL`
- Improved error messages to indicate when configuration is missing
- Improved error messages to indicate when configuration is missing or fields need to be filled
- Required fields are now: Full Name, Email Address, Yacht Name, Length, Width, Depth
### 4. Interest Save Failures
- **Problem**: Interest updates were failing with authentication errors
- **Solution**:
- Updated `update-interest.ts` API to accept both x-tag headers ("094ut234" and "pjnvü1230")
- Now both authenticated and unauthenticated users can save interest updates
## Required Environment Variables

View File

@ -39,18 +39,20 @@ export default defineEventHandler(async (event) => {
const requiredFields = [
{ field: 'Full Name', value: interest['Full Name'] },
{ field: 'Email Address', value: interest['Email Address'] },
{ field: 'Address', value: interest['Address'] },
{ field: 'Yacht Name', value: interest['Yacht Name'] },
{ field: 'Length', value: interest['Length'] },
{ field: 'Width', value: interest['Width'] },
{ field: 'Depth', value: interest['Depth'] }
];
// Address is optional - use a default if not provided
const address = interest['Address'] || 'Not Provided';
const missingFields = requiredFields.filter(f => !f.value).map(f => f.field);
if (missingFields.length > 0) {
throw createError({
statusCode: 400,
statusMessage: `Missing required fields: ${missingFields.join(', ')}`
statusMessage: `Please fill in the following required fields before generating EOI: ${missingFields.join(', ')}. You can update these fields in the interest details form.`
});
}
@ -127,7 +129,7 @@ export default defineEventHandler(async (event) => {
"Email": interest['Email Address'],
"Width": interest['Width'],
"Length": interest['Length'],
"Address": interest['Address'],
"Address": address,
"Lease_10": false,
"Purchase": true,
"Yacht Name": interest['Yacht Name'],

View File

@ -1,7 +1,7 @@
export default defineEventHandler(async (event) => {
const xTagHeader = getRequestHeader(event, "x-tag");
if (!xTagHeader || xTagHeader !== "094ut234") {
if (!xTagHeader || (xTagHeader !== "094ut234" && xTagHeader !== "pjnvü1230")) {
throw createError({ statusCode: 401, statusMessage: "unauthenticated" });
}