This repository has been archived by the owner on Sep 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5e369c
commit 054ac73
Showing
18 changed files
with
3,732 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// eslint-disable-next-line no-undef | ||
module.exports = { | ||
root: true, | ||
parser: '@typescript-eslint/parser', | ||
plugins: [ | ||
'@typescript-eslint', | ||
], | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# Dependency directories | ||
node_modules/ | ||
built/ | ||
dist/ | ||
dist/ | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import getQueryStringValue from '../getQueryStringValue'; | ||
|
||
describe('validating `src/getQueryStringValue`..', () => { | ||
it('should return `invitation` when given `?type=invitation`', () => { | ||
expect(getQueryStringValue({ search: '?type=invitation' }, 'type')).toBe('invitation'); | ||
}); | ||
|
||
it('should return `indra` when given `?to=indra&type=invitation`', () => { | ||
expect(getQueryStringValue({ search: '?to=indra&type=invitation' }, 'to')).toBe('indra'); | ||
}); | ||
|
||
it('should return empty string when given invalid qs or queryName', () => { | ||
expect(getQueryStringValue({ search: '?type=indra' }, 'to')).toBe(''); | ||
expect(getQueryStringValue({ search: '?type=indra&to=' }, 'to')).toBe(''); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import noop from '../noop'; | ||
|
||
describe('validating `src/noop`...', () => { | ||
it('function should be called', () => { | ||
expect(noop()).toBe(undefined); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Function to check is can use the DOM or not | ||
* @returns {boolean} | ||
*/ | ||
function canUseDOM() { | ||
if (typeof window !== 'undefined' && window.document && window.document.createElement) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
export default canUseDOM; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
const BANK_LOGO = { | ||
bca: { | ||
text: 'BCA (Bank Central Asia)', | ||
logo: `https://user-images.githubusercontent.com/10141928/137078885-aff0a5f8-8d62-4415-b0dd-34e8126e3cb3.jpg`, | ||
}, | ||
mandiri: { | ||
text: 'Bank Mandiri', | ||
logo: `https://user-images.githubusercontent.com/10141928/137079644-dbccb649-2e25-48b7-ba49-e7b38b6e16f4.jpg`, | ||
}, | ||
gopay: { | ||
text: 'Gopay', | ||
logo: `https://user-images.githubusercontent.com/10141928/137080671-be3cd9c2-b15b-461f-b5be-072e5087cc1a.jpg`, | ||
}, | ||
bni: { | ||
text: 'BNI', | ||
logo: `https://user-images.githubusercontent.com/10141928/147829773-83849afe-2a53-437d-83c5-c7d062a47f63.png`, | ||
}, | ||
bsi: { | ||
text: 'BSI (Bank Syariah Indonesia)', | ||
logo: `https://user-images.githubusercontent.com/10141928/147829845-5de9fdd2-de14-4112-8931-b46eddba5c6c.png`, | ||
}, | ||
linkAja: { | ||
text: 'Link Aja', | ||
logo: `https://user-images.githubusercontent.com/10141928/147829920-da1bbc92-dd4c-451d-a946-2803010a9bd3.png`, | ||
}, | ||
payPal: { | ||
text: 'PayPal', | ||
logo: `https://user-images.githubusercontent.com/10141928/147829980-cb64b93f-2969-4042-ac53-c38d299631d5.png`, | ||
}, | ||
dana: { | ||
text: 'DANA', | ||
logo: `https://user-images.githubusercontent.com/10141928/137604292-a9fa143e-8d34-4da3-8e71-09ecdd365712.png`, | ||
}, | ||
bri: { | ||
text: 'BRI (Bank Rakyat Indonesia)', | ||
logo: `https://user-images.githubusercontent.com/10141928/137526934-cc9b1d37-609b-478d-ad12-fc96e2c13f7c.png`, | ||
}, | ||
jenius: { | ||
text: 'BTPN Jenius', | ||
logo: `https://user-images.githubusercontent.com/10141928/147830197-ff989d03-2448-4aa1-9c79-a3cff3b8fe55.png`, | ||
}, | ||
btn: { | ||
text: 'BTN (Bank Tabungan Negara)', | ||
logo: `https://user-images.githubusercontent.com/10141928/147830252-a0913dc3-343c-4218-b1f1-010219630ce0.png`, | ||
}, | ||
ovo: { | ||
text: 'OVO', | ||
logo: `https://user-images.githubusercontent.com/10141928/148795208-627a6c1d-7bc3-430e-a69d-c15db4f785c5.png`, | ||
}, | ||
shopeePay: { | ||
text: 'Shopee Pay', | ||
logo: `https://user-images.githubusercontent.com/10141928/148951310-73273d54-524a-4e13-bb4c-100a0e5d61d6.png`, | ||
}, | ||
bankJateng: { | ||
text: 'Bank Jateng', | ||
logo: `https://user-images.githubusercontent.com/10141928/148952015-dd874328-69f6-4314-8714-2c9e2ff9e572.png`, | ||
}, | ||
cimb: { | ||
text: 'Bank CIMB', | ||
logo: `https://user-images.githubusercontent.com/10141928/148952304-a5b6b79f-8a3d-4af5-9a3f-8b3b0e92c0d3.png`, | ||
}, | ||
bankPermata: { | ||
text: 'Bank Permata', | ||
logo: `https://user-images.githubusercontent.com/10141928/148952398-e26efa80-55da-486d-aaa3-8fe01318fe76.png`, | ||
}, | ||
}; | ||
|
||
export default BANK_LOGO; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * as BANK_LOGO from './banks'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* Fallback function to copy text if navigator clipboard not ready | ||
* @param {Anything} text | ||
* @returns {boolean} | ||
*/ | ||
function fallbackCopyTextToClipboard(text: string): boolean { | ||
const textArea = document.createElement('textarea'); | ||
let result = false; | ||
textArea.value = text; | ||
|
||
// Avoid scrolling to bottom | ||
textArea.style.top = '0'; | ||
textArea.style.left = '0'; | ||
textArea.style.position = 'fixed'; | ||
|
||
document.body.appendChild(textArea); | ||
textArea.focus(); | ||
textArea.select(); | ||
|
||
try { | ||
const successful = document.execCommand('copy'); | ||
result = successful ? true : false; | ||
} catch (err) { | ||
result = false; | ||
} | ||
|
||
document.body.removeChild(textArea); | ||
return result; | ||
} | ||
|
||
/** | ||
* Async function to copy text | ||
* @param {Anything} text | ||
* @returns {boolean} | ||
*/ | ||
async function copyTextToClipboard(text: string): Promise<boolean> { | ||
let result = false; | ||
|
||
if (!navigator.clipboard) { | ||
result = fallbackCopyTextToClipboard(text); | ||
return result; | ||
} | ||
|
||
await navigator.clipboard.writeText(text).then( | ||
function () { | ||
result = true; | ||
console.log('[SUCCESS] text copied to clipboard ✅'); | ||
}, | ||
function (err) { | ||
console.log('[FAILED] text failed to clipboard ❌', err); | ||
result = false; | ||
}, | ||
); | ||
|
||
return result; | ||
} | ||
|
||
export default copyTextToClipboard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Function to return value from querystring | ||
* @param {Location} location | ||
* @param {string} name | ||
* @returns {string} | ||
*/ | ||
function getQueryValue(location: Pick<Location, 'search'>, queryName: string): string { | ||
const testedName = queryName.replace(/[[]/, '\\[').replace(/[\]]/, '\\]'); | ||
const regex = new RegExp(`[\\?&]${testedName}=([^&#]*)`); | ||
const results = regex.exec(location.search); | ||
|
||
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); | ||
} | ||
|
||
export default getQueryValue || ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import dayjs from 'dayjs'; | ||
/** | ||
* Function to get current time with default format `MM/DD/YYYY HH:mm:ss` | ||
* For format, you can refer the `dayjs` docs | ||
* | ||
* @param {string} format | ||
* @returns {string} | ||
*/ | ||
function getTimeNow(format = 'MM/DD/YYYY HH:mm:ss'): string { | ||
return `${dayjs(new Date()).format(format)}`; | ||
} | ||
|
||
export default getTimeNow; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
import getDeviceOS from './getDeviceOS'; | ||
import isDarkmode from './isDarkmode'; | ||
|
||
export { getDeviceOS, isDarkmode }; | ||
export * as canUseDOM from './canUseDOM'; | ||
export * as copyTextToClipboard from './copyTextToClipboard'; | ||
export * as getDeviceOS from './getDeviceOS'; | ||
export * as getQueryStringValue from './getQueryStringValue'; | ||
export * as getTimeNow from './getTimeNow'; | ||
export * as isDarkmode from './isDarkmode'; | ||
export * as isDevelopmentMode from './isDevelopmentMode'; | ||
export * as noop from './noop'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Function to check is Development Mode or Not | ||
* @return {boolean} | ||
*/ | ||
function isDevelopment(): boolean { | ||
try { | ||
if (typeof window.location !== 'undefined') { | ||
if (window.location.href.includes('//localhost')) return true; | ||
} | ||
} catch (error) { | ||
console.log('ERR_WHEN_ACCESS_DOM'); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
export default isDevelopment; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* Function to return nothing | ||
* @returns {void} | ||
*/ | ||
const noop = (): void => {}; | ||
export default noop; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.