Skip to content

Commit

Permalink
app redirection based on mobile os. (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
arrogant-ant committed Sep 10, 2023
1 parent d94c457 commit 43389af
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/components/templates/TemplateAbout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<div class="app-links">
<span>
<a
href="https://play.google.com/store/apps/details?id=com.parkspot.maya_nagri&utm_source=parkspot.in&utm_campaign=website"
:href="APP_LINK.ANDROID"
target="_blank"
>
<figure class="card-img image">
Expand All @@ -41,10 +41,7 @@
</a>
</span>
<span>
<a
href="https://apps.apple.com/in/app/parkspot-find-book-parking/id6449634064"
target="_blank"
>
<a :href="APP_LINK.IOS" target="_blank">
<figure class="card-img image">
<img
alt="ios app link"
Expand All @@ -66,6 +63,7 @@ import BodyWrapper from '../extras/BodyWrapper.vue';
import AtomHeading from '../atoms/AtomHeading.vue';
import AtomParagraph from '../atoms/AtomParagraph.vue';
import AtomImage from '../atoms/AtomImage.vue';
import { APP_LINK } from '@/constant/constant';
export default {
name: 'TemplateAbout',
components: {
Expand All @@ -79,6 +77,7 @@ export default {
appLinkImg: require('@/assets/google-play-badge.svg'),
iosAppLinkImg: require('@/assets/apple-store.svg'),
aboutImg: require('@/assets/about.svg'),
APP_LINK,
};
},
};
Expand Down
6 changes: 6 additions & 0 deletions src/constant/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,9 @@ export const PAGE_TITLE = {
DISCOVER: 'Parking Near ',
SEARCH: 'ParkSpot | ',
};

export const APP_LINK = {
IOS: 'https://apps.apple.com/in/app/parkspot-find-book-parking/id6449634064',
ANDROID:
'https://play.google.com/store/apps/details?id=com.parkspot.maya_nagri&utm_source=parkspot.in&utm_campaign=website',
};
24 changes: 24 additions & 0 deletions src/router/routes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Home from '../views/PageHome.vue';
import PageAbout from '@/views/PageAbout.vue';
import { firebase, getDatabase, ref, get, child } from '../firebase';
import { APP_LINK } from '../constant/constant';

const guardThisRoute = async (to, from, next) => {
const db = getDatabase(firebase);
Expand Down Expand Up @@ -44,6 +45,8 @@ export const pages = {
TEMP : '/temp',
THANK_YOU : '/thank-you',
ERROR : '/error',
BOOKING_PORTAL : "/internal/booking-portal",
APP : "/app"
};

export const routes = [
Expand Down Expand Up @@ -149,6 +152,27 @@ export const routes = [
name: 'error',
component: () => import('@/views/PageError.vue'),
},
{
path: pages.BOOKING_PORTAL,
name: 'booking-portal',
component: () => import('@/views/BookingPortal.vue'),
},
{
path: pages.APP,
name: 't-about',
component: PageAbout,
beforeEnter(to, from, next) {
const androidRegexp = /android/i;
if (androidRegexp.test(navigator.userAgent)) {
window.location.href = APP_LINK.ANDROID;
}
const iOSRegexp = /iphone|ipad/i;
if (iOSRegexp.test(navigator.userAgent)) {
window.location.href = APP_LINK.IOS;
}
next();
},
},
// Todo Delete below code before deployment
{
path: pages.TEMP,
Expand Down

0 comments on commit 43389af

Please sign in to comment.