Skip to content

Commit

Permalink
Merge pull request #642 from enatega/main-vapid
Browse files Browse the repository at this point in the history
Main vapid
  • Loading branch information
ufumerfarooq67 authored Aug 8, 2024
2 parents e16ac03 + 9e18f58 commit 8e7ebbe
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 16 deletions.
4 changes: 4 additions & 0 deletions enatega-multivendor-admin/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@

<head>


<script type="text/javascript">
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "m8tm0wdr2j");
</script>

<script src="https://cdn.amplitude.com/libs/analytics-browser-2.7.4-min.js.gz"></script><script src="https://cdn.amplitude.com/libs/plugin-session-replay-browser-1.6.8-min.js.gz"></script><script src="https://cdn.amplitude.com/libs/plugin-autocapture-browser-0.9.0-min.js.gz"></script><script>window.amplitude.add(window.sessionReplay.plugin({sampleRate: 1})).promise.then(function() {window.amplitude.add(window.amplitudeAutocapturePlugin.plugin());window.amplitude.init('2f6189cefa2b2bd2a6d964a9970f81d6');});</script>
<!-- Begin Inspectlet Asynchronous Code -->

<script type="text/javascript">
(function () {
window.__insp = window.__insp || [];
Expand Down
1 change: 1 addition & 0 deletions enatega-multivendor-admin/src/apollo/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ export const saveFirebaseConfiguration = `
msgSenderId
appId
measurementId
vapidKey
}
}
`
Expand Down
1 change: 1 addition & 0 deletions enatega-multivendor-admin/src/apollo/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ export const getConfiguration = `query GetConfiguration{
skipEmailVerification
skipMobileVerification
costType
vapidKey
}
}`

Expand Down
2 changes: 1 addition & 1 deletion enatega-multivendor-admin/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const App = () => {
MEASUREMENT_ID,
GOOGLE_MAPS_KEY
} = ConfigurableValues()
console.log('GOOGLE_MAPS_KEY_App', GOOGLE_MAPS_KEY)

// const [mapsKey, setMapsKey] = useState(null)
// useEffect(() => {
// if (GOOGLE_MAPS_KEY) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function FirebaseConfiguration(props) {
const [msgSenderId] = useState(props.msgSenderId || '')
const [appId] = useState(props.appId || '')
const [measurementId] = useState(props.measurementId || '')
const [vapidKey] = useState(props.vapidKey || '')

const [firebaseKeyError, setFirebaseKeyError] = useState(null)
const [authDomainError, setAuthDomainError] = useState(null)
Expand All @@ -30,6 +31,7 @@ function FirebaseConfiguration(props) {
const [msgSenderIdError, setMsgSenderIdError] = useState(null)
const [appIdError, setAppIdError] = useState(null)
const [measurementIdError, setMeasurementIdError] = useState(null)
const [vapidKeyError, setVapidKeyError] = useState(null)

const [mutate, { loading }] = useMutation(SAVE_FIREBASE_CONFIGURATION)

Expand Down Expand Up @@ -286,6 +288,29 @@ function FirebaseConfiguration(props) {
/>
</Box>

<Box>
<Typography className={classes.labelText}>Vapid Key</Typography>
<Input
style={{ marginTop: -1 }}
id="input-vapidKey"
name="input-vapidKey"
placeholder="Vapid Key"
defaultValue={vapidKey}
onBlur={event =>
onBlur(setVapidKeyError, 'vapidKey', event.target.value)
}
disableUnderline
className={[
globalClasses.input,
vapidKeyError === false
? globalClasses.inputError
: vapidKeyError === true
? globalClasses.inputSuccess
: ''
]}
/>
</Box>

<Box>
<Button
className={globalClasses.button}
Expand All @@ -304,7 +329,8 @@ function FirebaseConfiguration(props) {
msgSenderId: formRef.current['input-msgSenderId'].value,
appId: formRef.current['input-appId'].value,
measurementId:
formRef.current['input-measurementId'].value
formRef.current['input-measurementId'].value,
vapidKey: formRef.current['input-vapidKey'].value ?? ''
}
}
})
Expand Down
12 changes: 6 additions & 6 deletions enatega-multivendor-admin/src/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import ConfigurationContext from '../context/Configuration'

const ConfigurableValues = () => {
const configuration = useContext(ConfigurationContext)
const SERVER_URL = 'https://enatega-multivendor.up.railway.app'
const WS_SERVER_URL = 'wss://enatega-multivendor.up.railway.app'
// const SERVER_URL = 'http://192.168.0.107:8001'
// const WS_SERVER_URL = 'ws://192.168.0.107:8001'
const SERVER_URL = 'https://enatega-multivendor-api-production.up.railway.app'
const WS_SERVER_URL = 'wss://enatega-multivendor-api-production.up.railway.app'
// const SERVER_URL = 'http://192.168.0.110:8001'
// const WS_SERVER_URL = 'ws://192.168.0.110:8001'
const GOOGLE_MAPS_KEY = configuration.googleApiKey
const FIREBASE_KEY = configuration.firebaseKey
const APP_ID = configuration.appId
Expand All @@ -18,10 +18,10 @@ const ConfigurableValues = () => {
const SENTRY_DSN = configuration.dashboardSentryUrl
const CLOUDINARY_UPLOAD_URL = configuration.cloudinaryUploadUrl
const CLOUDINARY_FOOD = configuration.cloudinaryApiKey
const VAPID_KEY =
'BOpVOtmawD0hzOR0F5NQTz_7oTlNVwgKX_EgElDnFuILsaE_jWYPIExAMIIGS-nYmy1lhf2QWFHQnDEFWNG_Z5w'
const VAPID_KEY = configuration.vapidKey
const PAID_VERSION = configuration.isPaidVersion


return {
GOOGLE_MAPS_KEY,
FIREBASE_KEY,
Expand Down
1 change: 1 addition & 0 deletions enatega-multivendor-admin/src/views/Configuration.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ const Configuration = props => {
msgSenderId={data && data.configuration.msgSenderId}
appId={data && data.configuration.appId}
measurementId={data && data.configuration.measurementId}
vapidKey={data && data.configuration.vapidKey}
/>
</Grid>
<Grid item sx={12} md={12} lg={5}>
Expand Down
2 changes: 2 additions & 0 deletions enatega-multivendor-web/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
})(window, document, "clarity", "script", "m893shrzty");
</script>

<script src="https://cdn.amplitude.com/libs/analytics-browser-2.7.4-min.js.gz"></script><script src="https://cdn.amplitude.com/libs/plugin-session-replay-browser-1.6.8-min.js.gz"></script><script src="https://cdn.amplitude.com/libs/plugin-autocapture-browser-0.9.0-min.js.gz"></script><script>window.amplitude.add(window.sessionReplay.plugin({sampleRate: 1})).promise.then(function() {window.amplitude.add(window.amplitudeAutocapturePlugin.plugin());window.amplitude.init('2f6189cefa2b2bd2a6d964a9970f81d6');});</script>

<link
href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300;0,400;0,600;0,700;0,800;1,300;1,400;1,600;1,700;1,800&display=swap"
rel="stylesheet" />
Expand Down
18 changes: 13 additions & 5 deletions enatega-multivendor-web/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ import VerifyPhone from "./screens/VerifyPhone/VerifyPhone";
import UserContext from "./context/User";
import { useTranslation } from "react-i18next";

const GoogleMapsLoader = ({ children, LIBRARIES, GOOGLE_MAPS_KEY }) => {
const GoogleMapsLoader = ({
children,
LIBRARIES,
GOOGLE_MAPS_KEY,
VAPID_KEY,
}) => {
const [message, setMessage] = useState(null);
const { t, i18n } = useTranslation();

Expand All @@ -48,8 +53,7 @@ const GoogleMapsLoader = ({ children, LIBRARIES, GOOGLE_MAPS_KEY }) => {
Notification.requestPermission()
.then(() => {
getToken(messaging, {
vapidKey:
"BOpVOtmawD0hzOR0F5NQTz_7oTlNVwgKX_EgElDnFuILsaE_jWYPIExAMIIGS-nYmy1lhf2QWFHQnDEFWNG_Z5w",
vapidKey: VAPID_KEY,
})
.then((token) => {
localStorage.setItem("messaging-token", token);
Expand Down Expand Up @@ -132,12 +136,16 @@ const GoogleMapsLoader = ({ children, LIBRARIES, GOOGLE_MAPS_KEY }) => {
};

function App() {
const { GOOGLE_MAPS_KEY, LIBRARIES } = ConfigurableValues();
const { GOOGLE_MAPS_KEY, LIBRARIES, VAPID_KEY } = ConfigurableValues();
const { isLoggedIn } = useContext(UserContext);

return GOOGLE_MAPS_KEY ? (
<HashRouter>
<GoogleMapsLoader GOOGLE_MAPS_KEY={GOOGLE_MAPS_KEY} LIBRARIES={LIBRARIES}>
<GoogleMapsLoader
GOOGLE_MAPS_KEY={GOOGLE_MAPS_KEY}
LIBRARIES={LIBRARIES}
VAPID_KEY={VAPID_KEY}
>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/restaurant-list" element={<Restaurants />} />
Expand Down
1 change: 1 addition & 0 deletions enatega-multivendor-web/src/apollo/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ export const getConfiguration = `query Configuration{
skipEmailVerification
skipMobileVerification
costType
vapidKey
}
}`;

Expand Down
8 changes: 5 additions & 3 deletions enatega-multivendor-web/src/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const ConfigurableValues = () => {
const configuration = useContext(ConfigurationContext);
const SERVER_URL = "https://enatega-multivendor.up.railway.app/";
const WS_SERVER_URL = "wss://enatega-multivendor.up.railway.app/";
// const SERVER_URL = 'http://192.168.0.107:8001/'
// const WS_SERVER_URL = 'ws://192.168.0.107:8001/'
//const SERVER_URL = 'http://192.168.0.110:8001/'
//const WS_SERVER_URL = 'ws://192.168.0.110:8001/'
const GOOGLE_CLIENT_ID = configuration.webClientID;
const STRIPE_PUBLIC_KEY = configuration.publishableKey;
const PAYPAL_KEY = configuration.clientId;
Expand All @@ -22,6 +22,7 @@ const ConfigurableValues = () => {
const SENTRY_DSN = configuration.webSentryUrl;
const SKIP_EMAIL_VERIFICATION = configuration.skipEmailVerification;
const SKIP_MOBILE_VERIFICATION = configuration.skipMobileVerification;
const VAPID_KEY = configuration.vapidKey;

return {
SERVER_URL,
Expand All @@ -35,7 +36,8 @@ const ConfigurableValues = () => {
LIBRARIES,
SENTRY_DSN,
SKIP_EMAIL_VERIFICATION,
SKIP_MOBILE_VERIFICATION
SKIP_MOBILE_VERIFICATION,
VAPID_KEY,
};
};

Expand Down

0 comments on commit 8e7ebbe

Please sign in to comment.