Skip to content

Commit

Permalink
create utils base structure
Browse files Browse the repository at this point in the history
  • Loading branch information
suren-atoyan committed Jun 12, 2020
1 parent b80b8f9 commit 729b03b
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/utils/downloadFile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function downloadFile(path, name) {
const link = document.createElement('a');
link.href = path;
link.download = name;
link.dispatchEvent(new MouseEvent('click'));
link.remove();
}

export default downloadFile;
13 changes: 13 additions & 0 deletions src/utils/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import today from './today';
import noop from './noop';
import isMobile from './isMobile';
import resetApp from './resetApp';
import downloadFile from './downloadFile';

export {
today,
noop,
isMobile,
resetApp,
downloadFile,
};
3 changes: 3 additions & 0 deletions src/utils/isMobile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import isMobile from 'is-mobile';

export default isMobile();
1 change: 1 addition & 0 deletions src/utils/noop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function noop() {};
3 changes: 3 additions & 0 deletions src/utils/resetApp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const resetApp = _ => window.location.reload();

export default resetApp;
9 changes: 9 additions & 0 deletions src/utils/today.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import dayjs from 'dayjs';

import { dateFormat } from 'config';

const today = _ => {
return dayjs().format(dateFormat);
};

export default today;

0 comments on commit 729b03b

Please sign in to comment.