|
@@ -9,7 +9,8 @@ import { Colors } from 'src/theme';
|
|
|
import { styles } from './styles';
|
|
|
import { NAVIGATION_PAGES } from 'src/types';
|
|
|
import { API_HOST } from 'src/constants';
|
|
|
-import { Loading } from 'src/components';
|
|
|
+import { Loading, WarningModal } from 'src/components';
|
|
|
+import { StoreType, storage } from 'src/storage';
|
|
|
|
|
|
const SearchModal = ({
|
|
|
searchVisible,
|
|
@@ -17,7 +18,8 @@ const SearchModal = ({
|
|
|
handleFindRegion,
|
|
|
index,
|
|
|
searchData,
|
|
|
- setIndex
|
|
|
+ setIndex,
|
|
|
+ token
|
|
|
}: {
|
|
|
searchVisible: boolean;
|
|
|
handleCloseModal: () => void;
|
|
@@ -25,6 +27,7 @@ const SearchModal = ({
|
|
|
index: number;
|
|
|
searchData: any;
|
|
|
setIndex: (index: number) => void;
|
|
|
+ token: string | undefined;
|
|
|
}) => {
|
|
|
const navigation = useNavigation();
|
|
|
const [routes] = useState([
|
|
@@ -33,6 +36,7 @@ const SearchModal = ({
|
|
|
{ key: 'dare', title: 'Places' }
|
|
|
]);
|
|
|
const [shouldOpenModal, setShouldOpenModal] = useState<{ id: number; type: string } | null>(null);
|
|
|
+ const [warningVisible, setWarningVisible] = useState(false);
|
|
|
|
|
|
const renderItem = ({ item }: { item: any }) => {
|
|
|
const name = item.name?.split(/ – | - /);
|
|
@@ -41,10 +45,14 @@ const SearchModal = ({
|
|
|
<TouchableOpacity
|
|
|
style={{ paddingVertical: 12 }}
|
|
|
onPress={() => {
|
|
|
- handleCloseModal();
|
|
|
- navigation.navigate(
|
|
|
- ...([NAVIGATION_PAGES.PUBLIC_PROFILE_VIEW, { userId: item.id }] as never)
|
|
|
- );
|
|
|
+ if (!token) {
|
|
|
+ setWarningVisible(true);
|
|
|
+ } else {
|
|
|
+ handleCloseModal();
|
|
|
+ navigation.navigate(
|
|
|
+ ...([NAVIGATION_PAGES.PUBLIC_PROFILE_VIEW, { userId: item.id }] as never)
|
|
|
+ );
|
|
|
+ }
|
|
|
}}
|
|
|
>
|
|
|
<View style={styles.container}>
|
|
@@ -122,6 +130,12 @@ const SearchModal = ({
|
|
|
) : (
|
|
|
<Loading />
|
|
|
)}
|
|
|
+ <WarningModal
|
|
|
+ type="unauthorized"
|
|
|
+ isVisible={warningVisible}
|
|
|
+ onClose={() => setWarningVisible(false)}
|
|
|
+ action={handleCloseModal}
|
|
|
+ />
|
|
|
</View>
|
|
|
);
|
|
|
};
|