Skip to content

Commit

Permalink
Merge pull request #51 from AzimovS/fix-searchBar-stats
Browse files Browse the repository at this point in the history
Fix search bar stats
  • Loading branch information
azf20 authored May 8, 2024
2 parents 9d4e9e8 + 1215e22 commit dbb3461
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 46 deletions.
2 changes: 1 addition & 1 deletion packages/react-app/src/Artist.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export default function Artist(props) {
const data = await response.json();
data.image = data.image.replace(
"https://ipfs.io/ipfs/",
"https://nifty-ink.mypinata.cloud/ipfs/"
"https://gateway.nifty.ink:42069/ipfs/"
);
return data;
};
Expand Down
20 changes: 10 additions & 10 deletions packages/react-app/src/Stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function Stats(props) {
const [dailyTotals, setDailyTotals] = useState(null)
const [period, setPeriod] = useState("month")
const [totalData, setTotalData] = useState({})
const [startingDate, setStartingDate] = useState(dailyDate)
const [startingDate, setStartingDate] = useState(dayjs().utc().startOf("day").subtract(28, "day").unix())


const handleChartHover = (hoverLoc, activePoint) => {
Expand All @@ -65,20 +65,20 @@ export default function Stats(props) {
console.log("before", totalDataBefore.totals)
console.log("now", totalDataNow.totals)
setTotalData({
tokens: totalDataNow.totals[0].tokens - totalDataBefore.totals[0].tokens,
inks: totalDataNow.totals[0].inks - totalDataBefore.totals[0].inks,
saleValue: ethers.utils.formatEther(totalDataNow.totals[0].saleValue) - ethers.utils.formatEther(totalDataBefore.totals[0].saleValue),
sales: totalDataNow.totals[0].sales - totalDataBefore.totals[0].sales,
upgrades: totalDataNow.totals[0].upgrades - totalDataBefore.totals[0].upgrades,
users: totalDataNow.totals[0].users - totalDataBefore.totals[0].users,
artists: totalDataNow.totals[0].artists - totalDataBefore.totals[0].artists
tokens: totalDataNow.totals[0].tokens - (totalDataBefore?.totals[0]?.tokens || 0),
inks: totalDataNow.totals[0].inks - (totalDataBefore?.totals[0]?.inks||0),
saleValue: ethers.utils.formatEther(totalDataNow?.totals[0]?.saleValue) - (ethers.utils.formatEther(totalDataBefore?.totals[0]?.saleValue || 0)),
sales: totalDataNow.totals[0].sales - (totalDataBefore?.totals[0]?.sales || 0),
upgrades: totalDataNow.totals[0].upgrades - (totalDataBefore?.totals[0]?.upgrades|| 0),
users: totalDataNow.totals[0].users - (totalDataBefore?.totals[0]?.users || 0),
artists: totalDataNow.totals[0].artists - (totalDataBefore?.totals[0]?.artists || 0)
})
}
}, [totalDataBefore, totalDataNow])

useEffect(() => {
if (period == "month") {
setStartingDate(dayjs().utc().startOf("day").subtract(1, "month").unix())
setStartingDate(dayjs().utc().startOf("day").subtract(28, "day").unix())
} else if (period == "week") {
setStartingDate(dayjs().utc().startOf("day").subtract(1, "week").unix())
} else if (period == "year") {
Expand Down Expand Up @@ -221,7 +221,7 @@ export default function Stats(props) {
/>
<StatCard
name={"Sale Value"}
value={totalData.saleValue?.toFixed(2)}
value={Number(totalData.saleValue)?.toFixed(2)}
emoji={"💲"}
/>
<StatCard
Expand Down
3 changes: 1 addition & 2 deletions packages/react-app/src/ViewInk.js
Original file line number Diff line number Diff line change
Expand Up @@ -953,8 +953,7 @@ export default function ViewInk(props) {
width: size[0],
height: size[0],
margin: "0 auto",
border: "1px solid #999999",
boxShadow: "2px 2px 8px #AAAAAA"
outline: "3px solid #999999",
}}
>
<div style={{ position: "relative" }}>
Expand Down
39 changes: 6 additions & 33 deletions packages/react-app/src/components/AddressInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,11 @@ import { Input, Badge } from 'antd';

export default function AddressInput(props) {

const [ ens, setEns ] = useState(0)
const [ value, setValue ] = useState()
const [isAddressFound, setIsAddressFound] = useState(false);

const currentValue = typeof props.value != "undefined"?props.value:value

useEffect(()=>{
setEns("")
if(currentValue && props.ensProvider){
async function getEns(){
let newEns
try{
console.log("trying reverse ens",newEns)

newEns = await props.ensProvider.lookupAddress(currentValue)
console.log("setting ens",newEns)
setEns(newEns)
}catch(e){}
console.log("checking resolve")
if( currentValue.indexOf(".eth")>0 || currentValue.indexOf(".xyz")>0 ){
try{
console.log("resolving")
let possibleAddress = await props.ensProvider.resolveName(currentValue);
console.log("GOT:L",possibleAddress)
if(possibleAddress){
setEns(currentValue)
props.onChange(possibleAddress)
}
}catch(e){}
}
}
getEns()
}
},[props.value])


const [ scan, setScan ] = useState(false)

let scannerButton = (
Expand All @@ -62,8 +32,11 @@ export default function AddressInput(props) {
let possibleAddress = await props.ensProvider.resolveName(address);
if(possibleAddress){
address = possibleAddress
setIsAddressFound(true);
}
}catch(e){}
} else {
setIsAddressFound(true);
}
setValue(address)
if(typeof props.onChange == "function") { props.onChange(address) }
Expand Down Expand Up @@ -105,10 +78,10 @@ export default function AddressInput(props) {
<div>
{scanner}
<Input
autoFocus={props.autoFocus}
autoFocus={!isAddressFound}
placeholder={props.placeholder?props.placeholder:"address"}
prefix={<Blockie address={currentValue} size={8} scale={3}/>}
value={ens?ens:currentValue}
value={currentValue}
addonAfter={scannerButton}
onChange={(e)=>{
updateAddress(e.target.value)
Expand Down

0 comments on commit dbb3461

Please sign in to comment.