Skip to content

Commit 08b029c

Browse files
authored
Minor graphical fixes (#194)
Implement confirmation dialogs for accepting and canceling quotes in the QuoteListComponent. Update quote action button texts to include delivery date requirement. Enhance the QuoteDetailsModalComponent with improved file size validation and action button visibility logic. Refactor code for better readability and maintainability.
1 parent 476f897 commit 08b029c

3 files changed

Lines changed: 253 additions & 147 deletions

File tree

src/app/features/quotes/pages/quote-list/quote-list.component.ts

Lines changed: 92 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,28 @@ import { environment } from 'src/environments/environment';
217217
(cancel)="showDeleteConfirm = false"
218218
></app-confirm-dialog>
219219
220+
<!-- Accept Confirmation Dialog -->
221+
<app-confirm-dialog
222+
[isOpen]="showAcceptConfirm"
223+
title="Accept Quote"
224+
[message]="acceptConfirmMessage"
225+
confirmText="Accept"
226+
confirmButtonClass="px-4 py-2 text-sm font-medium text-white bg-green-600 border border-transparent rounded-md hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500"
227+
(confirm)="acceptConfirmCallback && acceptConfirmCallback()"
228+
(cancel)="showAcceptConfirm = false"
229+
></app-confirm-dialog>
230+
231+
<!-- Cancel Confirmation Dialog -->
232+
<app-confirm-dialog
233+
[isOpen]="showCancelConfirm"
234+
title="Cancel Quote"
235+
[message]="cancelConfirmMessage"
236+
confirmText="Cancel Quote"
237+
confirmButtonClass="px-4 py-2 text-sm font-medium text-white bg-red-600 border border-transparent rounded-md hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500"
238+
(confirm)="cancelConfirmCallback && cancelConfirmCallback()"
239+
(cancel)="showCancelConfirm = false"
240+
></app-confirm-dialog>
241+
220242
<!-- State Update Modal -->
221243
<div *ngIf="showStateUpdate" class="fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full z-50">
222244
<div class="relative top-20 mx-auto p-5 border w-96 shadow-lg rounded-md bg-white">
@@ -374,6 +396,14 @@ export class QuoteListComponent implements OnInit {
374396
deleteConfirmMessage = '';
375397
quoteToDelete: Quote | null = null;
376398

399+
// Confirmation dialogs
400+
showAcceptConfirm = false;
401+
acceptConfirmMessage = '';
402+
acceptConfirmCallback: (() => void) | null = null;
403+
showCancelConfirm = false;
404+
cancelConfirmMessage = '';
405+
cancelConfirmCallback: (() => void) | null = null;
406+
377407
// Data enrichment maps
378408
organizationNames: Map<string, string> = new Map();
379409
productNames: Map<string, string> = new Map();
@@ -518,11 +548,11 @@ export class QuoteListComponent implements OnInit {
518548
return this.productService.getProductById(id).then(
519549
(product: any) => {
520550
console.log('Product fetched:', id, product?.name);
521-
return { id, name: product?.name || id };
551+
return { id, name: product?.name || 'Product Name Unavailable' };
522552
},
523553
(error) => {
524554
console.error('Product fetch error:', id, error);
525-
return { id, name: id }; // Fallback to ID on error
555+
return { id, name: 'Product Name Unavailable' }; // Fallback to placeholder on error
526556
}
527557
);
528558
});
@@ -727,56 +757,54 @@ export class QuoteListComponent implements OnInit {
727757

728758
acceptQuote(quote: Quote) {
729759
const shortId = this.extractShortId(quote.id);
730-
const confirmAccept = confirm(`Are you sure you want to accept this request?`);
731-
732-
if (!confirmAccept) {
733-
return;
734-
}
760+
this.acceptConfirmMessage = 'Are you sure you want to accept this request?';
761+
this.acceptConfirmCallback = () => {
762+
console.log('Accepting quote request:', quote.id);
735763

736-
console.log('Accepting quote request:', quote.id);
737-
738-
this.quoteService.updateQuoteStatus(quote.id!, 'inProgress').subscribe({
739-
next: (updatedQuote) => {
740-
const index = this.quotes.findIndex(q => q.id === updatedQuote.id);
741-
if (index !== -1) {
742-
this.quotes[index] = updatedQuote;
743-
this.filterQuotesByStatus();
764+
this.quoteService.updateQuoteStatus(quote.id!, 'inProgress').subscribe({
765+
next: (updatedQuote) => {
766+
const index = this.quotes.findIndex(q => q.id === updatedQuote.id);
767+
if (index !== -1) {
768+
this.quotes[index] = updatedQuote;
769+
this.filterQuotesByStatus();
770+
}
771+
console.log('Quote request successfully accepted');
772+
this.notificationService.showSuccess(`Quote request ${shortId} has been accepted and is now in progress.`);
773+
},
774+
error: (error) => {
775+
console.error('Error accepting quote request:', error);
776+
this.notificationService.showError(`Error accepting quote request: ${error.message || 'Unknown error'}`);
744777
}
745-
console.log('Quote request successfully accepted');
746-
this.notificationService.showSuccess(`Quote request ${shortId} has been accepted and is now in progress.`);
747-
},
748-
error: (error) => {
749-
console.error('Error accepting quote request:', error);
750-
this.notificationService.showError(`Error accepting quote request: ${error.message || 'Unknown error'}`);
751-
}
752-
});
778+
});
779+
this.showAcceptConfirm = false;
780+
};
781+
this.showAcceptConfirm = true;
753782
}
754783

755784
acceptQuoteCustomer(quote: Quote) {
756785
const shortId = this.extractShortId(quote.id);
757-
const confirmAccept = confirm(`Are you sure you want to accept the quotation?`);
758-
759-
if (!confirmAccept) {
760-
return;
761-
}
786+
this.acceptConfirmMessage = 'Are you sure you want to accept the quotation?';
787+
this.acceptConfirmCallback = () => {
788+
console.log('Customer accepting quotation:', quote.id);
762789

763-
console.log('Customer accepting quotation:', quote.id);
764-
765-
this.quoteService.updateQuoteStatus(quote.id!, 'accepted').subscribe({
766-
next: (updatedQuote) => {
767-
const index = this.quotes.findIndex(q => q.id === updatedQuote.id);
768-
if (index !== -1) {
769-
this.quotes[index] = updatedQuote;
770-
this.filterQuotesByStatus();
790+
this.quoteService.updateQuoteStatus(quote.id!, 'accepted').subscribe({
791+
next: (updatedQuote) => {
792+
const index = this.quotes.findIndex(q => q.id === updatedQuote.id);
793+
if (index !== -1) {
794+
this.quotes[index] = updatedQuote;
795+
this.filterQuotesByStatus();
796+
}
797+
console.log('Quotation successfully accepted by customer');
798+
this.notificationService.showSuccess(`Quotation ${shortId} has been accepted successfully.`);
799+
},
800+
error: (error) => {
801+
console.error('Error accepting quotation:', error);
802+
this.notificationService.showError(`Error accepting quotation: ${error.message || 'Unknown error'}`);
771803
}
772-
console.log('Quotation successfully accepted by customer');
773-
this.notificationService.showSuccess(`Quotation ${shortId} has been accepted successfully.`);
774-
},
775-
error: (error) => {
776-
console.error('Error accepting quotation:', error);
777-
this.notificationService.showError(`Error accepting quotation: ${error.message || 'Unknown error'}`);
778-
}
779-
});
804+
});
805+
this.showAcceptConfirm = false;
806+
};
807+
this.showAcceptConfirm = true;
780808
}
781809

782810
// Date picker methods
@@ -849,29 +877,28 @@ export class QuoteListComponent implements OnInit {
849877

850878
cancelQuote(quote: Quote) {
851879
const shortId = this.extractShortId(quote.id);
852-
const confirmCancel = confirm(`Are you sure you want to cancel quote ${shortId}?\n\nThis action cannot be undone and will disable all other quote actions.`);
853-
854-
if (!confirmCancel) {
855-
return;
856-
}
880+
this.cancelConfirmMessage = `Are you sure you want to cancel quote ${shortId}? This action cannot be undone and will disable all other quote actions.`;
881+
this.cancelConfirmCallback = () => {
882+
console.log('Cancelling quote:', quote.id);
857883

858-
console.log('Cancelling quote:', quote.id);
859-
860-
this.quoteService.updateQuoteStatus(quote.id!, 'cancelled').subscribe({
861-
next: (updatedQuote) => {
862-
const index = this.quotes.findIndex(q => q.id === updatedQuote.id);
863-
if (index !== -1) {
864-
this.quotes[index] = updatedQuote;
865-
this.filterQuotesByStatus();
884+
this.quoteService.updateQuoteStatus(quote.id!, 'cancelled').subscribe({
885+
next: (updatedQuote) => {
886+
const index = this.quotes.findIndex(q => q.id === updatedQuote.id);
887+
if (index !== -1) {
888+
this.quotes[index] = updatedQuote;
889+
this.filterQuotesByStatus();
890+
}
891+
console.log('Quote successfully cancelled');
892+
this.notificationService.showSuccess(`Quote ${shortId} has been cancelled successfully.`);
893+
},
894+
error: (error) => {
895+
console.error('Error cancelling quote:', error);
896+
this.notificationService.showError(`Error cancelling quote: ${error.message || 'Unknown error'}`);
866897
}
867-
console.log('Quote successfully cancelled');
868-
this.notificationService.showSuccess(`Quote ${shortId} has been cancelled successfully.`);
869-
},
870-
error: (error) => {
871-
console.error('Error cancelling quote:', error);
872-
this.notificationService.showError(`Error cancelling quote: ${error.message || 'Unknown error'}`);
873-
}
874-
});
898+
});
899+
this.showCancelConfirm = false;
900+
};
901+
this.showCancelConfirm = true;
875902
}
876903

877904
createOffer(quote: Quote) {

src/app/models/quote.constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export const QUOTE_CHAT_MESSAGES = {
9191
* Action button helper texts displayed next to buttons in quote details modal
9292
*/
9393
export const QUOTE_ACTION_BUTTON_TEXTS = {
94-
ACCEPT_QUOTE_PROVIDER: 'Accept the request of the customer.',
94+
ACCEPT_QUOTE_PROVIDER: 'Accept the request of the customer. Set an expected delivery Date first to proceed.',
9595
ACCEPT_PROPOSAL_CUSTOMER: 'Accept the proposal that has been sent to you by the provider.',
9696
CANCEL_QUOTE_PROVIDER: 'Cancel the quote request.',
9797
REJECT_PROPOSAL_CUSTOMER: 'Reject the proposal.',

0 commit comments

Comments
 (0)