Skip to content

Commit

Permalink
:)
Browse files Browse the repository at this point in the history
  • Loading branch information
coredumped7893 committed Feb 18, 2024
1 parent 8bc5014 commit 7764f11
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 102 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"version": "0.0.1",
"type": "module",
"scripts": {
"dev": "loyalty-customer-mobile-app/node_modules/.bin/vite",
"build": "loyalty-customer-mobile-app/node_modules/.bin/tsc && vite build",
"dev": "vite",
"build": "tsc && vite build",
"preview": "loyalty-customer-mobile-app/node_modules/.bin/vite preview",
"test.e2e": "loyalty-customer-mobile-app/node_modules/.bin/cypress run",
"test.unit": "loyalty-customer-mobile-app/node_modules/.bin/vitest",
Expand Down
53 changes: 27 additions & 26 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IonApp, IonRouterOutlet, IonSplitPane, setupIonicReact } from '@ionic/react';
import { IonReactRouter } from '@ionic/react-router';
import { Redirect, Route } from 'react-router-dom';
import {IonApp, IonRouterOutlet, IonSplitPane, setupIonicReact} from '@ionic/react';
import {IonReactRouter} from '@ionic/react-router';
import {Redirect, Route} from 'react-router-dom';
import Menu from './components/Menu';
import Page from './pages/Page';

Expand All @@ -24,33 +24,34 @@ import '@ionic/react/css/display.css';
import './theme/variables.css';
import CouponsPage from './pages/CouponsPage';
import UserProfilePage from './pages/UserProfilePage';
import React from "react";

setupIonicReact();

const App: React.FC = () => {
return (
<IonApp>
<IonReactRouter>
<IonSplitPane contentId="main">
<Menu />
<IonRouterOutlet id="main">
<Route path="/" exact={true}>
<Redirect to="/folder/Coupons" />
</Route>
<Route path="/folder/:name" exact={true}>
<Page />
</Route>
<Route path="/folder/Coupons" exact={true}>
<CouponsPage/>
</Route>
<Route path="/folder/Profile" exact={true}>
<UserProfilePage />
</Route>
</IonRouterOutlet>
</IonSplitPane>
</IonReactRouter>
</IonApp>
);
return (
<IonApp>
<IonReactRouter>
<IonSplitPane contentId="main">
<Menu/>
<IonRouterOutlet id="main">
<Route path="/" exact={true}>
<Redirect to="/folder/Coupons"/>
</Route>
<Route path="/folder/:name" exact={true}>
<Page/>
</Route>
<Route path="/folder/Coupons" exact={true}>
<CouponsPage/>
</Route>
<Route path="/folder/Profile" exact={true}>
<UserProfilePage/>
</Route>
</IonRouterOutlet>
</IonSplitPane>
</IonReactRouter>
</IonApp>
);
};

export default App;
138 changes: 64 additions & 74 deletions src/components/UserProfileContainer.tsx
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;

0 comments on commit 7764f11

Please sign in to comment.