Skip to content

Commit

Permalink
changes after feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninarchive committed Dec 18, 2023
1 parent 39e1631 commit c6d6c2c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions frontend/src/actions/downloadActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import moment from 'moment';
import {catchHandler} from './utils/fetch';
import {buildUrl} from './utils/buildUrl';
import InvoiceModel from '../components/invoice/models/InvoiceModel';
import {Attachment} from '../models';
import {Attachment, CoreInvoiceAttachments} from '../models';
import {ClientModel} from '../components/client/models/ClientModels';
import {getInvoiceFileName, getDownloadUrl, previewPdf, downloadAttachment} from './utils/download-helpers';
import {ProjectMonthOverviewModel} from '../components/project/models/ProjectMonthModel';
Expand All @@ -14,7 +14,7 @@ import {authService} from '../components/users/authService';
export function getInvoiceDownloadUrl(
fileNameTemplate: string,
invoice: InvoiceModel,
attachment: string | Attachment = 'pdf',
attachment: CoreInvoiceAttachments | Attachment = 'pdf',
downloadType?: 'preview' | 'download',
fullProjectMonth?: FullProjectMonthModel,
): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import {Icon, IconProps} from '../Icon';
import {getInvoiceDownloadUrl} from '../../../actions/index';
import t from '../../../trans';
import {InvoiceModelProps} from '../../invoice/models/InvoiceModel';
import {Attachment} from '../../../models';
import {Attachment, CoreInvoiceAttachments} from '../../../models';
import {getAwesomeFileType} from '../../invoice/models/getAwesomeFileType';
import {ConfacState} from '../../../reducers/app-state';

type InvoiceDownloadIconProps = InvoiceModelProps & {
fileType: string,
styleOption?: {}
fileType: CoreInvoiceAttachments,
style?: {}
}


export const InvoiceDownloadIcon = ({invoice, fileType, styleOption, ...props}: InvoiceDownloadIconProps) => {
export const InvoiceDownloadIcon = ({invoice, fileType, style, ...props}: InvoiceDownloadIconProps) => {
const configInvoiceFileName = useSelector((state: ConfacState) => state.config.invoiceFileName);

const defaultInvoiceFileName = invoice.client.invoiceFileName || configInvoiceFileName;
Expand All @@ -23,7 +23,7 @@ export const InvoiceDownloadIcon = ({invoice, fileType, styleOption, ...props}:
<AttachmentDownloadIcon
downloadUrl={url}
attachment={invoice.attachments.find(a => a.type === fileType)}
style={styleOption}
style={style}
{...props}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const EditInvoice = () => {
variant="link"
/>
{initInvoice._id && <DownloadInvoiceButton invoice={initInvoice} />}
{storeInvoice?._id && !storeInvoice?.isQuotation && <InvoiceDownloadIcon invoice={invoice} fileType='xml' styleOption={{color: '#0062cc', marginLeft: 20}} />}
{storeInvoice?._id && !storeInvoice?.isQuotation && <InvoiceDownloadIcon invoice={invoice} fileType='xml' style={{color: '#0062cc', marginLeft: 20}} />}
</div>
</div>
</Col>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/invoice/models/InvoiceModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default class InvoiceModel implements IAttachment {
this.orderNr = obj.orderNr || '';
this.verified = obj.verified || false;
this.discount = obj.discount;
this.attachments = obj.attachments || [{type: 'pdf'}, {type:'xml', desc:'PEPPOL xml'}];
this.attachments = obj.attachments || [{type: 'pdf', desc:'Factuur pdf'}, {type:'xml', desc:'PEPPOL xml'}];
this.isQuotation = obj.isQuotation || false;
this.lastEmail = obj.lastEmail;
this.note = obj.note || '';
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export type Attachment = {
desc?: string
}

export type CoreInvoiceAttachments = 'pdf' | 'xml';


/** Duplicated on backend */
export const TimesheetCheckAttachmentType = 'Timesheet check';
Expand Down

0 comments on commit c6d6c2c

Please sign in to comment.