Skip to content

Commit

Permalink
Merge pull request #39 from spknetwork/feat/point-wallet-refactor
Browse files Browse the repository at this point in the history
points wallet refactor and community title
  • Loading branch information
Adesojisouljay authored May 20, 2024
2 parents eaff909 + a63a80b commit f57aece
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 22 deletions.
30 changes: 17 additions & 13 deletions src/common/components/wallet-ecency/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {claimPoints, getCurrencyTokenRate} from "../../api/private-api";
import { claimBaPoints} from "../../api/breakaway";
import { dateToFullRelative } from "../../helper/parse-date";
import { getCommunity } from "../../api/bridge";
import { Community } from "../../store/communities/types";

import {
accountGroupSvg,
Expand Down Expand Up @@ -173,6 +174,7 @@ export class TransactionRow extends Component<TransactionRowProps> {

interface Props {
global: Global;
myCommunity: Community
dynamicProps: DynamicProps
history: History;
activeUser: ActiveUser | null;
Expand Down Expand Up @@ -222,14 +224,15 @@ export const WalletEcency = (props: Props) => {
const {global, activeUser, account, points, history, fetchPoints, updateActiveUser} = props;

useEffect(() => {
console.log(props)
setIsMounted(true);
let user = history.location.pathname.split("/")[1];
user = user.replace('@','')
global.isElectron && initiateOnElectron(user);
getEstimatedPointsValue();
getCommunityInfo();
if (communityInfo && isMounted ) {
getPointsHistory(user, communityInfo?.title);
getPointsHistory(account.name, communityInfo?.title);
getUserPoints();
}

Expand Down Expand Up @@ -289,7 +292,7 @@ export const WalletEcency = (props: Props) => {
const getUserPoints = async (): Promise<any[] | undefined> => {

try {
const response: AxiosResponse | any = await getBaUserPoints(activeUser!.username, communityInfo?.title);
const response: AxiosResponse | any = await getBaUserPoints(account!?.name, communityInfo?.title);
if (response.status === 200) {
const userPoints = response.data.userPoints;
setUserPoints(userPoints[0])
Expand Down Expand Up @@ -418,7 +421,7 @@ export const WalletEcency = (props: Props) => {
</>
)}

<div className="balance-row estimated alternative">
{/* <div className="balance-row estimated alternative">
<div className="balance-info">
<div className="title">{_t("wallet.estimated-points")}</div>
<div className="description">{_t("wallet.estimated-description-points")}</div>
Expand All @@ -428,7 +431,7 @@ export const WalletEcency = (props: Props) => {
{estimatedPointsValueLoading ? `${_t("wallet.calculating")}...` : <FormattedCurrency {...props} value={estimatedPointsValue*parseFloat(userPoints?.pointsBalance)} fixAt={3} />}
</div>
</div>
</div>
</div> */}

<div className="balance-row alternative">
<div className="balance-info">
Expand All @@ -438,7 +441,7 @@ export const WalletEcency = (props: Props) => {
<div className="balance-values">
<div className="amount">

{
{/* {
(() => {
let dropDownConfig: any
if(isMyPage) {
Expand Down Expand Up @@ -472,7 +475,7 @@ export const WalletEcency = (props: Props) => {
</div>
)
})()
}
} */}


{/* {isMyPage && (
Expand All @@ -481,7 +484,7 @@ export const WalletEcency = (props: Props) => {
</div>
)} */}

<>{userPoints?.pointsBalance}.000 Points</>
<>{!userPoints ? "Fetching Point..." : userPoints?.pointsBalance + ".000 Points"}</>
</div>
</div>
</div>
Expand Down Expand Up @@ -514,12 +517,12 @@ export const WalletEcency = (props: Props) => {
<span className="reward-num">1</span>
</div>
</Tooltip>
<Tooltip content={_t('points.checkin-desc')}>
{/* <Tooltip content={_t('points.checkin-desc')}>
<div className="point-reward-type">
{starOutlineSvg}
<span className="reward-num">0.25</span>
</div>
</Tooltip>
</Tooltip> */}
<Tooltip content={_t('points.login-desc')}>
<div className="point-reward-type">
{accountOutlineSvg}
Expand All @@ -532,18 +535,18 @@ export const WalletEcency = (props: Props) => {
<span className="reward-num">10</span>
</div>
</Tooltip>
<Tooltip content={_t('points.delegation-desc')}>
{/* <Tooltip content={_t('points.delegation-desc')}>
<div className="point-reward-type">
{ticketSvg}
<span className="reward-num">10</span>
</div>
</Tooltip>
<Tooltip content={_t('points.community-desc')}>
</Tooltip> */}
{/* <Tooltip content={_t('points.community-desc')}>
<div className="point-reward-type">
{accountGroupSvg}
<span className="reward-num">20</span>
</div>
</Tooltip>
</Tooltip> */}
</div>
</div>
{/* {isMyPage && (
Expand Down Expand Up @@ -601,6 +604,7 @@ export const WalletEcency = (props: Props) => {
export default (p: Props) => {
const props = {
global: p.global,
myCommunity: p.myCommunity,
dynamicProps: p.dynamicProps,
history: p.history,
activeUser: p.activeUser,
Expand Down
2 changes: 1 addition & 1 deletion src/common/components/wallet-menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class WalletMenu extends Component<Props> {
//REMOVE USE PRIVATE FOR POINTS
<div className="wallet-menu">
<Link className={_c(`menu-item ecency ${active === "ecency" ? "active" : ""}`)} to={`/@${username}/points`}>
<span className="title">{communityInfo?.title}</span>
<span className="title">{global?.communityTitle}</span>
<span className="sub-title">Points</span>
<span className="platform-logo"><img alt="ecency" src={logo}/></span>
</Link>
Expand Down
10 changes: 5 additions & 5 deletions src/common/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -693,12 +693,12 @@
"claim-reward-points": "Claim reward points",
"main-description": "Points can be used for in-app services, like Promote, Boost, Gifting.",
"earn-points": "How to earn more Points",
"post-desc": "You can earn point by posting regularly. Posting gives you 15 points.",
"comment-desc": "Each comment you make helps you to grow your audience and make friendship but also earns you 5 points.",
"post-desc": "You can earn point by posting regularly. Posting gives you 10 points.",
"comment-desc": "Each comment you make helps you to grow your audience and make friendship but also earns you 10 points.",
"checkin-desc": "Checking in on Ecency gives you 0.25 points and helps you stay connected with your friends.",
"vote-desc": "By voting you give reward to other creators and show your appreciation but also earn 0.01 x vote weight points.",
"reblog-desc": "Share what post you like with your friends and earn 1 points.",
"login-desc": "When you login into Ecency you are entitled to earn 10 points automatically.",
"vote-desc": "By voting you give reward to other creators and show your appreciation but also earn 10 points.",
"reblog-desc": "Share what post you like with your friends and earn 10 points.",
"login-desc": "When you login, you are entitled to earn 10 points automatically.",
"checkin-extra-desc": "Consistent use of app gives you extra chances to earn more 10 points, be more active and earn more.",
"delegation-desc": "You can earn ~100 points per day for each 1000HP delegation.",
"community-desc": "Register your community to get 20 points for per post published with Ecency applications.",
Expand Down
4 changes: 2 additions & 2 deletions src/common/pages/_sign-up.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
display: flex;
justify-content: center;
width: 100%;
margin-top: 200px;
// margin-top: 200px;

@media (max-width: 470px) {
margin-top: 500px;
margin-top: 100px;
}

.success-info {
Expand Down
2 changes: 1 addition & 1 deletion src/common/pages/sign-up.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ const SignUpPage = (props: Props | any) => {
<div className="signup-wrapper">
{step === 1 && (
<div className="account-types align-self-center d-flex">
<h3>Sign up with</h3>
{/* <h3>Sign up with</h3> */}
<div
className="account-type"
onClick={() => handleAccountTypeClick("Hive")}
Expand Down
1 change: 1 addition & 0 deletions src/common/store/global/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const initialState: Global = {
tags: ["spk", "3speak"],
hive_id: "hive-112019",
baseApiUrl: "https://account-creator.3speak.tv/api",
communityTitle: ""
};

export default (state: Global = initialState, action: Actions): Global => {
Expand Down
1 change: 1 addition & 0 deletions src/common/store/global/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export interface Global {
ctheme: string;
hive_id: string;
tags: string[];
communityTitle: string;
}

export enum ActionTypes {
Expand Down
4 changes: 4 additions & 0 deletions src/server/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import config from "../config";
import { getSearchIndexCount, getDynamicProps } from "./helper";

import { getOperatingSystem } from "../common/util/platform";
import { getCommunity } from "../common/api/bridge";

export const makePreloadedState = async (
req: express.Request
Expand All @@ -23,6 +24,8 @@ export const makePreloadedState = async (

const activeUser = _c("active_user") || null;

const communityData = await getCommunity(config.hive_id)

const theme =
_c("theme") && Object.values(Theme).includes(_c("theme"))
? _c("theme")
Expand Down Expand Up @@ -53,6 +56,7 @@ export const makePreloadedState = async (
ctheme: config.theme,
tags: [...config.tags],
baseApiUrl: config.baseApiUrl,
communityTitle: communityData!.title
};

const dynamicProps = await getDynamicProps();
Expand Down

0 comments on commit f57aece

Please sign in to comment.