Feature/export draft activities as ics (#830)
* Export draft activities as ICS * Update changelog
This commit is contained in:
@@ -12,17 +12,28 @@ export function decodeDataSource(encodedDataSource: string) {
|
||||
return Buffer.from(encodedDataSource, 'hex').toString();
|
||||
}
|
||||
|
||||
export function downloadAsFile(
|
||||
aContent: unknown,
|
||||
aFileName: string,
|
||||
aContentType: string
|
||||
) {
|
||||
export function downloadAsFile({
|
||||
content,
|
||||
contentType = 'text/plain',
|
||||
fileName,
|
||||
format
|
||||
}: {
|
||||
content: unknown;
|
||||
contentType?: string;
|
||||
fileName: string;
|
||||
format: 'json' | 'string';
|
||||
}) {
|
||||
const a = document.createElement('a');
|
||||
const file = new Blob([JSON.stringify(aContent, undefined, ' ')], {
|
||||
type: aContentType
|
||||
|
||||
if (format === 'json') {
|
||||
content = JSON.stringify(content, undefined, ' ');
|
||||
}
|
||||
|
||||
const file = new Blob([<string>content], {
|
||||
type: contentType
|
||||
});
|
||||
a.href = URL.createObjectURL(file);
|
||||
a.download = aFileName;
|
||||
a.download = fileName;
|
||||
a.click();
|
||||
}
|
||||
|
||||
|
@@ -5,5 +5,14 @@ export interface Export {
|
||||
date: string;
|
||||
version: string;
|
||||
};
|
||||
activities: Partial<Order>[];
|
||||
activities: (Omit<
|
||||
Order,
|
||||
| 'accountUserId'
|
||||
| 'createdAt'
|
||||
| 'date'
|
||||
| 'isDraft'
|
||||
| 'symbolProfileId'
|
||||
| 'updatedAt'
|
||||
| 'userId'
|
||||
> & { date: string; symbol: string })[];
|
||||
}
|
||||
|
Reference in New Issue
Block a user