-
Notifications
You must be signed in to change notification settings - Fork 0
feat(jobOffer): job offer view and apply #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,124 @@ | ||
| import { useLocales } from 'expo-localization'; | ||
| import { FC, useCallback } from 'react'; | ||
| import { Alert, StyleSheet, View } from 'react-native'; | ||
| import { Button, Text, useTheme } from 'react-native-paper'; | ||
| import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'; | ||
|
|
||
| import { JobOffer } from '@/models/entities/jobOffer'; | ||
| import { usePostApplyJobOfferMutation } from '@/store/api/jobOfferApiSlice'; | ||
| import i18n from '@/utils/i18n'; | ||
|
|
||
| /** | ||
| * The styles for the JobOfferContent component. | ||
| */ | ||
| const styles = StyleSheet.create({ | ||
| button: { | ||
| width: 200, | ||
| }, | ||
| container: { | ||
| gap: 16, | ||
| }, | ||
| horizontalContainer: { | ||
| flexDirection: 'row', | ||
| gap: 12, | ||
| }, | ||
| sectionContainer: { | ||
| gap: 8, | ||
| }, | ||
| verticalCentered: { | ||
| alignItems: 'center', | ||
| flexDirection: 'column', | ||
| }, | ||
| }); | ||
|
|
||
| /** | ||
| * The props for the JobOfferContent component. | ||
| */ | ||
| type JobOfferContentProps = { | ||
thomas-mauran marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /** | ||
| * The job offer to display. | ||
| */ | ||
| jobOffer: JobOffer; | ||
| }; | ||
|
|
||
| /** | ||
| * Displays the details about a job offer. | ||
| * @constructor | ||
| */ | ||
| const JobOfferContent: FC<JobOfferContentProps> = ({ jobOffer }) => { | ||
thomas-mauran marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // API calls | ||
| const [applyToJobOffer] = usePostApplyJobOfferMutation(); | ||
|
|
||
| // Hooks | ||
| const locales = useLocales(); | ||
| const theme = useTheme(); | ||
|
|
||
| // Callbacks | ||
| const handleApplyToJobOffer = useCallback( | ||
| (jobOffer: JobOffer) => { | ||
| Alert.alert( | ||
| i18n.t('jobOffer.apply.applyTitle'), | ||
| i18n.t('jobOffer.apply.applyConfirm'), | ||
| [ | ||
| { | ||
| text: i18n.t('common.cancel'), | ||
| style: 'cancel', | ||
| }, | ||
| { | ||
| text: i18n.t('common.confirm'), | ||
| onPress: () => applyToJobOffer(jobOffer.id), | ||
| style: 'destructive', | ||
| }, | ||
| ], | ||
| ); | ||
| }, | ||
| [applyToJobOffer], | ||
| ); | ||
|
|
||
| return ( | ||
| <View style={styles.container}> | ||
| <View style={styles.sectionContainer}> | ||
| <Text variant='titleLarge'>{`${jobOffer.title}`}</Text> | ||
| <View style={styles.sectionContainer}> | ||
| <View style={styles.horizontalContainer}> | ||
| <MaterialCommunityIcons | ||
| name='calendar' | ||
| size={24} | ||
| style={{ color: theme.colors.onSurface }} | ||
| /> | ||
| <Text variant='labelLarge'> | ||
| {`${new Date(jobOffer.startDate).toLocaleDateString( | ||
| locales[0].languageTag, | ||
| )} - ${new Date(jobOffer.endDate).toLocaleDateString( | ||
| locales[0].languageTag, | ||
| )}`} | ||
| </Text> | ||
| </View> | ||
|
|
||
| <View style={styles.horizontalContainer}> | ||
| <MaterialCommunityIcons | ||
| name='map-marker' | ||
| size={24} | ||
| style={{ color: theme.colors.onSurface }} | ||
| /> | ||
| <Text variant='labelLarge'>{`${jobOffer.geographicArea}`}</Text> | ||
| </View> | ||
| </View> | ||
| </View> | ||
|
|
||
| <Text>{`${jobOffer.description}`}</Text> | ||
|
|
||
| <View style={styles.verticalCentered}> | ||
| <Button | ||
| mode={'contained-tonal'} | ||
| style={styles.button} | ||
| onPress={() => handleApplyToJobOffer(jobOffer)} | ||
| > | ||
| {i18n.t('jobOffer.apply.apply')} | ||
| </Button> | ||
| </View> | ||
| </View> | ||
| ); | ||
| }; | ||
|
|
||
| export default JobOfferContent; | ||
This file contains hidden or 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 hidden or 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 hidden or 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,71 @@ | ||
| import { useFocusEffect } from '@react-navigation/native'; | ||
| import { NativeStackScreenProps } from '@react-navigation/native-stack'; | ||
| import { FC, useCallback } from 'react'; | ||
| import { ScrollView, StyleSheet } from 'react-native'; | ||
|
|
||
| import JobOfferList from '@/components/jobOffers/JobOfferList'; | ||
| import { JobOffer } from '@/models/entities/jobOffer'; | ||
| import { useGetJobOffersQuery } from '@/store/api/jobOfferApiSlice'; | ||
|
|
||
| import { JobOfferStackParamList } from './JobOfferNav'; | ||
|
|
||
| /** | ||
| * The styles for the JobOfferListPage component. | ||
| */ | ||
| const styles = StyleSheet.create({ | ||
thomas-mauran marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| container: { | ||
| flex: 1, | ||
| }, | ||
| contentContainer: { | ||
| gap: 8, | ||
| paddingBottom: 8, | ||
| paddingHorizontal: 16, | ||
| }, | ||
| }); | ||
|
|
||
| /** | ||
| * The props for the JobOfferListPage component. | ||
| */ | ||
| type JobOfferListPageProps = NativeStackScreenProps< | ||
| JobOfferStackParamList, | ||
| 'JobOfferList' | ||
| >; | ||
|
|
||
| /** | ||
| * Displays the page of job offers for the current user. | ||
| * @constructor | ||
| */ | ||
| const JobOfferListPage: FC<JobOfferListPageProps> = ({ navigation }) => { | ||
| // API calls | ||
| const { data: jobOffers, refetch: refetchJobOffers } = useGetJobOffersQuery(); | ||
|
|
||
| // Callbacks | ||
| const handleJobOfferPress = useCallback( | ||
| (jobOffer: JobOffer) => { | ||
| navigation.navigate('JobOffer', { id: jobOffer.id }); | ||
| }, | ||
| [navigation], | ||
| ); | ||
|
|
||
| // Fetch data from the API when the page is focused | ||
| useFocusEffect( | ||
| useCallback(() => { | ||
| refetchJobOffers(); | ||
| }, [refetchJobOffers]), | ||
| ); | ||
|
|
||
| if (jobOffers === undefined) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <ScrollView | ||
| style={styles.container} | ||
| contentContainerStyle={styles.contentContainer} | ||
| > | ||
| <JobOfferList onItemPress={handleJobOfferPress} jobOffers={jobOffers} /> | ||
| </ScrollView> | ||
| ); | ||
| }; | ||
|
|
||
| export default JobOfferListPage; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.