From 98201c894894d63b2068a762aa08d98f93213250 Mon Sep 17 00:00:00 2001 From: aeroreyna Date: Mon, 7 Mar 2022 16:10:43 -0800 Subject: [PATCH] Changin to material icons --- API.js | 37 +++++++++++++++++++++++++++++++++--- Views/Feed.js | 8 ++++++-- components/NewPost.js | 44 ++++++++++++++++++++++++++++++++++--------- components/Post.js | 8 ++++---- 4 files changed, 79 insertions(+), 18 deletions(-) diff --git a/API.js b/API.js index 4160970..ed56bf1 100644 --- a/API.js +++ b/API.js @@ -17,6 +17,23 @@ let getCall = async (path = "", params = {}) => { }) } +let deleteCall = async (path = "", params = {}) => { + let queryParams = "?"; + Object.keys(params).forEach(p => { + queryParams += p + "=" + params[p] + "&" + }); + return fetch(baseUrl + path + queryParams, { + method: 'DELETE', + mode: 'cors', + credentials: 'include', + headers: { + 'Content-Type': 'application/json', + } + }).then(response => response.json()).catch((error) => { + console.error(error); + }) +} + let postCall = async (path, params) => { return fetch(baseUrl + path, { method: 'POST', @@ -112,9 +129,13 @@ const API = { if (userid) return getCall("/post/usr/" + userid); return getCall("/post/"); }, - newPost(content, toProfile) { + deletePost(postid){ + return deleteCall("/post/" + postid); + }, + newPost(content, toProfile, isNews) { //Content is expected to be a string. let params = { content }; + if(isNews) params.nonOrganicType = "News" if (toProfile && CurrentUserId !== toProfile) params.toProfile = toProfile; return postCall("/post/", params); @@ -157,8 +178,8 @@ const API = { getMyProfile() { return getCall("/user/" + CurrentProfile); }, - updateMyProfile(profile) { - return postCall("/user/myProfile", profile); + updateMyProfile(profile, data) { + return postCall("/user/myProfile", {profile, data}); }, searchProfiles(query){ return getCall("/user/search", query ? {query} : {}).then((data)=>{ @@ -180,6 +201,9 @@ const API = { getUserProfile(profileid, refresh=false) { return getProfileFromCache(profileid, refresh); }, + deleteProfile(profileid){ + return deleteCall("/user/" + profileid); + }, currentProfileId() { if (!CurrentProfile) this.isLoggedIn(); //replace with cookie return CurrentProfile; @@ -245,6 +269,13 @@ const API = { }, unsubscribeToGroup(groupid){ return getCall("/user/groups/" + groupid + "/unsubscribe"); + }, + //Payments + paymentIntent(userid, price, description){ + return postCall("/payments/intent", {userid, price, description}); + }, + paymentRegister(userid, result){ + return postCall("/payments/register/", {userid, result}); } } diff --git a/Views/Feed.js b/Views/Feed.js index aabc371..d207649 100644 --- a/Views/Feed.js +++ b/Views/Feed.js @@ -5,6 +5,8 @@ import API from './../API.js'; import Post from './../components/Post.js'; import { Provider as PaperProvider } from 'react-native-paper'; import AwesomeIcon from 'react-native-vector-icons/FontAwesome'; +import MaterialIcons from 'react-native-vector-icons/MaterialIcons'; +import NewPost from "./../components/NewPost.js"; @@ -29,11 +31,12 @@ let Feed = ({ navigation, route }) => { return ( , + icon: props => , }}> + { Posts.map((post, i) => { return ( @@ -57,6 +60,7 @@ const styles = StyleSheet.create({ flex: 1, alignItems: 'center', justifyContent: 'center', - backgroundColor: "#edf2f7" + backgroundColor: "#edf2f7", + width: "100%" }, }); diff --git a/components/NewPost.js b/components/NewPost.js index fad7305..aab21df 100644 --- a/components/NewPost.js +++ b/components/NewPost.js @@ -1,19 +1,45 @@ import React, { useState } from 'react'; -import { Text, View, TextInput, Button, StyleSheet } from 'react-native'; +import { View, StyleSheet } from 'react-native'; +import { TextInput, Button } from 'react-native-paper'; import API from './../API.js'; +import { useNavigation } from '@react-navigation/native'; -let NewPost = ()=>{ - let [query, setQuery] = useState(''); +let NewPost = () => { + let [postContent, setPostContent] = useState(''); + const navigation = useNavigation(); - return ( - - - - ); + return ( + + + { + postContent ? ( + + + + + ) : undefined + } + + + ); } export default NewPost; -const styles = StyleSheet.create ({ +const styles = StyleSheet.create({ + newPost: { + margin: 10 + } }); \ No newline at end of file diff --git a/components/Post.js b/components/Post.js index 81e18f2..06f950e 100644 --- a/components/Post.js +++ b/components/Post.js @@ -24,10 +24,10 @@ let Post = ({ post, viewer }) => { - - - - + + + + { showCommentsB &&