Skip to content

Commit

Permalink
fix(scanner): added scanner component
Browse files Browse the repository at this point in the history
  • Loading branch information
opensrc0 committed Mar 3, 2024
1 parent a56807d commit b043eb3
Show file tree
Hide file tree
Showing 9 changed files with 386 additions and 33 deletions.
6 changes: 4 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"node": true
},
"globals": {
"APP_ENV": true
"APP_ENV": true,
"globalThis": true
},
"rules": {
"import/no-extraneous-dependencies": ["off"], // Need to use external dep like webpack-dashboard
Expand All @@ -14,7 +15,8 @@
"no-underscore-dangle": ["off"],
"react/prop-types": ["off"],
"jsx-a11y/control-has-associated-label": ["off"],
"react/forbid-prop-types": ["off"]
"react/forbid-prop-types": ["off"],
"object-curly-newline": ["off"]
},
"parserOptions": {
"ecmaVersion":"latest"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ A React UI library for Advance Web Features that streamlines the development of

## Features
- **Web/Mobile Support:** fe-pilot will be helpfull in Large/Mid/Small size of web based applications.
- **Ease of Use:** fe-pilot contains a set of components like `Scanner`, `PhoneBook`, `Voice Search`, `Share`, `Contact List`, `Live Location Tracking`, `Current Location` that are easy to plug and play.
- **Ease of Use:** fe-pilot contains a set of components like `Scanner`, `PhoneBook`, `Voice Search`, `Share`, `Live Location Tracking`, `Current Location` that are easy to plug and play.
- **Scalable & Maintainable:** fe-pilot components are built on top of a React for better scalable, maintainable component.

## Installation
Expand Down
7 changes: 7 additions & 0 deletions __app/component/Bluetooth/Bluetooth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';

export default function bluetooth() {
return (
<div>bluetooth</div>
);
}
7 changes: 7 additions & 0 deletions __app/component/Clipboard/Clipboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';

export default function Clipboard() {
return (
<div>Clipboard</div>
);
}
35 changes: 25 additions & 10 deletions __app/component/PhoneBook/PhoneBook.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@ import PropTypes from 'prop-types';

const isPhoneBookAPISupport = () => navigator.contacts && window.ContactsManager;

const handleError = ({ disbaleToast, msg, msgType, failureCb }) => {
console.log(msgType);
if (!disbaleToast && msg) console.log(msg);
failureCb({
msgType,
msg,
});
};

const handleSuccess = ({ disbaleToast, msg, msgType, data, successCb }) => {
console.log(msgType);
if (!disbaleToast && msg) console.log('Success:', msg);
successCb({
msgType,
msg,
data,
});
};

function PhoneBook({
disbaleToast,
successCb,
Expand All @@ -21,15 +40,12 @@ function PhoneBook({
if (isPhoneBookAPISupport()) {
try {
const contacts = await navigator.contacts.select(contactProperty, opts);
if (!disbaleToast && successMsg) console.log('Success:', successMsg);
successCb({ msgType: 'SUCCESS', msg: successMsg, data: contacts });
handleSuccess({ disbaleToast, msgType: 'SUCCESS', msg: successMsg, successCb, data: contacts });
} catch (error) {
if (!disbaleToast && failureMsg.generalMsg) console.log(failureMsg.generalMsg || error);
failureCb({ msgType: 'ERROR', msg: failureMsg.generalMsg || error });
handleError({ disbaleToast, msgType: 'ERROR', msg: failureMsg.error || error, failureCb });
}
} else {
if (!disbaleToast && failureMsg.unSupportedMsg) console.log(failureMsg.unSupportedMsg);
failureCb({ msgType: 'UN_SUPPORTED_FEATURE', msg: failureMsg.unSupportedMsg });
handleError({ disbaleToast, msgType: 'UN_SUPPORTED_FEATURE', msg: failureMsg.unSupported, failureCb });
}
};

Expand Down Expand Up @@ -61,11 +77,10 @@ PhoneBook.defaultProps = {
failureCb: () => {},
successMsg: '',
failureMsg: {
unSupportedMsg: '',
badRequestMsg: '',
generalMsg: '',
unSupported: '',
error: '',
},
showForever: false,
showForever: true,
contactProperty: ['name', 'email', 'tel', 'address', 'icon'],
isSelectMultiple: false,
};
Expand Down
Loading

0 comments on commit b043eb3

Please sign in to comment.