Skip to content

Commit

Permalink
added search bar functions
Browse files Browse the repository at this point in the history
  • Loading branch information
aasimdag committed Apr 30, 2024
1 parent 37f3efd commit af0ccc1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
33 changes: 29 additions & 4 deletions artifact_MobileApp/SearchBar.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,40 @@
// SearchBar.js
import React, { useState } from 'react';
import apiInstance from './Api';
import Toast from 'react-native-toast-message';
import { View, TextInput, TouchableOpacity, StyleSheet } from 'react-native';
import { Ionicons } from '@expo/vector-icons';

const SearchBar = () => {
const [searchText, setSearchText] = useState('');

const handleSearch = (val) => {
console.log({val});
//link to wikiData API here ...
setSearchText('');
const handleSearch = async (val) => {
try {
const response = await apiInstance().post("search", {
query: val
})

if (response.status === 200) {

const data = await response.data

console.log(data)

setSearchText("")
}
} catch (e) {
console.log(e)
Toast.show({
type: 'error',
position: 'bottom',
text1: 'Search Error',
text2: 'There was an error while searching. Please try again.',
visibilityTime: 2000,
autoHide: true,
topOffset: 30,
bottomOffset: 40
});
}

};

Expand Down
2 changes: 1 addition & 1 deletion artifact_backend/artifact/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
'http://localhost:3000',
'https://bounswe.github.io',
'https://frontend-yslcfqdwna-oa.a.run.app',
'http://192.168.1.31:8081'
'http://localhost:8081'
]

CORS_ALLOW_CREDENTIALS = True
Expand Down

0 comments on commit af0ccc1

Please sign in to comment.