Skip to content

Commit

Permalink
use backend support for whether onboarding seen
Browse files Browse the repository at this point in the history
  • Loading branch information
SheepTester committed Nov 5, 2024
1 parent 1282c47 commit 0e0a00e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/lib/types/apiRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export interface UserPatches {
graduationYear?: number;
bio?: string;
isAttendancePublic?: boolean;
onboardingSeen?: boolean;
passwordChange?: PasswordUpdate;
}

Expand Down
1 change: 1 addition & 0 deletions src/lib/types/apiResponses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ export interface PrivateProfile extends PublicProfile {
state: UserState;
credits: number;
resumes?: PublicResume[];
onboardingSeen: boolean;
}

export interface PublicFeedback {
Expand Down
6 changes: 1 addition & 5 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@ const PortalHomePage = ({
// Start onboarding after checking in
// TEMP: This should be saved server-side in the future
// Do not start onboarding if user already attended other events
if (attendance.length > 1) {
return;
}
const onboardingState = localStorage.getItem(config.tempLocalOnboardingKey);
if (onboardingState === 'onboarded') {
if (user.onboardingSeen) {
return;
}
router.push(
Expand Down
9 changes: 6 additions & 3 deletions src/pages/onboard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { OnboardingScreen } from '@/components/onboarding';
import { config } from '@/lib';
import { UserAPI } from '@/lib/api';
import withAccessType, { GetServerSidePropsWithAuth } from '@/lib/hoc/withAccessType';
import { PermissionService } from '@/lib/services';
import { URL } from '@/lib/types';
Expand All @@ -9,10 +10,11 @@ import { useRouter } from 'next/router';

interface OnboardProps {
destination: URL;
authToken: string;
user: PrivateProfile;
}

const OnboardPage: NextPage<OnboardProps> = ({ user, destination }) => {
const OnboardPage: NextPage<OnboardProps> = ({ authToken, user, destination }) => {
const router = useRouter();

const handleExit = () => {
Expand All @@ -25,7 +27,7 @@ const OnboardPage: NextPage<OnboardProps> = ({ user, destination }) => {
user={user}
onDismiss={handleExit}
onFinish={() => {
localStorage.setItem(config.tempLocalOnboardingKey, 'onboarded');
UserAPI.updateCurrentUserProfile(authToken, { onboardingSeen: true });
}}
/>
</div>
Expand All @@ -34,12 +36,13 @@ const OnboardPage: NextPage<OnboardProps> = ({ user, destination }) => {

export default OnboardPage;

const getServerSidePropsFunc: GetServerSidePropsWithAuth = async ({ query }) => {
const getServerSidePropsFunc: GetServerSidePropsWithAuth = async ({ query, authToken }) => {
const route = query?.destination ? decodeURIComponent(query?.destination as string) : null;

return {
props: {
destination: route || config.homeRoute,
authToken,
quietNavbar: true,
},
};
Expand Down

0 comments on commit 0e0a00e

Please sign in to comment.