-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8bc5014
commit 7764f11
Showing
3 changed files
with
93 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,77 @@ | ||
import "./CouponsContainer.css"; | ||
import React, { useEffect, useState } from "react"; | ||
import { | ||
IonButton, | ||
IonCard, | ||
IonCardContent, | ||
IonCardHeader, | ||
IonCardSubtitle, | ||
IonCardTitle, | ||
IonInput, | ||
IonItem, | ||
IonLabel, | ||
IonList, | ||
IonThumbnail, | ||
} from "@ionic/react"; | ||
import { signCoupon } from "../helpers/signCoupon"; | ||
import { getData, setData } from "../data/helpers/localStorageService"; | ||
import { DataKey } from "../data/const/localStorageConst"; | ||
import { getShares } from "../services/loyaltyService"; | ||
import React, {useEffect, useState} from "react"; | ||
import {IonCard, IonCardHeader, IonCardSubtitle, IonCardTitle, IonInput, IonProgressBar,} from "@ionic/react"; | ||
import {getData, setData} from "../data/helpers/localStorageService"; | ||
import {DataKey} from "../data/const/localStorageConst"; | ||
import {getShares} from "../services/loyaltyService"; | ||
|
||
interface UserProfileProps {} | ||
interface UserProfileProps { | ||
} | ||
|
||
const changeName = (newName: string | number | null | undefined) => { | ||
if (!!newName) { | ||
setData(DataKey.Name, `${newName}`); | ||
} | ||
if (!!newName) { | ||
setData(DataKey.Name, `${newName}`); | ||
} | ||
}; | ||
|
||
const UserProfileContainer: React.FC<UserProfileProps> = () => { | ||
const [shares, setShares] = useState<any>(0); | ||
const [error, setError] = useState<string | null>(null); | ||
const [shares, setShares] = useState<any>(0); | ||
const [error, setError] = useState<string | null>(null); | ||
|
||
useEffect(() => { | ||
const fetchData = async () => { | ||
console.log(shares); | ||
try { | ||
const data = await getShares(); // Call the getShares function | ||
setShares(data); // Assuming that the returned data has a 'shares' property | ||
console.log("Shares data:", data); | ||
} catch (error) { | ||
console.error("Error fetching data:", error); | ||
setError("Error fetching data. Please try again."); | ||
} | ||
}; | ||
useEffect(() => { | ||
const fetchData = async () => { | ||
console.log(shares); | ||
try { | ||
const data = await getShares(); // Call the getShares function | ||
setShares(data); // Assuming that the returned data has a 'shares' property | ||
console.log("Shares data:", data); | ||
} catch (error) { | ||
console.error("Error fetching data:", error); | ||
setError("Error fetching data. Please try again."); | ||
} | ||
}; | ||
|
||
fetchData(); | ||
}, []); | ||
fetchData(); | ||
}, []); | ||
|
||
return ( | ||
<> | ||
<IonCard> | ||
<IonCardHeader> | ||
<IonCardSubtitle>My name:</IonCardSubtitle> | ||
<IonCardTitle> | ||
<IonInput | ||
clearOnEdit={true} | ||
value={getData(DataKey.Name)} | ||
onIonBlur={(e) => changeName(e.target.value)} | ||
></IonInput> | ||
</IonCardTitle> | ||
</IonCardHeader> | ||
</IonCard> | ||
<IonCard> | ||
<IonCardHeader> | ||
<IonCardSubtitle>My shares:</IonCardSubtitle> | ||
<IonCardTitle> | ||
{shares.numberOfShares !== null | ||
? shares.numberOfShares | ||
: "Loading..."} | ||
</IonCardTitle> | ||
</IonCardHeader> | ||
</IonCard> | ||
<IonCard> | ||
<IonCardHeader> | ||
<IonCardTitle>0x932890843298943298</IonCardTitle> | ||
<IonInput | ||
label="Private key:" | ||
type="password" | ||
value="132123123132123123" | ||
></IonInput> | ||
</IonCardHeader> | ||
</IonCard> | ||
</> | ||
); | ||
return ( | ||
<> | ||
<IonCard> | ||
<IonCardHeader> | ||
<IonCardTitle> | ||
<IonInput | ||
clearOnEdit={true} | ||
value={getData(DataKey.Name)} | ||
onIonBlur={(e) => changeName(e.target.value)} | ||
></IonInput> | ||
</IonCardTitle> | ||
<IonCardSubtitle>My name:</IonCardSubtitle> | ||
</IonCardHeader> | ||
</IonCard> | ||
<IonCard> | ||
<IonCardHeader> | ||
<IonCardTitle> | ||
{shares?.numberOfShares | ||
? shares.numberOfShares | ||
: <IonProgressBar style={{"margin-top": "5px"}} type="indeterminate"></IonProgressBar>} | ||
</IonCardTitle> | ||
<IonCardSubtitle>My shares: </IonCardSubtitle> | ||
</IonCardHeader> | ||
</IonCard> | ||
<IonCard> | ||
<IonCardHeader> | ||
|
||
<IonCardTitle | ||
style={{"font-size": "25px", "text-align": "center"}}>0x932890843298943298</IonCardTitle> | ||
<IonInput | ||
label="Private key:" | ||
type="password" | ||
value="132123123132123123" | ||
></IonInput> | ||
</IonCardHeader> | ||
</IonCard> | ||
</> | ||
); | ||
}; | ||
|
||
export default UserProfileContainer; |