Skip to content

Commit 582bf1b

Browse files
committed
🖌️ User Interface: for near by jobs, list
1 parent eb3d878 commit 582bf1b

File tree

6 files changed

+86
-16
lines changed

6 files changed

+86
-16
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ web-build/
1212

1313
# macOS
1414
.DS_Store
15+
.env
Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
11
import React from 'react'
2-
import { View, Text } from 'react-native'
2+
import { View, Text, TouchableOpacity, Image } from 'react-native'
3+
import { checkImageURL } from '../../../../utils'
34

45
import styles from './nearbyjobcard.style'
56

6-
const NearbyJobCard = () => {
7+
const NearbyJobCard = ({ job, handleNavigate }) => {
8+
79
return (
8-
<View>
9-
<Text>NearbyJobCard</Text>
10-
</View>
10+
<TouchableOpacity
11+
style={styles.container}
12+
onPress={() => handleNavigate}
13+
>
14+
<TouchableOpacity style={styles.logoContainer}>
15+
<Image
16+
source={{
17+
uri: checkImageURL(job.employer_logo) ? job.employer_logo : 'https://dummyimage.com/600x400/000/fff',
18+
}}
19+
resizeMode='contain'
20+
style={styles.logImage}
21+
/>
22+
</TouchableOpacity>
23+
<View style={styles.textContainer}>
24+
<Text
25+
style={styles.jobName}
26+
numberOfLines={1}
27+
>{job?.job_title}</Text>
28+
<Text style={styles.jobType}>{job?.job_employment_type}</Text>
29+
</View>
30+
</TouchableOpacity>
1131
)
1232
}
1333

14-
export default NearbyJobCard
34+
export default NearbyJobCard

components/common/cards/popular/PopularJobCard.jsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react'
22
import { View, Text, TouchableOpacity, Image } from 'react-native'
3+
import { checkImageURL } from '../../../../utils'
34

45
import styles from './popularjobcard.style'
56

@@ -10,11 +11,23 @@ const PopularJobCard = ({ item, selectedJob, handleCardPress }) => {
1011
onPress={() => handleCardPress(item)}
1112
>
1213
<TouchableOpacity style={styles.logoContainer(selectedJob, item)}>
13-
<Image source={{ uri: item?.employer_logo }} resizeMode='contain' style={styles.logoImage} />
14+
<Image
15+
source={{
16+
uri: checkImageURL(item.employer_logo) ? item.employer_logo : 'https://dummyimage.com/600x400/000/fff',
17+
}}
18+
resizeMode='contain'
19+
style={styles.logoImage}
20+
/>
1421
</TouchableOpacity>
15-
<Text style={styles.companyName} numberOfLines={1}>{item?.employer_name}</Text>
22+
<Text
23+
style={styles.companyName}
24+
numberOfLines={1}
25+
>{item?.employer_name}</Text>
1626
<View style={styles.infoContainer}>
17-
<Text style={styles.jobName(selectedJob, item)} numberOfLines={1}>{item?.job_title}</Text>
27+
<Text
28+
style={styles.jobName(selectedJob, item)}
29+
numberOfLines={1}
30+
>{item?.job_title}</Text>
1831
<Text style={styles.location}>{item?.job_country}</Text>
1932
</View>
2033
</TouchableOpacity>

components/home/nearby/Nearbyjobs.jsx

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,44 @@
1-
import React from 'react'
2-
import { View, Text } from 'react-native'
1+
import React, { useState } from 'react'
2+
import { View, Text, ActivityIndicator, TouchableOpacity } from 'react-native'
3+
import { COLORS, SIZES } from '../../../constants'
4+
import NearbyJobCard from '../../common/cards/nearby/NearbyJobCard'
5+
6+
import { useRouter } from 'expo-router'
7+
import useFetch from '../../../hook/useFetch'
38

49
import styles from './nearbyjobs.style'
510

611
const Nearbyjobs = () => {
12+
const router = useRouter();
13+
const { data, isLoading, error, refetch } = useFetch('search', {
14+
query: 'Python developer in Kolkata, India',
15+
page: '1',
16+
num_pages: '1'
17+
})
18+
719
return (
8-
<View>
9-
<Text>Nearbyjobs</Text>
20+
<View style={styles.container}>
21+
<View style={styles.header}>
22+
<Text style={styles.headerTitle}>Near By Jobs</Text>
23+
<TouchableOpacity><Text style={styles.headerBtn}>Show all</Text></TouchableOpacity>
24+
</View>
25+
<View style={styles.cardsContainer}>
26+
{isLoading ? (
27+
<ActivityIndicator size="large" color={COLORS.primary} />
28+
) : error ? (
29+
<Text>Something went worng</Text>
30+
) : (
31+
data?.map((job) => (
32+
<NearbyJobCard
33+
job={job}
34+
key={`nearby-${job?.job_id}`}
35+
handleNavigate={() => router.push(`/job-details/${job?.job_id}`)}
36+
/>
37+
))
38+
)}
39+
</View>
1040
</View>
1141
)
1242
}
1343

14-
export default Nearbyjobs
44+
export default Nearbyjobs;

components/home/popular/Popularjobs.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ const Popularjobs = () => {
1515
page: '1',
1616
num_pages: '1'
1717
})
18-
console.log(data)
19-
2018

2119
return (
2220
<View style={styles.container}>

utils/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export const checkImageURL = (url) => {
2+
if (!url) return false;
3+
else {
4+
const pattern = new RegExp('^https?:\\/\\/.+\\.(png|jpg|jpeg|bmp|gif|webp)$', 'i');
5+
return pattern.test(url);
6+
}
7+
}
8+

0 commit comments

Comments
 (0)