Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
susumutomita committed Feb 3, 2024
1 parent 5152a6c commit b10ce40
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 4 deletions.
24 changes: 22 additions & 2 deletions packages/frontend/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
// App.tsx
import React from 'react';
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';
import { StyleSheet, Text, View, TextInput, Button } from 'react-native';
import { useGenerateProof } from './src/hooks/useGenerateProof';

export default function App() {
const { age, setAge, proofResult, handleGenerateProof } = useGenerateProof();

return (
<View style={styles.container}>
<Text>Open up App.tsx to start working on your app test!</Text>
<TextInput
style={styles.input}
placeholder="年齢を入力"
value={age}
onChangeText={setAge}
keyboardType="numeric"
/>
<Button title="年齢を証明" onPress={handleGenerateProof} />
{proofResult ? <Text>{proofResult}</Text> : null}
<StatusBar style="auto" />
</View>
);
Expand All @@ -17,4 +30,11 @@ const styles = StyleSheet.create({
alignItems: 'center',
justifyContent: 'center',
},
input: {
height: 40,
margin: 12,
borderWidth: 1,
padding: 10,
width: '80%',
},
});
64 changes: 63 additions & 1 deletion packages/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
"test:watch": "jest --watch --verbose"
},
"dependencies": {
"axios": "^1.6.7",
"expo": "~50.0.5",
"expo-status-bar": "~1.11.1",
"react": "18.2.0",
"react-native": "0.73.2"
"react-native": "0.73.2",
"react-native-config": "^1.5.1"
},
"devDependencies": {
"@babel/core": "^7.20.0",
Expand Down
24 changes: 24 additions & 0 deletions packages/frontend/src/hooks/useGenerateProof.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// src/hooks/useGenerateProof.ts
import { useState } from 'react';
import { generateProof } from '../sindri';

export const useGenerateProof = () => {
const [age, setAge] = useState<string>('');
const [proofResult, setProofResult] = useState<string>('');

const handleGenerateProof = async () => {
try {
const result = await generateProof(parseInt(age, 10));

Check failure on line 11 in packages/frontend/src/hooks/useGenerateProof.ts

View workflow job for this annotation

GitHub Actions / build-and-test

'result' is assigned a value but never used
setProofResult('年齢が証明されました');
} catch (error) {
setProofResult('証明に失敗しました');
}
};

return {
age,
setAge,
proofResult,
handleGenerateProof
};
};
File renamed without changes.

0 comments on commit b10ce40

Please sign in to comment.