Skip to content

Commit

Permalink
feat(unified-login): update dahboard_url function call
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricmagne authored and Vlad Lo. committed Aug 23, 2024
1 parent a43d146 commit 1d1ce86
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/components/AuthLogin/AuthModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import React, { useEffect } from "react";
import Modal from "react-modal";
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import styles from "./styles.module.css";
Expand Down Expand Up @@ -104,7 +104,6 @@ const AuthModal = ({
open,
setOpen,
setProjects,
setUser,
step,
setStep,
}: AuthModalProps) => {
Expand Down
8 changes: 6 additions & 2 deletions src/components/CodeTerminal/TerminalViewBox.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useMemo } from "react";
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import Icon from "../Icon/Icon";
import { DASHBOARD_URL } from "../../lib/constants";
import Link from "@docusaurus/Link";
Expand All @@ -15,6 +16,9 @@ const TerminalViewBox = ({
isExpansionNetwork = false,
}) => {

const { siteConfig } = useDocusaurusContext();
const { DASHBOARD_PREVIEW_URL, VERCEL_ENV } = siteConfig?.customFields || {}

const exampleRequest = useMemo(() => {
const prepareParams = params.length === 0 ? "" : params.map(param => {
if ('boolean' === typeof param) return `${param}`
Expand Down Expand Up @@ -48,13 +52,13 @@ const TerminalViewBox = ({
</div>
) : (
<p className="description-row">
<Link target="_blank" to={`${DASHBOARD_URL}/login`} rel="noreferrer">
<Link target="_blank" to={`${DASHBOARD_URL(DASHBOARD_PREVIEW_URL, VERCEL_ENV)}/login`} rel="noreferrer">
Sign in
</Link>{" "}
or{" "}
<Link
target="_blank"
to={`${DASHBOARD_URL}/register`}
to={`${DASHBOARD_URL(DASHBOARD_PREVIEW_URL, VERCEL_ENV)}/register`}
rel="noreferrer">
create an account
</Link>{" "}
Expand Down
8 changes: 6 additions & 2 deletions src/hooks/useUser.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import { useState, useEffect } from "react";
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import { DASHBOARD_URL, GET_OPTIONS } from "../lib/constants";

export default function useUser() {
const { siteConfig } = useDocusaurusContext();
const { DASHBOARD_PREVIEW_URL, VERCEL_ENV } = siteConfig?.customFields || {}
const [user, setUser] = useState(undefined);
const [loading, setLoading] = useState(true);
const [keys, setKeys] = useState([]);

const getUserInfo = async () => {
setLoading(true);
try {
const res = await fetch(`${DASHBOARD_URL}/api/me`, GET_OPTIONS);
const res = await fetch(`${DASHBOARD_URL(DASHBOARD_PREVIEW_URL, VERCEL_ENV)}/api/me`, GET_OPTIONS);
const response = await res.json();
if (response?.data) {
setUser(response.data);
const userId = response.data.id;
const upData = await fetch(
`${DASHBOARD_URL}/api/v1/users/${userId}/projects`,
`${DASHBOARD_URL(DASHBOARD_PREVIEW_URL, VERCEL_ENV)}/api/v1/users/${userId}/projects`,
GET_OPTIONS
);
if (upData.ok) {
Expand Down

0 comments on commit 1d1ce86

Please sign in to comment.