fix: update error handling in Contact component and disable submit button during submission
This commit is contained in:
@@ -13,11 +13,6 @@ jobs:
|
|||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '22'
|
|
||||||
|
|
||||||
- name: Create Backend .env file
|
- name: Create Backend .env file
|
||||||
run: |
|
run: |
|
||||||
echo "Creating backend .env file..."
|
echo "Creating backend .env file..."
|
||||||
@@ -54,6 +49,10 @@ jobs:
|
|||||||
echo "Building frontend application..."
|
echo "Building frontend application..."
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
|
- name: Sync Files to Production Directory
|
||||||
|
run: |
|
||||||
|
rsync -a --delete --exclude 'frontend/.next/cache/' --exclude '.git/' ./ /var/www/website.joaoloureiro.dev.br/
|
||||||
|
|
||||||
- name: Restart Applications with PM2
|
- name: Restart Applications with PM2
|
||||||
run: |
|
run: |
|
||||||
echo "Restarting applications with PM2..."
|
echo "Restarting applications with PM2..."
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export default function Contact() {
|
|||||||
|
|
||||||
return await response.json();
|
return await response.json();
|
||||||
|
|
||||||
} catch (error: any) {
|
} catch (error: unknown) {
|
||||||
if (error instanceof TypeError) {
|
if (error instanceof TypeError) {
|
||||||
throw new Error('status_error_generic');
|
throw new Error('status_error_generic');
|
||||||
}
|
}
|
||||||
@@ -58,9 +58,12 @@ export default function Contact() {
|
|||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
return t('status_success');
|
return t('status_success');
|
||||||
},
|
},
|
||||||
error: (err: Error) => {
|
error: (err: unknown) => {
|
||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
return t(err.message as any);
|
if (err instanceof Error) {
|
||||||
|
return t(err.message as string) || t('status_error_generic');
|
||||||
|
}
|
||||||
|
return t('server_unexpected_error');
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -88,8 +91,8 @@ export default function Contact() {
|
|||||||
className="bg-[var(--color-card)] border border-[var(--color-border)] text-[var(--color-text-primary)] text-sm rounded-lg focus:ring-[var(--color-primary)] focus:border-[var(--color-primary)] block w-full p-2.5"></textarea>
|
className="bg-[var(--color-card)] border border-[var(--color-border)] text-[var(--color-text-primary)] text-sm rounded-lg focus:ring-[var(--color-primary)] focus:border-[var(--color-primary)] block w-full p-2.5"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<button type="submit" className="bg-[var(--color-primary)] hover:bg-[var(--color-primary)]/90 text-white font-bold py-3 px-8 rounded-full transition-colors">
|
<button type="submit" className="bg-[var(--color-primary)] hover:bg-[var(--color-primary)]/90 text-white font-bold py-3 px-8 rounded-full transition-colors" disabled={isSubmitting}>
|
||||||
{t('submit_button')}
|
{isSubmitting ? t('status_sending') : t('submit_button')}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user