Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Small fixes #120

Merged
merged 3 commits into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 32 additions & 13 deletions wallet/wallet-app/components/frames/ActivityFrame.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import createVerifiablePresentationJWT from '../../utils/sign';
*/
export default function ActivityFrame() {
const [status, setStatus] = useState(false);
const dispatch = useDispatch();
const [scanned, setScanned] = useState(false);

const dispatch = useDispatch();
const navigation = useNavigation();
const { cred } = useSelector((state) => state.credentials);

Expand Down Expand Up @@ -48,27 +49,45 @@ export default function ActivityFrame() {
setScanned(true);
const verifier = data.split('|')[0];
const vc = data.split('|')[1];

const userID = data.split('|')[2];
console.log(userID);
let proof = '';
for (let i = 0; i < cred.length; i++) {
if (cred[i].vc.credentialSubject.age.type === vc) {
proof = cred[i];
try {
if (cred[i].vc.credentialSubject.age.type === vc) {
proof = cred[i];
break;
}
} catch (error) {
proof = '';
}
}

Alert.alert(
'TJENESTE SPØR OM BEVIS',
`Vil du godkjenne at beviset ${vc} blir sendt til tjeneste ${verifier}?`,
[
if (proof === '') {
Alert.alert('Mangler bevis', `Du har ikke beviset som tjenesten spør om: ${vc}`, [
{
text: 'Ikke godkjenn',
onPress: () => navigation.navigate('Oversikt') && setScanned(false),
style: 'cancel',
text: 'Ok',
onPress: () => setScanned(false),
},
{ text: 'Godkjenn', onPress: () => sendPresentation([proof], verifier, userID) && setScanned(false) },
]
);
]);
} else {
Alert.alert(
'TJENESTE SPØR OM BEVIS',
`Vil du godkjenne at beviset ${vc} blir sendt til tjeneste ${verifier}?`,
[
{
text: 'Ikke godkjenn',
onPress: () => setScanned(false),
style: 'cancel',
},
{
text: 'Godkjenn',
onPress: () => sendPresentation([proof], verifier, userID) && setScanned(false),
},
]
);
}
};

return (
Expand Down
33 changes: 22 additions & 11 deletions wallet/wallet-app/components/frames/ProfileMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function ProfileMenuSlide() {
const dispatch = useDispatch();
const navigation = useNavigation();
const [baseIdIssuer, setBaseIdIssuer] = useState('');
const [walletID, setWalletID] = useState('');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unneccessary state

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gjorde bare det samme som ble gjort med baseIdIssuer


const getBaseIdIssuer = async () => {
const baseIdToken = await AsyncStorage.getItem('baseId');
Expand All @@ -26,6 +27,14 @@ export default function ProfileMenuSlide() {

getBaseIdIssuer();

const getWalletId = async () => {
const walletId = await AsyncStorage.getItem('walletID');
console.log(walletId);
setWalletID(walletId);
};

getWalletId();

const clearAllData = async () => {
const keys = await AsyncStorage.getAllKeys();
keys.map((key) => AsyncStorage.removeItem(key));
Expand Down Expand Up @@ -79,30 +88,31 @@ export default function ProfileMenuSlide() {
text90
/>
</View>
<View style={styles.container} marginTop={100}>
<View style={styles.container} marginTop={80}>
<Icon name="user-circle" size={220} color="rgb(30,46,60)" />
</View>
<View>
<Text style={styles.textstyle}>Kari Nordman</Text>
</View>

<Text text90 style={{ marginLeft: 10, alignSelf: 'center', marginTop: 140 }}>
ID: {baseIdIssuer.substring(baseIdIssuer.length - 36)}
</Text>
<View
style={{
display: 'flex',
flexDirection: 'row',
flexWrap: 'nowrap',
marginTop: 1,
marginTop: 5,
alignSelf: 'center',
}}>
<Icon name="check" size={10} color="rgb(30,46,60)" />
<Icon name="check" size={10} color="#a9a9a9" />

<Text text100 style={{ marginLeft: 4, marginTop: -3 }}>
Utstedt av: {baseIdIssuer.substring(0, baseIdIssuer.length - 36)}
<Text text100 grey40 style={{ marginLeft: 4, marginTop: -3 }}>
Godkjent av {baseIdIssuer.substring(0, baseIdIssuer.length - 36)}
</Text>
</View>

<Text text90 style={{ marginLeft: 10, alignSelf: 'center', marginTop: 130 }}>
ID: {walletID.substring(walletID.length - 36)}
</Text>

{/**
* Du har grunnidentitet utstedt fra: {baseIdIssuer}
*/}
Expand All @@ -111,7 +121,7 @@ export default function ProfileMenuSlide() {
label="Slett bruker"
color="rgb(194,19,44)"
backgroundColor="transparent"
style={{ marginTop: 20 }}
style={{ marginTop: 10 }}
size={Button.sizes.small}
onPress={buttonAlert}
text90
Expand All @@ -128,9 +138,10 @@ const styles = StyleSheet.create({
paddingHorizontal: 20,
},
textstyle: {
fontSize: 30,
fontSize: 40,
paddingHorizontal: 20,
marginTop: 20,
marginBottom: 5,
alignSelf: 'center',
color: 'rgb(30,46,60)',
},
Expand Down
2 changes: 1 addition & 1 deletion wallet/wallet-app/components/frames/VerifierLogFrame.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default function VerifierLogFrame({ route }) {
<CreateQR content={route.params.props.name} />
</Card>

{shared.filter((share) => share.credential_id === route.params.props.id) ? (
{shared.filter((share) => share.credential_id === route.params.props.id).length === 0 ? (
<Card.Section
content={[
{
Expand Down