fix: name and label

feat/new-user
Arik Chakma 2 weeks ago
parent 6c02da0b35
commit f09375b447
  1. 5
      src/components/AuthenticationFlow/EmailLoginForm.tsx
  2. 6
      src/components/AuthenticationFlow/GitHubButton.tsx
  3. 5
      src/components/AuthenticationFlow/GoogleButton.tsx
  4. 5
      src/components/AuthenticationFlow/LinkedInButton.tsx
  5. 6
      src/components/AuthenticationFlow/TriggerVerifyAccount.tsx
  6. 14
      src/components/ShareIcons/ShareIcons.tsx
  7. 1
      src/lib/jwt.ts
  8. 2
      src/pages/[roadmapId]/index.astro
  9. 2
      src/pages/best-practices/[bestPracticeId]/index.astro

@ -2,8 +2,7 @@ import Cookies from 'js-cookie';
import type { FormEvent } from 'react'; import type { FormEvent } from 'react';
import { useId, useState } from 'react'; import { useId, useState } from 'react';
import { httpPost } from '../../lib/http'; import { httpPost } from '../../lib/http';
import { TOKEN_COOKIE_NAME, setAuthToken } from '../../lib/jwt'; import { FIRST_LOGIN_PARAM, setAuthToken } from '../../lib/jwt';
import { FIRST_LOGIN_TAG } from './TriggerVerifyAccount';
type EmailLoginFormProps = { type EmailLoginFormProps = {
isDisabled?: boolean; isDisabled?: boolean;
@ -40,7 +39,7 @@ export function EmailLoginForm(props: EmailLoginFormProps) {
const currentLocation = window.location.href; const currentLocation = window.location.href;
const url = new URL(currentLocation, window.location.origin); const url = new URL(currentLocation, window.location.origin);
if (response?.isNewUser) { if (response?.isNewUser) {
url.searchParams.set(FIRST_LOGIN_TAG, '1'); url.searchParams.set(FIRST_LOGIN_PARAM, '1');
} }
window.location.href = url.toString(); window.location.href = url.toString();
return; return;

@ -1,11 +1,9 @@
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { GitHubIcon } from '../ReactIcons/GitHubIcon.tsx'; import { GitHubIcon } from '../ReactIcons/GitHubIcon.tsx';
import Cookies from 'js-cookie'; import { FIRST_LOGIN_PARAM, setAuthToken } from '../../lib/jwt';
import { TOKEN_COOKIE_NAME, setAuthToken } from '../../lib/jwt';
import { httpGet } from '../../lib/http'; import { httpGet } from '../../lib/http';
import { Spinner } from '../ReactIcons/Spinner.tsx'; import { Spinner } from '../ReactIcons/Spinner.tsx';
import { triggerUtmRegistration } from '../../lib/browser.ts'; import { triggerUtmRegistration } from '../../lib/browser.ts';
import { FIRST_LOGIN_TAG } from './TriggerVerifyAccount.tsx';
type GitHubButtonProps = { type GitHubButtonProps = {
isDisabled?: boolean; isDisabled?: boolean;
@ -78,7 +76,7 @@ export function GitHubButton(props: GitHubButtonProps) {
const url = new URL(redirectUrl, window.location.origin); const url = new URL(redirectUrl, window.location.origin);
if (response?.isNewUser) { if (response?.isNewUser) {
url.searchParams.set(FIRST_LOGIN_TAG, '1'); url.searchParams.set(FIRST_LOGIN_PARAM, '1');
} }
window.location.href = url.toString(); window.location.href = url.toString();
}) })

@ -1,6 +1,6 @@
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import { TOKEN_COOKIE_NAME, setAuthToken } from '../../lib/jwt'; import { FIRST_LOGIN_PARAM, TOKEN_COOKIE_NAME, setAuthToken } from '../../lib/jwt';
import { httpGet } from '../../lib/http'; import { httpGet } from '../../lib/http';
import { Spinner } from '../ReactIcons/Spinner.tsx'; import { Spinner } from '../ReactIcons/Spinner.tsx';
import { GoogleIcon } from '../ReactIcons/GoogleIcon.tsx'; import { GoogleIcon } from '../ReactIcons/GoogleIcon.tsx';
@ -8,7 +8,6 @@ import {
getStoredUtmParams, getStoredUtmParams,
triggerUtmRegistration, triggerUtmRegistration,
} from '../../lib/browser.ts'; } from '../../lib/browser.ts';
import { FIRST_LOGIN_TAG } from './TriggerVerifyAccount.tsx';
type GoogleButtonProps = { type GoogleButtonProps = {
isDisabled?: boolean; isDisabled?: boolean;
@ -82,7 +81,7 @@ export function GoogleButton(props: GoogleButtonProps) {
const url = new URL(redirectUrl, window.location.origin); const url = new URL(redirectUrl, window.location.origin);
if (response?.isNewUser) { if (response?.isNewUser) {
url.searchParams.set(FIRST_LOGIN_TAG, '1'); url.searchParams.set(FIRST_LOGIN_PARAM, '1');
} }
window.location.href = url.toString(); window.location.href = url.toString();
}) })

@ -1,11 +1,10 @@
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import { TOKEN_COOKIE_NAME, setAuthToken } from '../../lib/jwt'; import { FIRST_LOGIN_PARAM, TOKEN_COOKIE_NAME, setAuthToken } from '../../lib/jwt';
import { httpGet } from '../../lib/http'; import { httpGet } from '../../lib/http';
import { Spinner } from '../ReactIcons/Spinner.tsx'; import { Spinner } from '../ReactIcons/Spinner.tsx';
import { LinkedInIcon } from '../ReactIcons/LinkedInIcon.tsx'; import { LinkedInIcon } from '../ReactIcons/LinkedInIcon.tsx';
import { triggerUtmRegistration } from '../../lib/browser.ts'; import { triggerUtmRegistration } from '../../lib/browser.ts';
import { FIRST_LOGIN_TAG } from './TriggerVerifyAccount.tsx';
type LinkedInButtonProps = { type LinkedInButtonProps = {
isDisabled?: boolean; isDisabled?: boolean;
@ -77,7 +76,7 @@ export function LinkedInButton(props: LinkedInButtonProps) {
const url = new URL(redirectUrl, window.location.origin); const url = new URL(redirectUrl, window.location.origin);
if (response?.isNewUser) { if (response?.isNewUser) {
url.searchParams.set(FIRST_LOGIN_TAG, '1'); url.searchParams.set(FIRST_LOGIN_PARAM, '1');
} }
window.location.href = url.toString(); window.location.href = url.toString();
}) })

@ -1,13 +1,11 @@
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import { httpPost } from '../../lib/http'; import { httpPost } from '../../lib/http';
import { TOKEN_COOKIE_NAME, setAuthToken } from '../../lib/jwt'; import { FIRST_LOGIN_PARAM, TOKEN_COOKIE_NAME, setAuthToken } from '../../lib/jwt';
import { Spinner } from '../ReactIcons/Spinner'; import { Spinner } from '../ReactIcons/Spinner';
import { ErrorIcon2 } from '../ReactIcons/ErrorIcon2'; import { ErrorIcon2 } from '../ReactIcons/ErrorIcon2';
import { triggerUtmRegistration } from '../../lib/browser.ts'; import { triggerUtmRegistration } from '../../lib/browser.ts';
export const FIRST_LOGIN_TAG = 'fl' as const;
export function TriggerVerifyAccount() { export function TriggerVerifyAccount() {
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true);
const [error, setError] = useState(''); const [error, setError] = useState('');
@ -35,7 +33,7 @@ export function TriggerVerifyAccount() {
const url = new URL('/', window.location.origin); const url = new URL('/', window.location.origin);
if (response?.isNewUser) { if (response?.isNewUser) {
url.searchParams.set(FIRST_LOGIN_TAG, '1'); url.searchParams.set(FIRST_LOGIN_PARAM, '1');
} }
window.location.href = url.toString(); window.location.href = url.toString();
}) })

@ -6,12 +6,14 @@ import { RedditIcon } from '../ReactIcons/RedditIcon';
import { TwitterIcon } from '../ReactIcons/TwitterIcon'; import { TwitterIcon } from '../ReactIcons/TwitterIcon';
type ShareIconsProps = { type ShareIconsProps = {
resourceId: string;
resourceType: string;
pageUrl: string; pageUrl: string;
description: string; description: string;
}; };
export function ShareIcons(props: ShareIconsProps) { export function ShareIcons(props: ShareIconsProps) {
const { pageUrl, description } = props; const { pageUrl, description, resourceType, resourceId } = props;
const shareIconsRef = useRef<HTMLDivElement>(null); const shareIconsRef = useRef<HTMLDivElement>(null);
@ -73,7 +75,10 @@ export function ShareIcons(props: ShareIconsProps) {
ref={shareIconsRef} ref={shareIconsRef}
> >
<div className="sticky top-[100px] flex flex-col items-center gap-1.5"> <div className="sticky top-[100px] flex flex-col items-center gap-1.5">
{icons.map((icon, index) => ( {icons.map((icon, index) => {
const host = new URL(icon.url).host;
return (
<a <a
key={index} key={index}
href={icon.url} href={icon.url}
@ -85,14 +90,15 @@ export function ShareIcons(props: ShareIconsProps) {
onClick={() => { onClick={() => {
window.fireEvent({ window.fireEvent({
category: 'RoadmapShareLink', category: 'RoadmapShareLink',
action: 'Roadmap Share Link Clicked', action: `Share Roadmap / ${resourceType} / ${resourceId} / ${host}`,
label: icon.url, label: icon.url,
}); });
}} }}
> >
{icon.icon} {icon.icon}
</a> </a>
))} );
})}
</div> </div>
</div> </div>
); );

@ -3,6 +3,7 @@ import Cookies from 'js-cookie';
import type { AllowedOnboardingStatus } from '../api/user'; import type { AllowedOnboardingStatus } from '../api/user';
export const TOKEN_COOKIE_NAME = '__roadmapsh_jt__'; export const TOKEN_COOKIE_NAME = '__roadmapsh_jt__';
export const FIRST_LOGIN_PARAM = 'fl' as const;
export type TokenPayload = { export type TokenPayload = {
id: string; id: string;

@ -134,6 +134,8 @@ const projects = await getProjectsByRoadmapId(roadmapId);
<div class='container relative !max-w-[1000px]'> <div class='container relative !max-w-[1000px]'>
<ShareIcons <ShareIcons
resourceId={roadmapId}
resourceType='roadmap'
description={roadmapData.briefDescription} description={roadmapData.briefDescription}
pageUrl={`https://roadmap.sh/${roadmapId}`} pageUrl={`https://roadmap.sh/${roadmapId}`}
client:load client:load

@ -94,6 +94,8 @@ const ogImageUrl = getOpenGraphImageUrl({
!bestPracticeData.isUpcoming && bestPracticeData.jsonUrl && ( !bestPracticeData.isUpcoming && bestPracticeData.jsonUrl && (
<div class='container relative !max-w-[1000px]'> <div class='container relative !max-w-[1000px]'>
<ShareIcons <ShareIcons
resourceId={bestPracticeId}
resourceType='best-practice'
description={bestPracticeData.briefDescription} description={bestPracticeData.briefDescription}
pageUrl={`https://roadmap.sh/best-practices/${bestPracticeId}`} pageUrl={`https://roadmap.sh/best-practices/${bestPracticeId}`}
client:load client:load

Loading…
Cancel
Save