Skip to content

Commit

Permalink
fix: partial persona generation issue resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
DOOduneye committed Nov 29, 2023
1 parent 33bf8a1 commit a06794e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions client-new/src/contexts/ProfileContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ export const ProfileProvider: React.FC<ProfileProviderProps> = ({
const toggleOnboarding = useCallback(async (): Promise<void> => {
if (!profile) return;


try {
console.log('[profile context] toggle onboarding profile (prev)', profile)
const profileRespnse = await updateOnboardingToComplete(profile.id);
setCompletedOnboarding(true)
setCompletedOnboarding(profileRespnse.completed_onboarding_response)
await setItemAsync('profile', JSON.stringify(profileRespnse));
await setItemAsync('completedOnboarding', JSON.stringify(true));
await setItemAsync('completedOnboarding', JSON.stringify(profileRespnse?.completed_onboarding_response || false))
} catch (error) {
console.error(`Error setting onboarding to complete in profile:`, error);
// Handle error - show message or perform recovery action
Expand Down
2 changes: 1 addition & 1 deletion client-new/src/contexts/UserContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const UserProvider: React.FC<UserProviderProps> = ({ children }) => {
fetchProfile(userData.data.id);
setUser(userData.data);
setFirebaseUser(user);
setCompletedOnboarding(profile.completed_onboarding_response);
setCompletedOnboarding(profile?.completed_onboarding_response || false);
console.log('[user context] userData', completedOnboarding)
// Uncomment to store user data
setItemAsync('firebaseUser', JSON.stringify(user));
Expand Down
3 changes: 2 additions & 1 deletion client-new/src/navigation/OnboardingStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ export default function OnboardingStack() {
<Stack.Navigator
initialRouteName={'Sign Up Transition Screen'}
screenOptions={{
headerShown: false
headerShown: false,
}}

>
<Stack.Screen
name="Questionaire Screen"
Expand Down
2 changes: 1 addition & 1 deletion client-new/src/screens/auth/PersonaScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const PersonaScreen = ({ route, navigation }) => {
const { page, setPage, onboardingState, onboardingFlow } = useOnboarding();

const { user } = useUser();
const { profile, fetchProfile, completeOnboarding, toggleOnboarding } = useProfile();
const { completeOnboarding, toggleOnboarding } = useProfile();
const [persona, setPersona] = useState<IPersona>(null);

const requestOnboarding = convertNumericToString(onboardingState);
Expand Down
2 changes: 2 additions & 0 deletions client-new/src/services/ProfileService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { IProfile } from '../interfaces/IProfile';
import { API_BASE_URL } from '@/services/const';

export const getProfile = async (user_id: string) => {
console.log('[profile service] fetching profile', `${API_BASE_URL}/users/${user_id}/profile`)
const response = await axios.get(`${API_BASE_URL}/users/${user_id}/profile`);
return response.data as IProfile;
};
Expand Down Expand Up @@ -37,6 +38,7 @@ export const insertOnboardingResponse = async (
export const updateOnboardingToComplete = async (
profile_id: number,
): Promise<IProfile> => {
console.log('[profile service] updating onboarding to complete', `${API_BASE_URL}/profiles/complete/${profile_id}`)
const response = await axios.patch(`${API_BASE_URL}/profiles/complete/${profile_id}`);
return response.data;
}

0 comments on commit a06794e

Please sign in to comment.