Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/goto page #759

Merged
merged 4 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/constants/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const APP_URLS = {
TASKS: `${SCHEME}staging-my.${DOMAIN}/tasks`,
IDENTITY: `${SCHEME}staging-my.${DOMAIN}/identity`,
MY_STATUS: `${SCHEME}staging-my.${DOMAIN}`,
API_BACKEND: `${SCHEME}staging-api.${DOMAIN}`,
API_BACKEND: `http://localhost:3000`,
shubhamsinghbundela marked this conversation as resolved.
Show resolved Hide resolved
},
test: {
HOME: `${SCHEME}${DOMAIN}`,
Expand Down
66 changes: 66 additions & 0 deletions app/controllers/goto.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import { APPS, AUTH } from '../constants/urls';
import { tracked } from '@glimmer/tracking';
import fetch from 'fetch';

export default class GotoController extends Controller {
queryParams = ['dev'];
@service router;
@service store;
@service fastboot;
@tracked user;

WELCOME_URL = APPS.WELCOME;
SIGN_UP_URL = AUTH.SIGN_UP;
HOME_URL = 'index';

constructor() {
super(...arguments);

if (!this.fastboot.isFastBoot) {
const queryParams = new URLSearchParams(window.location.search);
const isDev = Boolean(queryParams.get('dev'));

(async () => {
await this.getSelfUser();
this.redirectionHandler(isDev, this.user);
})();
}
}

redirectionHandler(isDev, user) {
if (user.incompleteUserDetails) {
this.redirectUserToPage(this.SIGN_UP_URL);
} else if (isDev) {
if (user.roles?.developer && !user.roles?.in_discord) {
this.redirectUserToPage(this.WELCOME_URL);
} else {
this.router.transitionTo(this.HOME_URL);
}
} else {
if (!user.roles?.in_discord) {
this.redirectUserToPage(this.WELCOME_URL);
} else {
this.router.transitionTo(this.HOME_URL);
}
}
}

redirectUserToPage(url) {
window.location.replace(url);
}

async getSelfUser() {
const response = await fetch(`${APPS.API_BACKEND}/users/self`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
});

const userData = await response.json();
this.user = userData;
}
}
1 change: 1 addition & 0 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ Router.map(function () {
this.route('live');
this.route('page-not-found', { path: '/*' });
this.route('intro');
this.route('goto');
});
3 changes: 1 addition & 2 deletions app/routes/application.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
import Route from '@ember/routing/route';

export default class IndexRoute extends Route {}
export default class ApplicationRoute extends Route {}
2 changes: 2 additions & 0 deletions app/routes/goto.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Route from '@ember/routing/route';
export default class GotoRoute extends Route {}
1 change: 1 addition & 0 deletions app/styles/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
@import url("events.module.css");
@import url("identity-card.module.css");
@import url("wheel-animations.css");
@import url("goto.module.css");

* {
margin: 0;
Expand Down
33 changes: 33 additions & 0 deletions app/styles/goto.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.redirection-wrapper {
height: 90vh;
width: 100vw;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
box-sizing: border-box;
}

.logo-img {
width: 18rem;
height: 18rem;
display: block;
margin: 0 auto;
}

.redirection {
font-size: 1.6rem;
text-align: center;
}

@media (width >= 425px) {
.logo-img {
width: 25rem;
height: 25rem;
}

.redirection {
font-size: 2rem;
text-align: center;
}
}
10 changes: 10 additions & 0 deletions app/templates/goto.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{page-title 'Please wait'}}

<section class='redirection-wrapper'>
<img
class='logo-img'
src='/assets/images/rds-logo-2x.png'
alt='Real Dev Squad'
/>
<h1 class='redirection'>Redirecting to your correct location...</h1>
</section>
shubhamsinghbundela marked this conversation as resolved.
Show resolved Hide resolved
Loading