Skip to content

Commit

Permalink
new-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Adesojisouljay committed Mar 29, 2024
1 parent 6098a1e commit a275945
Show file tree
Hide file tree
Showing 4 changed files with 242 additions and 239 deletions.
44 changes: 42 additions & 2 deletions src/common/components/onboard-friend/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
flex-direction: column;
align-items: center;
gap: 10px;
width: max-content;
// width: max-content;
background-color: #161d26;
// background-color: $dark-three;
padding: 2rem;
Expand All @@ -19,6 +19,7 @@

.friend-details{
display: flex;
align-items: center;
flex-direction: column;
gap: 15px;
}
Expand All @@ -27,6 +28,7 @@
display: flex;
margin-top: 5px;
gap: 10px;
width: 100%;
}

.delegate-rc{
Expand Down Expand Up @@ -67,4 +69,42 @@
@media (max-width: 470px) {
flex-wrap: wrap;
}
}
}

.pay-wrapper{
display: flex;
align-items: center;
flex-direction: column;
gap: 5px;
@media (max-width: 470px) {
width: 300px;
}
}

.animation-container {
text-align: center;
}

.animation-text {
animation: spin 2s ease-in-out infinite;
}

@keyframes spin {
0% {
transform: rotate(0deg);
}
25% {
transform: rotate(8deg);
}
50% {
transform: rotate(0deg);
}
75% {
transform: rotate(-8deg);
}
100% {
transform: rotate(0deg);
}
}


129 changes: 83 additions & 46 deletions src/common/components/onboard-friend/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ const OnboardFriend = (props: Props | any) => {
const [voteAmount, setVoteAmount] = useState(0);
const [transferAmount, setTransferAmount] = useState(0);
const [customJsonAmount, setCustomJsonAmount] = useState(0);
const [rcError, setRcError] = useState("")
const [rcError, setRcError] = useState("");

useEffect(() => {
console.log(global)
let decodedObj;
try {
if (props.match.params.hash) {
Expand Down Expand Up @@ -87,6 +88,7 @@ const OnboardFriend = (props: Props | any) => {
}

const accountWithCredit = async () => {
setStep("creating")
try {
const response: any = await createAccountWithCredit({
username: urlInfo?.username,
Expand All @@ -98,7 +100,7 @@ const OnboardFriend = (props: Props | any) => {
if(isChecked){
await delegateRC(activeUser?.username, urlInfo!.username, rcAmount * 1e9)
}
await createBreakawayUser(urlInfo!.username, props.global.hive_id, urlInfo!.referral, urlInfo!.email)
// await createBreakawayUser(urlInfo!.username, props.global.hive_id, urlInfo!.referral, urlInfo!.email)
setStep("success");
setMsg("Account created successfully")
} else {
Expand All @@ -111,6 +113,7 @@ const OnboardFriend = (props: Props | any) => {
}

const createAccountNoUserKcCredit = async () => {
setStep("creating")
try {
const response: any = await createAccountWithCredit({
username: urlInfo?.username,
Expand All @@ -122,7 +125,7 @@ const OnboardFriend = (props: Props | any) => {
if(isChecked){
await delegateRcKc(urlInfo!.referral, urlInfo!.username, rcAmount * 1e9)
}
await createBreakawayUser(urlInfo!.username, props.global.hive_id, urlInfo!.referral, urlInfo!.email)
// await createBreakawayUser(urlInfo!.username, props.global.hive_id, urlInfo!.referral, urlInfo!.email)
setStep("success");
setMsg("Account created successfully")
} else {
Expand All @@ -135,6 +138,7 @@ const OnboardFriend = (props: Props | any) => {
}

const createAccount = async ()=> {
setStep("creating")
try {
const response: any = await createHiveAccount({
username: urlInfo?.username,
Expand All @@ -146,7 +150,7 @@ const OnboardFriend = (props: Props | any) => {
if(isChecked){
await delegateRC(urlInfo!.referral, urlInfo!.username, rcAmount * 1e9)
}
await createBreakawayUser(urlInfo!.username, props.global.hive_id, urlInfo!.referral, urlInfo!.email)
// await createBreakawayUser(urlInfo!.username, props.global.hive_id, urlInfo!.referral, urlInfo!.email)
setStep("success");
setMsg("Account created successfully")
} else {
Expand All @@ -159,6 +163,7 @@ const OnboardFriend = (props: Props | any) => {
};

const createAccountNoUser = async ()=> {
setStep("creating")
try {
const response: any = await createHiveAccount({
username: urlInfo?.username,
Expand All @@ -171,7 +176,7 @@ const OnboardFriend = (props: Props | any) => {
if(isChecked){
await delegateRcKc(urlInfo!.referral, urlInfo!.username, rcAmount * 1e9)
}
await createBreakawayUser(urlInfo!.username, props.global.hive_id, urlInfo!.referral, urlInfo!.email)
// await createBreakawayUser(urlInfo!.username, props.global.hive_id, urlInfo!.referral, urlInfo!.email)
setStep("success");
setMsg("Account created successfully")
} else {
Expand Down Expand Up @@ -232,20 +237,21 @@ const OnboardFriend = (props: Props | any) => {
<div className={`${containerClasses} d-flex align-items-center justify-content-center mt-5`}>
{ !activeUser ? <div className="d-flex justify-content-center">
<div className="onboard w-100">
{step === "creating" &&
<div className="animation-container">
<h4>Creating Account</h4>
<h5 className="text-success animation-text">Please wait...</h5>
</div>
}
{step=== "confirm" && <>
<h5 className="text-center">{_t("onboard.creating-for-a-friend")}</h5>
<div className="friend-details">
{urlInfo && (
<div className="friend-details">
<span>{_t("onboard.username")} {urlInfo.username}</span>
<span>{_t("onboard.public-posting")} {urlInfo.keys.postingPubKey}</span>
<span>{_t("onboard.public-owner")} {urlInfo.keys.ownerPubKey}</span>
<span>{_t("onboard.public-active")} {urlInfo.keys.activePubKey}</span>
<span>{_t("onboard.public-memo")} {urlInfo.keys.memoPubKey}</span>
</div>
)}
</div>

<div className="delegate-rc">
<div className="col-span-12 sm:col-span-10">
<div className="check mb-2">
Expand Down Expand Up @@ -280,21 +286,35 @@ const OnboardFriend = (props: Props | any) => {
}
</div>
</div>
<div className="create-buttons w-100">
<Button
disabled={rcError !== ""}
onClick={()=> createAccountNoUser()}
className="w-100"
>
Pay with (3Hive)
</Button>
<Button
disabled={token <= 0 || rcError !== ""}
onClick={()=> createAccountNoUserKcCredit()}
className="w-100"
>
Pay with account token
</Button>
<div className="pay-wrapper">
<span>Pay with:</span>
<div className="create-buttons w-100">
<Button
disabled={rcError !== ""}
onClick={()=> createAccountNoUser()}
className="w-100"
>
3Hive
</Button>
<Button
disabled={token <= 0 || rcError !== ""}
onClick={()=> createAccountNoUserKcCredit()}
className="w-100"
>
Account token
</Button>
</div>
</div>
<div className="friend-details">
{urlInfo && (
<div className="friend-details">
<span>Account public keys</span>
<span>{_t("onboard.public-posting")} {urlInfo.keys.postingPubKey}</span>
<span>{_t("onboard.public-owner")} {urlInfo.keys.ownerPubKey}</span>
<span>{_t("onboard.public-active")} {urlInfo.keys.activePubKey}</span>
<span>{_t("onboard.public-memo")} {urlInfo.keys.memoPubKey}</span>
</div>
)}
</div>
</>}
{step === "success" &&
Expand All @@ -310,16 +330,18 @@ const OnboardFriend = (props: Props | any) => {
</div>
</div> :
<div className="onboard">
{step === "creating" &&
<div className="animation-container">
<h4>Creating Account</h4>
<span className="text-success animation-text">Please wait...</span>
</div>
}
{step=== "confirm" && <>
<h5>{_t("onboard.creating-for-a-friend")}</h5>
<div className="friend-details">
{urlInfo && (
<div className="friend-details">
<span>{_t("onboard.username")} {urlInfo.username}</span>
<span>{_t("onboard.public-posting")} {urlInfo.keys.postingPubKey}</span>
<span>{_t("onboard.public-owner")} {urlInfo.keys.ownerPubKey}</span>
<span>{_t("onboard.public-active")} {urlInfo.keys.activePubKey}</span>
<span>{_t("onboard.public-memo")} {urlInfo.keys.memoPubKey}</span>
</div>
)}
</div>
Expand Down Expand Up @@ -358,24 +380,39 @@ const OnboardFriend = (props: Props | any) => {
}
</div>
</div>

<div className="create-buttons w-100">
<Button
disabled={rcError !== ""}
onClick={()=> createAccount()}
className="w-100"
>
Pay with (3Hive)
</Button>
<Button
disabled={token <= 0 || rcError !== ""}
onClick={()=> accountWithCredit()}
className="w-100"
>
Pay with account token
</Button>

<div className="pay-wrapper">
<span>Pay With:</span>
<div className="create-buttons">
<Button
disabled={rcError !== ""}
onClick={()=> createAccount()}
className="w-100"
>
3Hive
</Button>
<Button
disabled={token <= 0 || rcError !== ""}
onClick={()=> accountWithCredit()}
className="w-100"
>
account token
</Button>
</div>
</div>
</>}
<div className="friend-details mt-3">
{urlInfo && (
<div className="friend-details">
<span>Account public keys</span>
<span>{_t("onboard.public-posting")} {urlInfo.keys.postingPubKey}</span>
<span>{_t("onboard.public-owner")} {urlInfo.keys.ownerPubKey}</span>
<span>{_t("onboard.public-active")} {urlInfo.keys.activePubKey}</span>
<span>{_t("onboard.public-memo")} {urlInfo.keys.memoPubKey}</span>
</div>
)}
</div>
</>}

{step === "success" &&
<>
<h4 className="text-success">{msg}</h4>
Expand Down
6 changes: 3 additions & 3 deletions src/common/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@
"username": "Username:",
"email": "Email:",
"referral": "Referral:",
"copy-key": "Make sure you copy your password as you would be needing it to setup keychain.",
"copy-key": "Make sure you copy your master password as you would be needing it to setup keychain.",
"key-copied": "Password copied successfully",
"download-keys": "Download the rest of your keys by clicking here, and save them somewhere you won’t lose them",
"download-keys": "Download keys",
"create-account-hive": "Pay with HIVE",
"create-account-credit": "Pay with Account Credits ({{n}})",
"confirm-details": "Confirm Details",
Expand Down Expand Up @@ -222,7 +222,7 @@
"copy-tooltip": "Copy password",
"regenerate-password": "Regenerate password",
"copy-password": "Password copied successfully",
"copy-info-message": "Click QR code to copy account link and send to your onboarder/referrer (an existing Hive user you know)",
"copy-info-message": "Scan QR code or click to copy link and send to your onboarder / referrer",
"creating-for-a-friend": "You are creating an account for a friend.",
"success-message": "You successfully created the account ",
"sign-title": "Sign transaction with ",
Expand Down
Loading

0 comments on commit a275945

Please sign in to comment.