From 6b0663cbc625dadd85094adad9e2ab9e9d6d74e4 Mon Sep 17 00:00:00 2001 From: Amir reza Date: Sun, 10 May 2020 00:42:56 +0430 Subject: [PATCH 1/6] add read qr code place --- .../MyActivities/MyActivitiesActions.js | 39 +++++++++++++++++++ .../MyActivities/MyActivitiesReducer.js | 31 +++++++++++++++ .../MyActivities/pages/QrCode/QrScanner.js | 12 +++++- src/redux/actions/ActionTypes.js | 4 ++ 4 files changed, 85 insertions(+), 1 deletion(-) diff --git a/src/components/MyActivities/MyActivitiesActions.js b/src/components/MyActivities/MyActivitiesActions.js index a10312a..90c532f 100644 --- a/src/components/MyActivities/MyActivitiesActions.js +++ b/src/components/MyActivities/MyActivitiesActions.js @@ -154,6 +154,45 @@ export const createQrEvent = (data, history) => { }; }; +export const createQrPlaceEvent = (data, history) => { + return (dispatch, getState) => { + dispatch({ type: ActionTypes.ADD_PLACE_EVENT_REQUEST }); + + let now = new Date(); + + console.log(now); + + createEventInBulk( + 2, + data, + getState().MyActivities.user.people[0].id, + getState().MyActivities.token, + now + ) + .then((response) => { + if (response.status === 201) { + dispatch({ + type: ActionTypes.ADD_PLACE_EVENT_SUCCESS, + eventResult: response.data, + eventCounter: +getState().MyActivities.eventCounter + 1, + createTime: now, + }); + dispatch(showNav()); + + history.push('/my-activities'); + } else { + //TODO:باید پیاده سازی شود + throw response; + } + }) + .catch(() => { + dispatch({ + type: ActionTypes.ADD_PLACE_EVENT_FAILURE, + }); + }); + }; +}; + const createEventInBulk = (type, data, personId, token, now) => { let year = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(now); let month = new Intl.DateTimeFormat('en', { month: 'numeric' }).format(now); diff --git a/src/components/MyActivities/MyActivitiesReducer.js b/src/components/MyActivities/MyActivitiesReducer.js index 7b804ae..92dce43 100644 --- a/src/components/MyActivities/MyActivitiesReducer.js +++ b/src/components/MyActivities/MyActivitiesReducer.js @@ -32,6 +32,11 @@ const initialState = { success: false, error: false, }, + qrPlaceEvent: { + loading: false, + success: false, + error: false, + }, }; export function MyActivitiesReducer(state = initialState, action) { @@ -124,6 +129,32 @@ export function MyActivitiesReducer(state = initialState, action) { error: true, }, }; + case ActionTypes.ADD_PLACE_EVENT_REQUEST: + return { + ...state, + qrPlaceEvent: { + ...state.qrPlaceEvent, + loading: true, + }, + }; + case ActionTypes.ADD_PLACE_EVENT_SUCCESS: + return { + ...state, + eventResult: action.eventResult, + eventCounter: action.eventCounter, + qrPlaceEvent: { + ...state.qrPlaceEvent, + success: true, + }, + }; + case ActionTypes.ADD_PLACE_EVENT_FAILURE: + return { + ...state, + qrPlaceEvent: { + ...state.qrPlaceEvent, + error: true, + }, + }; default: return state; } diff --git a/src/components/MyActivities/pages/QrCode/QrScanner.js b/src/components/MyActivities/pages/QrCode/QrScanner.js index d35f82b..7660655 100644 --- a/src/components/MyActivities/pages/QrCode/QrScanner.js +++ b/src/components/MyActivities/pages/QrCode/QrScanner.js @@ -5,7 +5,7 @@ import { KeyboardBackspace } from '@material-ui/icons'; import { useHistory } from 'react-router-dom'; import { useDispatch } from 'react-redux'; import { showNav } from '../../../../redux/actions/CommonActions'; -import { createQrEvent } from '../../MyActivitiesActions'; +import { createQrEvent, createQrPlaceEvent } from '../../MyActivitiesActions'; import './QrCode.scss'; import logo from '../../../../logo-header.png'; @@ -15,6 +15,16 @@ export default function QrScanner() { function handleScan(data) { if (data) { + // check if place + const place = data.split('\n'); + if (place.length >= 6) { + const name = place[1].split('NAM')[1]; + const tel = place[2].split('TEL')[1]; + const psc = place[3].split('PSC')[1]; + const geo = place[4].split('GEO')[1]; + + dispatch(createQrPlaceEvent({ name, tel, psc, geo }, history)); + } // It is assumed that QR code has always the form person:code if (/^person:[a-z0-9]+$/i.test(data)) { dispatch(createQrEvent({ id: data.split(':')[1] }, history)); diff --git a/src/redux/actions/ActionTypes.js b/src/redux/actions/ActionTypes.js index ffcb21d..b42901b 100644 --- a/src/redux/actions/ActionTypes.js +++ b/src/redux/actions/ActionTypes.js @@ -9,3 +9,7 @@ export const ERROR_IN_HEALTH_EVENT_API = 'ERROR_IN_HEALTH_EVENT_API'; export const ADD_MEETING_EVENT_REQUEST = 'ADD_MEETING_EVENT_REQUEST'; export const ADD_MEETING_EVENT_SUCCESS = 'ADD_MEETING_EVENT_SUCCESS'; export const ADD_MEETING_EVENT_FAILURE = 'ADD_MEETING_EVENT_FAILURE'; + +export const ADD_PLACE_EVENT_REQUEST = 'ADD_PLACE_EVENT_REQUEST'; +export const ADD_PLACE_EVENT_SUCCESS = 'ADD_PLACE_EVENT_SUCCESS'; +export const ADD_PLACE_EVENT_FAILURE = 'ADD_PLACE_EVENT_FAILURE'; From 620bde9a2d9455cb970ce4c2e8560b25c267f998 Mon Sep 17 00:00:00 2001 From: Amir reza Date: Sun, 10 May 2020 00:44:33 +0430 Subject: [PATCH 2/6] Merge pull request #77 from n1rna/send-version Add app version to user health info event --- .env | 5 +++++ src/components/MyActivities/MyActivitiesActions.js | 1 + 2 files changed, 6 insertions(+) diff --git a/.env b/.env index b1eb03c..0fe43c4 100644 --- a/.env +++ b/.env @@ -39,3 +39,8 @@ REACT_APP_GET_VERSION_INFO=$DOMAIN/data/version.json # ------------------------------------- REACT_APP_ADD_TO_HOME_SCREEN_MODAL_ANDROID=false REACT_APP_ADD_TO_HOME_SCREEN_MODAL_IOS=false + +# ------------------------------------- +# VERSION +# ------------------------------------- +REACT_APP_VERSION=1 \ No newline at end of file diff --git a/src/components/MyActivities/MyActivitiesActions.js b/src/components/MyActivities/MyActivitiesActions.js index a10312a..d78af53 100644 --- a/src/components/MyActivities/MyActivitiesActions.js +++ b/src/components/MyActivities/MyActivitiesActions.js @@ -36,6 +36,7 @@ export const createHealthEvent = (data, history) => { dispatch({ type: ActionTypes.SHOW_HEALTH_EVENT_LOADING }); let indexedData = { + version: process.env.REACT_APP_VERSION, fever: MyHealthEventConsts.fever.indexOf(data.fever), sore_throat: MyHealthEventConsts.soreThroat.indexOf(data.sore_throat), dry_cough: MyHealthEventConsts.dryCough.indexOf(data.dry_cough), From 625fce3bd1c2177e5d3c5d2f1bf04382a8fd97a1 Mon Sep 17 00:00:00 2001 From: narges Date: Sat, 16 May 2020 12:47:04 +0430 Subject: [PATCH 3/6] Prevent user from zooming --- public/index.html | 5 ++--- yarn.lock | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/public/index.html b/public/index.html index a9b5a31..2394fbb 100644 --- a/public/index.html +++ b/public/index.html @@ -3,7 +3,6 @@ - diff --git a/yarn.lock b/yarn.lock index 5a4891e..50e3222 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1531,6 +1531,11 @@ resolved "https://registry.yarnpkg.com/@types/js-cookie/-/js-cookie-2.2.5.tgz#38dfaacae8623b37cc0b0d27398e574e3fc28b1e" integrity sha512-cpmwBRcHJmmZx0OGU7aPVwGWGbs4iKwVYchk9iuMtxNCA2zorwdaTz4GkLgs2WGxiRZRFKnV1k6tRUHX7tBMxg== +"@types/js-cookie@2.2.6": + version "2.2.6" + resolved "https://registry.yarnpkg.com/@types/js-cookie/-/js-cookie-2.2.6.tgz#f1a1cb35aff47bc5cfb05cb0c441ca91e914c26f" + integrity sha512-+oY0FDTO2GYKEV0YPvSshGq9t7YozVkgvXLty7zogQNuCxBhT9/3INX9Q7H1aRZ4SUDRXAKlJuA4EA5nTt7SNw== + "@types/json-schema@^7.0.3": version "7.0.4" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.4.tgz#38fd73ddfd9b55abb1e1b2ed578cb55bd7b7d339" @@ -9985,6 +9990,25 @@ react-use@>=12.0.0: ts-easing "^0.2.0" tslib "^1.10.0" +react-use@^14.2.0: + version "14.2.0" + resolved "https://registry.yarnpkg.com/react-use/-/react-use-14.2.0.tgz#abac033fae5e358599b7e38084ff11b02e5d4868" + integrity sha512-vwC7jsBsiDENLrXGPqIH3W4mMS2j24h5jp4ol3jiiUQzZhCaG+ihumrShJxBI59hXso1pLHAePRQAg/fJjDcaQ== + dependencies: + "@types/js-cookie" "2.2.6" + "@xobotyi/scrollbar-width" "1.9.5" + copy-to-clipboard "^3.2.0" + fast-deep-equal "^3.1.1" + fast-shallow-equal "^1.0.0" + js-cookie "^2.2.1" + nano-css "^5.2.1" + resize-observer-polyfill "^1.5.1" + screenfull "^5.0.0" + set-harmonic-interval "^1.0.1" + throttle-debounce "^2.1.0" + ts-easing "^0.2.0" + tslib "^1.10.0" + react@^16.13.1: version "16.13.1" resolved "https://registry.yarnpkg.com/react/-/react-16.13.1.tgz#2e818822f1a9743122c063d6410d85c1e3afe48e" From bbbf96f7d788ee87648ea01f8f4f325dd1a72e86 Mon Sep 17 00:00:00 2001 From: narges Date: Sat, 16 May 2020 12:48:49 +0430 Subject: [PATCH 4/6] Make status bar white --- public/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/public/index.html b/public/index.html index 2394fbb..a5389a2 100644 --- a/public/index.html +++ b/public/index.html @@ -13,6 +13,7 @@ name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width, user-scalable=no, shrink-to-fit=no" /> + From ab6a09e9a433434d8c27faa79bd8ff72e4999fd8 Mon Sep 17 00:00:00 2001 From: narges Date: Sat, 16 May 2020 13:15:24 +0430 Subject: [PATCH 5/6] Generalize 'outline: none' style --- .idea/watcherTasks.xml | 4 +++ src/App.scss | 35 ++++++++++++------- src/components/AppHeader/HeaderStyle.scss | 1 - src/components/Map/MapStyle.scss | 3 -- .../MyActivities/MyActivitiesStyle.scss | 1 - 5 files changed, 27 insertions(+), 17 deletions(-) create mode 100644 .idea/watcherTasks.xml diff --git a/.idea/watcherTasks.xml b/.idea/watcherTasks.xml new file mode 100644 index 0000000..fb0d65a --- /dev/null +++ b/.idea/watcherTasks.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/App.scss b/src/App.scss index 1f9e05a..50ce927 100644 --- a/src/App.scss +++ b/src/App.scss @@ -20,39 +20,50 @@ body { } body { - user-select: none; - outline: none; margin: 0; padding: 0; -webkit-font-smoothing: antialiased; - text-rendering: optimizeLegibility; - -webkit-touch-callout: none; scroll-snap-coordinate: 0 0; scroll-snap-type: mandatory; -webkit-overflow-scrolling: touch; + user-select: none; + overflow-x: hidden; + position: fixed !important; overscroll-behavior-x: none !important; top: 0; bottom: 0; left: 0; right: 0; + text-rendering: optimizeLegibility; + -webkit-touch-callout: none; } #root { - /* position: relative;*/ - /* touch-action: manipulation;*/ - /* -webkit-touch-callout: none;*/ + position: relative; + touch-action: manipulation; + -webkit-touch-callout: none; } html { - /* -webkit-tap-highlight-color: rgba(255, 255, 255, 0);*/ - /* -webkit-tap-highlight-color: transparent;*/ - /* height: 100vh;*/ - /* overflow: hidden;*/ + -webkit-tap-highlight-color: transparent; + height: 100vh; + width: 100vw; + overflow: hidden; +} + +html, +body { + height: 100%; +} + +body { + margin: 0; } +*, *:focus, *:active { - outline: none; + outline: none !important; } .app-container { diff --git a/src/components/AppHeader/HeaderStyle.scss b/src/components/AppHeader/HeaderStyle.scss index 242f3c5..41b984e 100644 --- a/src/components/AppHeader/HeaderStyle.scss +++ b/src/components/AppHeader/HeaderStyle.scss @@ -11,7 +11,6 @@ button { border-color: transparent; background-color: transparent; - outline: none; padding: 0; } z-index: 10; diff --git a/src/components/Map/MapStyle.scss b/src/components/Map/MapStyle.scss index c91db52..2127421 100644 --- a/src/components/Map/MapStyle.scss +++ b/src/components/Map/MapStyle.scss @@ -4,9 +4,6 @@ align-items: start; .map-button-wrapper { - button { - outline: none; - } position: fixed; z-index: 10; display: flex; diff --git a/src/components/MyActivities/MyActivitiesStyle.scss b/src/components/MyActivities/MyActivitiesStyle.scss index 7d7943a..1c73172 100644 --- a/src/components/MyActivities/MyActivitiesStyle.scss +++ b/src/components/MyActivities/MyActivitiesStyle.scss @@ -257,7 +257,6 @@ float: left; background-color: transparent; border: none; - outline: none; padding: 1rem 1rem 1rem 0; } } From 6a64f9bf3b793859c97b64150db22a8b024f94d5 Mon Sep 17 00:00:00 2001 From: narges Date: Sat, 16 May 2020 14:15:31 +0430 Subject: [PATCH 6/6] Fix place API request type and data --- .../MyActivities/MyActivitiesActions.js | 6 ++--- .../MyActivities/pages/QrCode/QrScanner.js | 26 ++++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/components/MyActivities/MyActivitiesActions.js b/src/components/MyActivities/MyActivitiesActions.js index 19ce856..361df50 100644 --- a/src/components/MyActivities/MyActivitiesActions.js +++ b/src/components/MyActivities/MyActivitiesActions.js @@ -118,7 +118,7 @@ export const createHealthEvent = (data, history) => { }; }; -export const createQrEvent = (data, history) => { +export const createQrMeetEvent = (data, history) => { return (dispatch, getState) => { dispatch({ type: ActionTypes.ADD_MEETING_EVENT_REQUEST }); @@ -161,10 +161,8 @@ export const createQrPlaceEvent = (data, history) => { let now = new Date(); - console.log(now); - createEventInBulk( - 2, + 3, data, getState().MyActivities.user.people[0].id, getState().MyActivities.token, diff --git a/src/components/MyActivities/pages/QrCode/QrScanner.js b/src/components/MyActivities/pages/QrCode/QrScanner.js index 7660655..4f70ac9 100644 --- a/src/components/MyActivities/pages/QrCode/QrScanner.js +++ b/src/components/MyActivities/pages/QrCode/QrScanner.js @@ -5,7 +5,10 @@ import { KeyboardBackspace } from '@material-ui/icons'; import { useHistory } from 'react-router-dom'; import { useDispatch } from 'react-redux'; import { showNav } from '../../../../redux/actions/CommonActions'; -import { createQrEvent, createQrPlaceEvent } from '../../MyActivitiesActions'; +import { + createQrMeetEvent, + createQrPlaceEvent, +} from '../../MyActivitiesActions'; import './QrCode.scss'; import logo from '../../../../logo-header.png'; @@ -15,19 +18,18 @@ export default function QrScanner() { function handleScan(data) { if (data) { - // check if place - const place = data.split('\n'); - if (place.length >= 6) { - const name = place[1].split('NAM')[1]; - const tel = place[2].split('TEL')[1]; - const psc = place[3].split('PSC')[1]; - const geo = place[4].split('GEO')[1]; - - dispatch(createQrPlaceEvent({ name, tel, psc, geo }, history)); - } // It is assumed that QR code has always the form person:code if (/^person:[a-z0-9]+$/i.test(data)) { - dispatch(createQrEvent({ id: data.split(':')[1] }, history)); + dispatch(createQrMeetEvent({ id: data.split(':')[1] }, history)); + } else { + // check if place + const place = data.split('\n'); + const location = place.find((value) => value.includes('GEO')); + if (location) { + const latitude = location.split('GEO')[1].split(',')[0]; + const longitude = location.split('GEO')[1].split(',')[1]; + dispatch(createQrPlaceEvent({ latitude, longitude }, history)); + } } } }