Skip to content

Commit

Permalink
tags into array
Browse files Browse the repository at this point in the history
  • Loading branch information
hrutik7 committed Jul 30, 2023
1 parent fcfb307 commit c83296c
Show file tree
Hide file tree
Showing 16 changed files with 1,826 additions and 378 deletions.
6 changes: 6 additions & 0 deletions amplify/backend/api/tada/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ type UserInfo @model{
id: ID!
username: String!
}

type GenderInfo @model{
id: ID!
gender: String!
}
type ExplainYourself @model{
id: ID!
explain: String!
Expand All @@ -81,6 +86,7 @@ type UsersData @model {
id: ID!
username : String!
tags: [String]
gender : String!
}

type Message @model {
Expand Down
11 changes: 8 additions & 3 deletions app/Components/Tags/Tags.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ResponsiveFontSize from 'react-native-responsive-fontsize';
import * as mutations from '../../../src/graphql/mutations';
import { API } from "aws-amplify";
import { UserInfo } from '../../../src/models';
import { GenderInfo } from '../../../src/models';
import { DataStore } from 'aws-amplify';
import { SQLiteAdapter } from '@aws-amplify/datastore-storage-adapter/SQLiteAdapter';

Expand All @@ -17,25 +18,29 @@ const Tags = ({navigation}) => {
const [text, setText] = useState('');
const [inputarray,setInputarray] = useState([])
const [username,setUsername] = useState('')
const [gender,setGender] = useState('')
const postUserData = async () => {
try {
const posts = await DataStore.query(UserInfo);
const genderinfo = await DataStore.query(GenderInfo);
setUsername(posts[0].username)
console.log('Posts retrieved successfully!', posts);

setGender(genderinfo[0].gender)
} catch (error) {
console.log('Error retrieving posts', error);
}
try {
// console.log(inputarray,username,"====================")

const inputstring = JSON.stringify(inputarray)
console.log(inputstring,"string==============================")
console.log(inputstring,"this isinputokkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk")
const userData = await API.graphql({
query: mutations.createUsersData,
variables: {
input: {
username: username,
tags: inputstring
tags: inputarray,
gender:gender
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion app/Screens/Confirmation/Confirmation.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const Confirmation = ({navigation}) => {
try {
const user = await Auth.confirmSignUp(username, code);
console.log(user,"user is here....")
navigation.navigate("Login")
navigation.navigate("Gender")
} catch (error) {
Alert.alert(error)
console.log('error signing in', error);
Expand Down
36 changes: 25 additions & 11 deletions app/Screens/Gender/Gender.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
import React, {useState} from 'react';
import {View, StyleSheet, Image, Text, TouchableOpacity} from 'react-native';
// import InputField from '../../components/InputField';
import InputField from '../../Components/InputField/InputField';
import CustomTouchableOpacity from '../../Components/Button/Button';
import {DataStore} from 'aws-amplify';
import {SQLiteAdapter} from '@aws-amplify/datastore-storage-adapter/SQLiteAdapter';
import { UserInfo } from '../../../src/models';
import { GenderInfo } from '../../../src/models';
DataStore.configure({
storageAdapter: SQLiteAdapter,
});

const Gender = ({navigation}) => {


import {Alert} from 'react-native';
const Gender = () => {
const [Username, setUsername] = useState('');
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [login, setLogin] = useState(false);
const saveGender = async(gender) =>{
try {
const post = await DataStore.save(
new GenderInfo({
gender: gender
}),
);
console.log('gender saved successfully!', post);
navigation.navigate("Explain")
} catch (error) {
console.log(error,"err hain")
}
}
return (
<View style={styles.container}>
<View style={styles.header}>
Expand All @@ -19,7 +33,7 @@ const Gender = () => {
<View style={styles.GenderContainer}>
<TouchableOpacity
style={{height:220}}
onPress={() => setLogin(true)}>
onPress={() => saveGender("male")}>
<Image
style={{width: 150, height: 150}}
source={require('../../Assets/male.png')}
Expand All @@ -29,7 +43,7 @@ const Gender = () => {

<TouchableOpacity

onPress={() => setLogin(true)}>
onPress={() => saveGender("female")}>
<Image
style={{width: 150, height: 150}}
source={require('../../Assets/female.png')}
Expand Down
1 change: 1 addition & 0 deletions app/Screens/Signup/SignUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const SignUp = ({navigation}) => {
}),
);
console.log('Post saved successfully!', post);

} catch (error) {
console.log('Error saving post', error);
}
Expand Down
63 changes: 59 additions & 4 deletions app/Screens/WaitingMatch/WaitingMatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,69 @@ import { SvgUri } from 'react-native-svg';
import CustomTouchableOpacity from '../../Components/Button/Button';
import * as queries from '../../../src/graphql/queries'
import { API, DataStore } from 'aws-amplify';
import awsconfig from '../../../src/aws-exports'
import { Auth } from 'aws-amplify';
import { listUserInfos } from '../../../src/graphql/queries';
import { listUsersData } from '../../../src/graphql/queries';
const WaitingScreen = ({navigation}) => {
const [users,setUsers] = useState()
const [NextToken,setNextToken] = useState()
useEffect(()=>{
fetchApi()
fetchApi(10)
},[])

const fetchApi = async (limit) =>{
// let apiName = 'listUserInfos';
// let path = '/listUsersInGroup';
// let myInit = {
// queryStringParameters: {

// "limit": limit,
// "token": nextToken
// },
// headers: {
// 'Content-Type' : 'application/json',
// Authorization: `${(await Auth.currentSession()).getAccessToken().getJwtToken()}`
// }
// }
// const { NextToken, ...rest } = await API.get(apiName, path, myInit);
// nextToken = NextToken;
// console.log(rest,"rest")
// return rest;


try {
let nextToken = await Auth.currentSession()
// let nextToken = await Auth.currentSession().getAccessToken().getJwtToken()


let nextjwt = nextToken.accessToken.jwtToken
console.log(nextjwt,"==========================================")
const { data , errors} = await API.graphql({
query: listUsersData,
variables: {
filter : null,
limit: 10, // Set the desired limit for each query
token: nextjwt, // Use the nextToken to paginate
},
});
if (errors) {
console.error('GraphQL errors:', errors);
return;
}
const newUsers = data.listUserInfos.items;
const newNextToken = data.listUserInfos.nextToken;
console.log(data.listUserInfos.items,"here is data")
setUsers((prevUsers) => [...prevUsers, ...newUsers]);
setNextToken(nextjwt);
} catch (error) {
console.error('Error fetching user information:', error.data.listUsersData.items);
}





const fetchApi = async () =>{
const allTodos = await API.graphql({ query: queries.listUsersData });
console.log(allTodos.data,"con")
}

const signOut = async () =>{
Expand Down
Loading

0 comments on commit c83296c

Please sign in to comment.