Skip to content

Commit 7ee04e6

Browse files
authored
ft-upload view trainee resume (#77)
1 parent 47b5fcd commit 7ee04e6

File tree

10 files changed

+448
-30
lines changed

10 files changed

+448
-30
lines changed

Diff for: .env.example

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
EXPO_PUBLIC_APOLLO_CLIENT_URI=""
2-
COVERALLS_REPO_TOKEN=""
2+
COVERALLS_REPO_TOKEN=""
3+
RESUME_URL=""

Diff for: app/dashboard/Resume/Resume.tsx

-11
This file was deleted.

Diff for: app/dashboard/trainee/profile/edit.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Resume from '@/app/dashboard/Resume/Resume';
1+
import Resume from '@/components/Resume';
22
import ProfileAvatar from '@/components/ProfileAvatar';
33
import { COUNTRIES } from '@/constants/countries';
44
import { UPDATE_PROFILE } from '@/graphql/mutations/UpdateProfile.mutation';

Diff for: app/dashboard/trainee/profile/index.tsx

+47-6
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import ProfileAvatar from '@/components/ProfileAvatar';
88
import AboutTrainee from '@/components/trainee/About';
99
import ProfileAccountTab from '@/components/trainee/Account';
1010
import TraineeOrg from '@/components/trainee/Organisation';
11-
import { GET_PROFILE } from '@/graphql/queries/user';
11+
import {GET_PROFILE, GET_TRAINEE_PROFILE } from '@/graphql/queries/user';
1212
import { useQuery } from '@apollo/client';
1313
import { Ionicons } from '@expo/vector-icons';
1414
import AsyncStorage from '@react-native-async-storage/async-storage';
15-
import { useRouter } from 'expo-router';
15+
import { router, useLocalSearchParams, useRouter } from 'expo-router';
1616
import { useToast } from 'react-native-toast-notifications';
1717

1818
type TabKey = 'About' | 'Organisation' | 'Account';
@@ -32,7 +32,8 @@ export default function Profile() {
3232
const handleTypeChange = (type: string) => {
3333
setSelectedType(type as TabKey);
3434
};
35-
35+
const [orgToken, setOrgToken] = useState<string | null>(null);
36+
const [traineeProfile, setTraineeProfile] = useState<any>({});
3637
const accountPasswordUpdated = () => {
3738
setSelectedType('About');
3839
};
@@ -66,12 +67,52 @@ export default function Profile() {
6667
setProfile(data.getProfile);
6768
}
6869
}, [data]);
70+
71+
useEffect(() => {
72+
const fetchOrgToken = async () => {
73+
try {
74+
const orgToken = await AsyncStorage.getItem('orgToken');
75+
if (orgToken) {
76+
setOrgToken(orgToken);
77+
} else {
78+
toast.show('Token Not found.', { type: 'danger', placement: 'top', duration: 3000 });
79+
}
80+
} catch (error) {
81+
toast.show('Failed to retrieve token.', { type: 'danger', placement: 'top', duration: 3000 });
82+
}
83+
};
84+
fetchOrgToken();
85+
}, []);
86+
87+
const { data: traineedata, error: err } = useQuery(GET_TRAINEE_PROFILE, {
88+
context: {
89+
headers: {
90+
Authorization: `Bearer ${userToken}`,
91+
},
92+
},
93+
skip: !userToken,
94+
variables: {
95+
orgToken: orgToken,
96+
},
97+
});
98+
99+
useEffect(() => {
100+
if (err) {
101+
toast.show(`Error fetching profile.${err}` , { type: 'danger', placement: 'top', duration: 3000 });
102+
}
103+
}, [err]);
104+
105+
useEffect(() => {
106+
if (traineedata) {
107+
setTraineeProfile(traineedata.getProfile);
108+
}
109+
}, [traineedata]);
69110

70111
return (
71112
<View>
72113
<View className="relative h-48">
73-
<CoverImage cover={profile?.cover} name={profile?.name} />
74-
<TouchableOpacity className="absolute bottom-1 right-4 rounded-full shadow-md">
114+
<CoverImage cover={profile?.cover} name={profile?.name} />
115+
<TouchableOpacity onPress={() => router.push('/dashboard/trainee/profile/edit')} className="absolute bottom-1 right-4 rounded-full shadow-md">
75116
<SvgXml xml={editBG} />
76117
</TouchableOpacity>
77118

@@ -116,7 +157,7 @@ export default function Profile() {
116157
className="mt-4 w-[100%] flex-grow"
117158
>
118159
{selectedType === 'About' && (
119-
<AboutTrainee profile={profile} bgColor={bgColor} textColor={textColor} />
160+
<AboutTrainee profile={profile} Resume={traineeProfile} bgColor={bgColor} textColor={textColor} />
120161
)}
121162

122163
{selectedType === 'Organisation' && (

Diff for: babel.config.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ module.exports = function (api) {
22
api.cache(true);
33
return {
44
presets: [['babel-preset-expo', { jsxImportSource: 'nativewind' }], 'nativewind/babel'],
5-
plugins: ['react-native-reanimated/plugin'],
5+
plugins: ['react-native-reanimated/plugin',
6+
7+
["module:react-native-dotenv", {
8+
moduleName: "@env",
9+
path: ".env",
10+
blacklist: null,
11+
whitelist: null,
12+
safe: false,
13+
allowUndefined: true
14+
}]
15+
],
616
};
717
};

0 commit comments

Comments
 (0)