fix: replaced constants

pull/3813/head
Arik Chakma 2 years ago
parent 173e37af38
commit fa9f87b310
  1. 2
      src/components/Login/AccountDropdown.astro
  2. 6
      src/components/Login/AccountNavigation.astro
  3. 2
      src/components/Login/EmailLoginForm.tsx
  4. 2
      src/components/Login/EmailSignupForm.tsx
  5. 2
      src/components/Login/GithubLogin.astro
  6. 2
      src/components/Login/GoogleLogin.astro
  7. 2
      src/components/Navigation.astro
  8. 2
      src/components/RoadmapHeader.astro
  9. 2
      src/components/Setting/UpdateProfileForm.tsx
  10. 3
      src/hooks/use-auth.ts
  11. 1
      src/lib/constants.ts
  12. 1
      src/lib/utils.ts
  13. 2
      src/pages/forgot-password.astro
  14. 2
      src/pages/login.astro
  15. 2
      src/pages/profile/index.astro
  16. 2
      src/pages/reset-password.astro
  17. 2
      src/pages/signup.astro
  18. 2
      src/pages/verify-account.astro

@ -34,7 +34,7 @@
<script>
import Cookies from 'js-cookie';
import { TOKEN_COOKIE_NAME } from '../../lib/utils';
import { TOKEN_COOKIE_NAME } from '../../lib/constants';
const accountButton = document.querySelector('[data-account-button]');
const accountMenu = accountButton?.nextElementSibling;

@ -15,7 +15,7 @@ import AccountDropdown from './AccountDropdown.astro';
<a
id='register-button'
class='hidden flex h-8 w-24 cursor-pointer items-center justify-center rounded-full bg-gradient-to-r from-blue-500 to-blue-700 py-2 px-4 text-sm font-medium text-white hover:from-blue-500 hover:to-blue-600'
class='flex hidden h-8 w-24 cursor-pointer items-center justify-center rounded-full bg-gradient-to-r from-blue-500 to-blue-700 py-2 px-4 text-sm font-medium text-white hover:from-blue-500 hover:to-blue-600'
href='/signup'
>
<span>Register</span>
@ -24,14 +24,14 @@ import AccountDropdown from './AccountDropdown.astro';
<script>
import Cookies from 'js-cookie';
import { TOKEN_COOKIE_NAME } from '../../lib/utils';
import { TOKEN_COOKIE_NAME } from '../../lib/constants';
const spinner = document.getElementById('navigation-spinner');
const registerButton = document.getElementById('register-button');
const accountDropdown = document.getElementById('account-dropdown');
spinner?.classList.add('hidden');
const token = Cookies.get(TOKEN_COOKIE_NAME);
if (token) {
accountDropdown?.classList.remove('hidden');
} else {

@ -1,7 +1,7 @@
import Cookies from 'js-cookie';
import type { FunctionComponent } from 'preact';
import { useState } from 'preact/hooks';
import { TOKEN_COOKIE_NAME } from '../../lib/utils';
import { TOKEN_COOKIE_NAME } from '../../lib/constants';
const EmailLoginForm: FunctionComponent<{}> = () => {
const [email, setEmail] = useState<string>('');

@ -1,7 +1,7 @@
import Cookies from 'js-cookie';
import type { FunctionComponent } from 'preact';
import { useState } from 'preact/hooks';
import { TOKEN_COOKIE_NAME } from '../../lib/utils';
import { TOKEN_COOKIE_NAME } from '../../lib/constants';
const EmailSignupForm: FunctionComponent<{}> = () => {
const [email, setEmail] = useState<string>('');

@ -18,7 +18,7 @@ import Spinner from '../Spinner.astro';
<script>
import Cookies from 'js-cookie';
import { TOKEN_COOKIE_NAME } from '../../lib/utils';
import { TOKEN_COOKIE_NAME } from '../../lib/constants';
const githubLoginButton = document.getElementById('github-login-button');
const githubLoginSpinner = document.getElementById('github-login-spinner');
const githubLoginText = document.querySelector('[data-github-text]');

@ -18,7 +18,7 @@ import Spinner from '../Spinner.astro';
<script>
import Cookies from 'js-cookie';
import { TOKEN_COOKIE_NAME } from '../../lib/utils';
import { TOKEN_COOKIE_NAME } from '../../lib/constants';
const googleLoginButton = document.getElementById('google-login-button');
const googleLoginSpinner = document.querySelector(
'[data-google-login-spinner]'

@ -105,7 +105,7 @@ import AccountNavigation from './Login/AccountNavigation.astro';
<script>
import Cookies from 'js-cookie';
import { TOKEN_COOKIE_NAME } from '../lib/utils';
import { TOKEN_COOKIE_NAME } from '../lib/constants';
const profileLink = document.getElementById('profile-mobile-nav');
const logoutButton = document.getElementById('logout-mobile-nav');

@ -153,7 +153,7 @@ const isRoadmapReady = !isUpcoming;
<script>
import Cookies from 'js-cookie';
import { TOKEN_COOKIE_NAME } from '../lib/utils';
import { TOKEN_COOKIE_NAME } from '../lib/constants';
const subscribeButton = document.getElementById('subscribe-button');
const downloadButton = document.getElementById('download-button');

@ -1,5 +1,5 @@
import { useEffect, useState } from 'preact/hooks';
import { TOKEN_COOKIE_NAME } from '../../lib/utils';
import { TOKEN_COOKIE_NAME } from '../../lib/constants';
import Cookies from 'js-cookie';
export default function UpdateProfileForm() {

@ -1,6 +1,7 @@
import { useEffect, useState } from 'preact/hooks';
import { TOKEN_COOKIE_NAME, TokenPayload, decodeToken } from '../lib/utils';
import { TokenPayload, decodeToken } from '../lib/utils';
import Cookies from 'js-cookie';
import { TOKEN_COOKIE_NAME } from '../lib/constants';
export const useAuth = () => {
const [user, setUser] = useState<TokenPayload | null>(null);

@ -0,0 +1 @@
export const TOKEN_COOKIE_NAME = '__roadmapsh_jt__';

@ -1,6 +1,5 @@
import * as jose from 'jose';
export const TOKEN_COOKIE_NAME = '__roadmapsh_jt__';
export type TokenPayload = {
id: string;
email: string;

@ -19,7 +19,7 @@ import SettingLayout from '../layouts/SettingLayout.astro';
<script>
import Cookies from 'js-cookie';
import { TOKEN_COOKIE_NAME } from '../lib/utils';
import { TOKEN_COOKIE_NAME } from '../lib/constants';
const token = Cookies.get(TOKEN_COOKIE_NAME);
if (token) {

@ -52,7 +52,7 @@ import BaseLayout from '../layouts/BaseLayout.astro';
<script>
import Cookies from 'js-cookie';
import { TOKEN_COOKIE_NAME } from '../lib/utils';
import { TOKEN_COOKIE_NAME } from '../lib/constants';
const token = Cookies.get(TOKEN_COOKIE_NAME);
if (token) {
window.location.href = '/';

@ -11,7 +11,7 @@ import BaseLayout from '../../layouts/BaseLayout.astro';
<script>
import Cookies from 'js-cookie';
import { TOKEN_COOKIE_NAME } from '../../lib/utils';
import { TOKEN_COOKIE_NAME } from '../../lib/constants';
const token = Cookies.get(TOKEN_COOKIE_NAME);
if (!token) {
window.location.href = '/';

@ -11,7 +11,7 @@ import SettingLayout from '../layouts/SettingLayout.astro';
<script>
import Cookies from 'js-cookie';
import { TOKEN_COOKIE_NAME } from '../lib/utils';
import { TOKEN_COOKIE_NAME } from '../lib/constants';
const token = Cookies.get(TOKEN_COOKIE_NAME);
const urlParams = new URLSearchParams(window.location.search);
const code = urlParams.get('code');

@ -53,7 +53,7 @@ import BaseLayout from '../layouts/BaseLayout.astro';
<script>
import Cookies from 'js-cookie';
import { TOKEN_COOKIE_NAME } from '../lib/utils';
import { TOKEN_COOKIE_NAME } from '../lib/constants';
const token = Cookies.get(TOKEN_COOKIE_NAME);
if (token) {
window.location.href = '/';

@ -34,7 +34,7 @@ import SettingLayout from '../layouts/SettingLayout.astro';
<script>
import Cookies from 'js-cookie';
import { TOKEN_COOKIE_NAME } from '../lib/utils';
import { TOKEN_COOKIE_NAME } from '../lib/constants';
const spinner = document.querySelector('[data-verification-spinner]');
const error = document.querySelector('[data-verification-error]');

Loading…
Cancel
Save