-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
218 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,32 @@ | ||
import React from 'react' | ||
import { View, Text } from 'react-native' | ||
import { View, Text, TouchableOpacity, Image } from "react-native"; | ||
|
||
import styles from './nearbyjobcard.style' | ||
import styles from "./nearbyjobcard.style"; | ||
import { checkImageURL } from "../../../../utils"; | ||
|
||
const NearbyJobCard = () => { | ||
const NearbyJobCard = ({ job, handleNavigate }) => { | ||
return ( | ||
<View> | ||
<Text>NearbyJobCard</Text> | ||
</View> | ||
) | ||
} | ||
<TouchableOpacity style={styles.container} onPress={handleNavigate}> | ||
<TouchableOpacity style={styles.logoContainer}> | ||
<Image | ||
source={{ | ||
uri: checkImageURL(job.employer_logo) | ||
? job.employer_logo | ||
: "https://t4.ftcdn.net/jpg/05/05/61/73/360_F_505617309_NN1CW7diNmGXJfMicpY9eXHKV4sqzO5H.jpg", | ||
}} | ||
resizeMode="contain" | ||
style={styles.logImage} | ||
/> | ||
</TouchableOpacity> | ||
|
||
export default NearbyJobCard | ||
<View style={styles.textContainer}> | ||
<Text style={styles.jobName} numberOfLines={1}> | ||
{job?.job_title} | ||
</Text> | ||
|
||
<Text style={styles.jobType}>{job?.job_employment_type}</Text> | ||
</View> | ||
</TouchableOpacity> | ||
); | ||
}; | ||
|
||
export default NearbyJobCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,42 @@ | ||
import React from 'react' | ||
import { View, Text } from 'react-native' | ||
import { View, Text, TouchableOpacity, Image } from "react-native"; | ||
|
||
import styles from './popularjobcard.style' | ||
import styles from "./popularjobcard.style"; | ||
import { checkImageURL } from "../../../../utils"; | ||
|
||
const PopularJobCard = () => { | ||
const PopularJobCard = ({ item, selectedJob, handleCardPress }) => { | ||
return ( | ||
<View> | ||
<Text>PopularJobCard</Text> | ||
</View> | ||
) | ||
} | ||
<TouchableOpacity | ||
style={styles.container(selectedJob, item)} | ||
onPress={() => handleCardPress(item)} | ||
> | ||
<TouchableOpacity style={styles.logoContainer(selectedJob, item)}> | ||
<Image | ||
source={{ | ||
uri: checkImageURL(item?.employer_logo) | ||
? item.employer_logo | ||
: "https://t4.ftcdn.net/jpg/05/05/61/73/360_F_505617309_NN1CW7diNmGXJfMicpY9eXHKV4sqzO5H.jpg", | ||
}} | ||
resizeMode="contain" | ||
style={styles.logoImage} | ||
/> | ||
</TouchableOpacity> | ||
<Text style={styles.companyName} numberOfLines={1}> | ||
{item.employer_name} | ||
</Text> | ||
|
||
export default PopularJobCard | ||
<View style={styles.infoContainer}> | ||
<Text style={styles.jobName(selectedJob, item)} numberOfLines={1}> | ||
{item.job_title} | ||
</Text> | ||
<View style={styles.infoWrapper}> | ||
<Text style={styles.publisher(selectedJob, item)}> | ||
{item?.job_publisher} - | ||
</Text> | ||
<Text style={styles.location}> {item.job_country}</Text> | ||
</View> | ||
</View> | ||
</TouchableOpacity> | ||
); | ||
}; | ||
|
||
export default PopularJobCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,45 @@ | ||
import React from 'react' | ||
import { View, Text } from 'react-native' | ||
import React from "react"; | ||
import { useRouter } from "expo-router"; | ||
import { View, Text, TouchableOpacity, ActivityIndicator } from "react-native"; | ||
|
||
import styles from './nearbyjobs.style' | ||
import styles from "./nearbyjobs.style"; | ||
import { COLORS } from "../../../constants"; | ||
import NearbyJobCard from "../../common/cards/nearby/NearbyJobCard"; | ||
import useFetch from "../../../hook/useFetch"; | ||
|
||
const Nearbyjobs = () => { | ||
const router = useRouter(); | ||
const { data, isLoading, error } = useFetch("search", { | ||
query: "React Native developer", | ||
num_pages: "1", | ||
}); | ||
|
||
return ( | ||
<View> | ||
<Text>Nearbyjobs</Text> | ||
<View style={styles.container}> | ||
<View style={styles.header}> | ||
<Text style={styles.headerTitle}>Nearby jobs</Text> | ||
<TouchableOpacity> | ||
<Text style={styles.headerBtn}>Show all</Text> | ||
</TouchableOpacity> | ||
</View> | ||
|
||
<View style={styles.cardsContainer}> | ||
{isLoading ? ( | ||
<ActivityIndicator size="large" color={COLORS.primary} /> | ||
) : error ? ( | ||
<Text>Something went wrong</Text> | ||
) : ( | ||
data?.map((job) => ( | ||
<NearbyJobCard | ||
job={job} | ||
key={`nearby-job-${job.job_id}`} | ||
handleNavigate={() => router.push(`/job-details/${job.job_id}`)} | ||
/> | ||
)) | ||
)} | ||
</View> | ||
</View> | ||
) | ||
} | ||
); | ||
}; | ||
|
||
export default Nearbyjobs | ||
export default Nearbyjobs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { useState, useEffect } from "react"; | ||
import axios from "axios"; | ||
|
||
const useFetch = (endpoint, query) => { | ||
const [data, setData] = useState([]); | ||
const [isLoading, setIsLoading] = useState(false); | ||
const [error, setError] = useState(null); | ||
|
||
const options = { | ||
method: "GET", | ||
url: `https://jsearch.p.rapidapi.com/${endpoint}`, | ||
headers: { | ||
"X-RapidAPI-Key": "8cf63f2becmsh2707d400616d579p10792ajsn93584592bd9d", | ||
"X-RapidAPI-Host": "jsearch.p.rapidapi.com", | ||
}, | ||
params: { ...query }, | ||
}; | ||
|
||
const fetchData = async () => { | ||
setIsLoading(true); | ||
|
||
try { | ||
const response = await axios.request(options); | ||
|
||
setData(response.data.data); | ||
setIsLoading(false); | ||
} catch (error) { | ||
setError(error); | ||
console.log(error); | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
fetchData(); | ||
}, []); | ||
|
||
const refetch = () => { | ||
setIsLoading(true); | ||
fetchData(); | ||
}; | ||
|
||
return { data, isLoading, error, refetch }; | ||
}; | ||
|
||
export default useFetch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export const checkImageURL = (url) => { | ||
if (!url) return false; | ||
else { | ||
const pattern = new RegExp( | ||
"^https?:\\/\\/.+\\.(png|jpg|jpeg|bmp|gif|webp)$", | ||
"i" | ||
); | ||
return pattern.test(url); | ||
} | ||
}; |