-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
129 lines (112 loc) · 3.27 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import { Stack, useRouter, useSearchParams } from "expo-router";
import { useCallback, useState } from "react";
import {
View,
Text,
SafeAreaView,
ScrollView,
ActivityIndicator,
RefreshControl,
} from "react-native";
import {
Company,
JobAbout,
JobFooter,
JobTabs,
ScreenHeaderBtn,
Specifics,
} from "../../components";
import { COLORS, icons, SIZES } from "../../constants";
import useFetch from "../../hook/useFetch";
const tabs = ["About", "Qualifications", "Responsibilities"];
const JobDetails = () => {
const params = useSearchParams();
const router = useRouter();
const { data, isLoading, error, refetch } = useFetch("job-details", {
job_id: params.id,
});
const [activeTab, setActiveTab] = useState(tabs[0]);
const [refreshing, setRefreshing] = useState(false);
const onRefresh = useCallback(() => {
setRefreshing(true);
refetch()
setRefreshing(false)
}, []);
const displayTabContent = () => {
switch (activeTab) {
case "Qualifications":
return (
<Specifics
title='Qualifications'
points={data[0].job_highlights?.Qualifications ?? ["N/A"]}
/>
);
case "About":
return (
<JobAbout info={data[0].job_description ?? "No data provided"} />
);
case "Responsibilities":
return (
<Specifics
title='Responsibilities'
points={data[0].job_highlights?.Responsibilities ?? ["N/A"]}
/>
);
default:
return null;
}
};
return (
<SafeAreaView style={{ flex: 1, backgroundColor: COLORS.lightWhite }}>
<Stack.Screen
options={{
headerStyle: { backgroundColor: COLORS.lightWhite },
headerShadowVisible: false,
headerBackVisible: false,
headerLeft: () => (
<ScreenHeaderBtn
iconUrl={icons.left}
dimension='60%'
handlePress={() => router.back()}
/>
),
headerRight: () => (
<ScreenHeaderBtn iconUrl={icons.share} dimension='60%' />
),
headerTitle: "",
}}
/>
<>
<ScrollView showsVerticalScrollIndicator={false}
refreshControl={
<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />}
>
{isLoading ? (
<ActivityIndicator size='large' color={COLORS.primary} />
) : error ? (
<Text>Something went wrong</Text>
) : data.length === 0 ? (
<Text>No data available</Text>
) : (
<View style={{ padding: SIZES.medium, paddingBottom: 100 }}>
<Company
companyLogo={data[0].employer_logo}
jobTitle={data[0].job_title}
companyName={data[0].employer_name}
location={data[0].job_country}
/>
<JobTabs
tabs={tabs}
activeTab={activeTab}
setActiveTab={setActiveTab}
/>
{displayTabContent()}
</View>
)}
</ScrollView>
<JobFooter url={data[0]?.job_google_link ?? 'https://careers.google.com/jobs/results/'} />
</>
</SafeAreaView>
);
};
export default JobDetails;