Skip to content

Commit

Permalink
working codebaseV2
Browse files Browse the repository at this point in the history
  • Loading branch information
ManojBaasha committed Dec 8, 2023
1 parent ff05bfc commit 76f7b40
Show file tree
Hide file tree
Showing 28 changed files with 53 additions and 1,996 deletions.
47 changes: 1 addition & 46 deletions Frontend/components/Login.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,5 @@
import React, { useState } from 'react';
import { View, Text, TextInput, StyleSheet, Button, TouchableOpacity } from 'react-native';

const LoginScreen = ({ navigation }) => {
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');

const handleLogin = () => {
// Here you would usually send a request to your Node.js server
// For the purpose of this example, we'll just log the credentials
console.log('Login with:', username, password);
// Regular expression to validate the email format
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;

// Validate if the username is in the correct email format
if (emailRegex.test(username)) {
// If the email is valid, proceed with the login
// TODO: Send a request to your Node.js server to validate the credentials

// Navigate to the HomeScreen if the login is successful
navigation.navigate('Home');
} else {
// If the email is not valid, alert the user
alert('Please enter a valid email address.');
}
// TODO: Implement login logic
navigation.navigate('Home');
};

const handleForgotPassword = () => {
// Here you would handle the forgot password logic or navigation
console.log('Forgot password');
// TODO: Implement forgot password logic
};


import React, { useState } from "react";
import {
View,
Text,
TextInput,
StyleSheet,
Button,
TouchableOpacity,
} from "react-native";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { useKey } from "./operations/keyContext";

Expand All @@ -56,9 +13,7 @@ const getData = async (username, password) => {
}
};



const LoginScreen = ({ navigation }) => {
const Login = ({ navigation }) => {
const { publicKey, privateKey } = useKey();
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
Expand Down
118 changes: 0 additions & 118 deletions Frontend/components/createtransaction.js

This file was deleted.

85 changes: 48 additions & 37 deletions Frontend/components/operations/settransactions.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, useCallback } from 'react';
import { StyleSheet, View, Text, TouchableOpacity, SafeAreaView, TextInput} from 'react-native';
import { LinearGradient } from 'expo-linear-gradient';
import AppLoading from 'expo-app-loading';
import * as Font from 'expo-font';
import { useKey } from "../operations/keyContext";
import Entypo from '@expo/vector-icons/Entypo';
import * as SplashScreen from 'expo-splash-screen';

// Keep the splash screen visible while we fetch resources
SplashScreen.preventAutoHideAsync();


const fetchFonts = () => {
return Font.loadAsync({
Expand All @@ -14,33 +21,15 @@ const fetchFonts = () => {
};


const CreateTransactionScreen = () => {

const [fontsLoaded, setFontsLoaded] = useState(false);
const [inputValue, setInputValue] = useState('');

// Handle number press
const handleNumberPress = (number) => {
setInputValue((prevInputValue) => `${prevInputValue}${number}`);
import React, { useState } from "react";
import {
SafeAreaView,
StatusBar,
StyleSheet,
Text,
TouchableOpacity,
View,
} from "react-native";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { useKey } from "../operations/keyContext";


const UpdateTransactionScreen = () => {
const CreateTransaction = () => {
const [appIsReady, setAppIsReady] = useState(false);
const [amount, setAmount] = useState("");
const { publicKey, privateKey } = useKey();
const [fontsLoaded, setFontsLoaded] = useState(false);
const [inputValue, setInputValue] = useState('');

const handlePressDigit = (digit) => {
setAmount((prevAmount) => prevAmount + digit);
const handleNumberPress = (digit) => {
setInputValue((prevAmount) => prevAmount + digit);
};

// Handle delete press
Expand All @@ -51,22 +40,19 @@ const UpdateTransactionScreen = () => {
// Handle clear press
const handleClearPress = () => {
setInputValue('');
const handleClear = () => {
setAmount("");
};

}
// Create transaction press
const handleCreatePress = () => {
console.log("Amount entered:", amount);
console.log("Amount entered:", inputValue);
// You can replace this with your GraphQL endpoint
const apiUrl = "https://cloud.resilientdb.com/graphql";

const postData = {
query: ` mutation { postTransaction(data: {
operation: "CREATE"
amount: ${amount}
signerPublicKey: "${publicKey}",
signerPrivateKey: "${privateKey}",
amount: ${inputValue}
signerPublicKey: "${publicKey}"
signerPrivateKey: "${privateKey}"
recipientPublicKey: "ECJksQuF9UWi3DPCYvQqJPjF6BqSbXrnDiXUjdiVvkyH"
asset: """{
"data": { "time": 1690881023169
Expand Down Expand Up @@ -102,12 +88,37 @@ const UpdateTransactionScreen = () => {
// return null;
// }
useEffect(() => {
fetchFonts().then(() => setFontsLoaded(true));
async function prepare() {
try {
// Pre-load fonts, make any API calls you need to do here
await Font.loadAsync(Entypo.font);
} catch (e) {
console.warn(e);
} finally {
// Tell the application to render
setAppIsReady(true);
}
}

prepare();
}, []);

if (!fontsLoaded) {
return <AppLoading />;
const onLayoutRootView = useCallback(async () => {
if (appIsReady) {
// This tells the splash screen to hide immediately! If we call this after
// `setAppIsReady`, then we may see a blank screen while the app is
// loading its initial state and rendering its first pixels. So instead,
// we hide the splash screen once we know the root view has already
// performed layout.
await SplashScreen.hideAsync();
}
}, [appIsReady]);

if (!appIsReady) {
return null;
}


return (
<SafeAreaView style={styles.container}>
<Text style={styles.title}>Create Transaction</Text>
Expand Down Expand Up @@ -211,4 +222,4 @@ const styles = StyleSheet.create({
},
});

export default CreateTransactionScreen;
export default CreateTransaction;
23 changes: 4 additions & 19 deletions Frontend/components/operations/updatetransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,14 @@ const fetchFonts = () => {
'ClashDisplay': require('../../assets/fonts/ClashDisplay-Regular.otf')
});
};

import React, { useState } from "react";
import {
StyleSheet,
View,
Text,
TouchableOpacity,
StatusBar,
SafeAreaView,
} from "react-native";
import { useKey } from "./keyContext";

const UpdateTransactionScreen = () => {

const UpdateTransactionScreen = ({ route }) => {
const [fontsLoaded, setFontsLoaded] = useState(false);
const [inputValue, setInputValue] = useState('');
const UpdateTransactionScreen = ({ route }) => {
const { transactionID } = route.params;
const [amount, setAmount] = useState("");
const { publicKey, privateKey } = useKey();


// Handle number press
const handleNumberPress = (number) => {
Expand All @@ -44,24 +31,22 @@ const UpdateTransactionScreen = ({ route }) => {
setInputValue((prevInputValue) => prevInputValue.slice(0, -1));
};

const handleClear = () => {
setAmount("");
// Handle clear press
const handleClearPress = () => {
setInputValue('');
};

// Create transaction press
const handleCreatePress = () => {
console.log("Amount entered:", amount);
console.log("Amount entered:", inputValue);
// You can replace this with your GraphQL endpoint
const apiUrl = "https://cloud.resilientdb.com/graphql";

const postData = {
query: ` mutation { updateTransaction(data:{
id: "${transactionID}"
operation: ""
amount: ${amount}
amount: ${inputValue}
signerPublicKey: "${publicKey}"
signerPrivateKey: "${privateKey}"
recipientPublicKey: "ECJksQuF9UWi3DPCYvQqJPjF6BqSbXrnDiXUjdiVvkyH"
Expand Down Expand Up @@ -217,4 +202,4 @@ const styles = StyleSheet.create({
},
});

export default UpdateTransactionScreen;
export default UpdateTransactionScreen;
Loading

0 comments on commit 76f7b40

Please sign in to comment.