Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: (#16): Fix edit function #23

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/views/MarketplaceV2/Views/User/UserStyle.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.user-input {
width: 100%;
background-color: transparent;
color: #ffff;
border: none;
border-bottom: 1px solid #3898b8;
}
28 changes: 20 additions & 8 deletions src/views/MarketplaceV2/Views/User/Usermain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ const UserMain = (props) => {
const {
txHistory: { coin, nft },
activityHistory,
stats,
userInfo,
tabController: { active },
handleFunctions: { handleUserInfo },
} = props
const txD = React.useMemo(() => (active === 0 ? coin : nft), [active, coin, nft])

const [enableEdit, setEnableEdit] = useState<boolean>(false)
const handleEdit = () => {
setEnableEdit(!enableEdit)
}
const boxInfo = (name: string, tooltip: string) => {
return (
<Flex alignItems="center" justifyContent="space-between">
Expand All @@ -52,24 +56,32 @@ const UserMain = (props) => {
<Grid container spacing={2}>
<Grid item xs={12} sm={10}>
<Grid container spacing={{ xs: 1, sm: 2 }}>
{Object.entries(stats.basicInfo).map((stat) => {
const field = FIELD_INFO[`${stat[0]}`]
const val = stat[1]
{Object.entries(userInfo).map((info) => {
const field = FIELD_INFO[`${info[0]}`]
const val = info[1].toString()
return (
<>
<Grid item xs={5} sm={5}>
<H5 fsize="0.9em">{field}</H5>
<H5 fsize="0.9em">{field}:</H5>
</Grid>
<Grid item xs={7} sm={7}>
<P fsize="0.9em">: {val}</P>
{enableEdit ? (
<input
className='user-input'
value={val}
onChange={(e) => handleUserInfo({ field: info[0], value: e.target.value })}
/>
) : (
<P fsize="0.9em">{val}</P>
)}
</Grid>
</>
)
})}
</Grid>
</Grid>
<Grid item xs={12} sm={2} display="flex" alignItems="center" justifyContent="center">
<IconButton variant="text" className="icon-button">
<IconButton variant="text" className="icon-button" onClick={handleEdit}>
<MiniBox>
<Iconloader type="fa" name="Edit" fontSize="1em" />
</MiniBox>
Expand Down
20 changes: 13 additions & 7 deletions src/views/MarketplaceV2/Views/User/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import withGridLayout from './withGridLayout'
import Main from '../Main'
import UserMain from './Usermain'
import NftCollection from './NftCollection'
import './UserStyle.css'

// Tempdata collection

const tempStats = {
basicInfo: {
email: '[email protected]',
wallet: '0x0000',
credit: 'NA',
},
const tempUserInfo = {
email: '[email protected]',
wallet: '0x0000',
credit: 'NA',
}

const tempActivityData = [
Expand Down Expand Up @@ -69,6 +68,12 @@ const WrappedNftList = withGridLayout(NftCollection)

const User = () => {
const [active, setActive] = useState(0)
// TODO: Replace with actual data
const [userInfo, setUserInfo] = useState(tempUserInfo)
const handleUserInfo = (payload: { field: string, value: string }) => {
setUserInfo({ ...userInfo, [`${payload.field}`]: payload.value })
console.log(userInfo)
}
return (
<Main>
<TextWrapper>
Expand All @@ -80,7 +85,8 @@ const User = () => {
tabController: { active, setActive },
txHistory: { ...tempTx },
activityHistory: tempActivityData,
stats: tempStats,
userInfo,
handleFunctions: { handleUserInfo },
}}
/>
<WrappedNftList {...{ mediaQ: { xs: 12, md: 6, lg: 7 } }} />
Expand Down
Loading