-
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
Suraj Auwal
committed
Nov 25, 2023
1 parent
4d41e68
commit 49a8f0d
Showing
10 changed files
with
111 additions
and
19 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
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
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
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
65 changes: 65 additions & 0 deletions
65
mobile-app/screens/AppNavigator/SettingsNavigator/screens/NotificationSettings.tsx
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,65 @@ | ||
import {View, Text} from "react-native"; | ||
import {getColor, tailwind} from "@tailwind"; | ||
import {useEffect, useState} from "react"; | ||
import {LoaderComponentScreen} from "@components/commons/LoaderComponent"; | ||
import {_api} from "@api/_request"; | ||
import {showTost} from "@components/commons/Toast"; | ||
import {useToast} from "react-native-toast-notifications"; | ||
import {GoBackButton} from "@screens/AppNavigator/SettingsNavigator/components/Goback"; | ||
import {useNavigation} from "@react-navigation/native"; | ||
import Checkbox from "expo-checkbox"; | ||
|
||
export const NotificationSettings = () => { | ||
const [loading, setLoading] = useState(true) | ||
const [listingNotification, setListingNotification] = useState<boolean | undefined>(undefined) | ||
const toast = useToast() | ||
const navigation = useNavigation() | ||
useEffect(() => { | ||
|
||
void fetchSettings() | ||
}, []) | ||
const saveSettings = () => { | ||
setListingNotification((prev) => !prev) | ||
} | ||
async function fetchSettings (): Promise<void> { | ||
try { | ||
const scheduledListingsNotifications = (await _api.requestData({ | ||
method: 'GET', | ||
url: 'vendor/subscription' | ||
})).data as any | ||
setListingNotification(scheduledListingsNotifications.enabledByVendor) | ||
} catch (error) { | ||
showTost(toast, 'something went wrong fetching settings', 'error') | ||
} finally { | ||
setLoading(false) | ||
} | ||
|
||
} | ||
|
||
if(loading) { | ||
return <LoaderComponentScreen /> | ||
} | ||
|
||
return ( | ||
<View style={tailwind('flex-1 bg-white')}> | ||
<View style={tailwind('px-5 pt-4')}> | ||
<GoBackButton onPress={() => navigation.goBack()} /> | ||
<View style={tailwind('mt-4')}> | ||
<View style={tailwind('flex flex-row items-center justify-between w-full')}> | ||
<View style={tailwind('w-2/3')}> | ||
<Text style={tailwind('font-medium text-base text-brand-black-500')}>Allow users to subscribe to a new listing</Text> | ||
<Text style={tailwind('font-normal my-1 text-xs text-brand-gray-700')}>This will allow customers to subscribe to your restaurant and get notified when ever you make a new listing</Text> | ||
<Text style={tailwind('font-normal text-xs text-warning-500')}>Is only available for Vendors with pre-order delivery</Text> | ||
</View> | ||
<Checkbox | ||
style={tailwind('m-2 p-3')} | ||
onValueChange={saveSettings} | ||
value={listingNotification} | ||
color={listingNotification ? getColor('black') : undefined} | ||
/> | ||
</View> | ||
</View> | ||
</View> | ||
</View> | ||
) | ||
} |
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