Skip to content

Commit

Permalink
feat: My collection lsit
Browse files Browse the repository at this point in the history
  • Loading branch information
ybgbob committed Nov 16, 2023
1 parent cd0c386 commit 0bd139e
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 35 deletions.
2 changes: 2 additions & 0 deletions src/components/layout/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export default function Layout({ children }: { children: ReactNode }) {
const { modalData: walletModalData, handleModalClose } = useWalletModal();
const walletModalOpen = walletModalData.modalState?.open;

console.log('walletModalData', walletModalData);

const {
openList,
initInfo,
Expand Down
21 changes: 0 additions & 21 deletions src/components/profile/MyCollectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,28 +87,7 @@ const MyCollectionList = (props: ICollectionList) => {
justifyContent={'flex-start'}
gap={6}
onClick={async () => {
// console.log('bucketId', bucketId);
// setSelectBucketId(bucketId);
navigator(`/detail?bid=${bucketId}`);
// const xx = await refetch();
// console.log('xx', xx);

// const list = state.globalState.breadList;
// const item = {
// path: '/profile',
// name: 'My Collections',
// query: p.toString(),
// };
// state.globalDispatch({
// type: 'ADD_BREAD',
// item,
// });

// navigator(
// `/resource?&bid=${id}&address=${address}&tab=dataList&from=${encodeURIComponent(
// JSON.stringify(list.concat([item])),
// )}${groupId ? '&gid=' + groupId : ''}`,
// );
}}
>
<ImgCon src={defaultImg(bucket_name, 40)}></ImgCon>
Expand Down
36 changes: 33 additions & 3 deletions src/components/resource/collection/CollectionInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { useGetCategory } from '../../../hooks/useGetCatoriesMap';
import { useGetObjectList } from '../../../hooks/useGetObjectList';
import { Loader } from '../../Loader';
import { FolderIcon } from '../../svgIcon/FolderIcon';
import { useAccount } from 'wagmi';
import { useWalletModal } from '../../../hooks/useWalletModal';

interface Props {
itemInfo: Item;
Expand All @@ -38,6 +40,8 @@ export const CollectionInfo = (props: Props) => {
const [p] = useSearchParams();
const { price: bnbPrice } = useBNBPrice();
const path = p.get('path') as string;
const { isConnected, isConnecting } = useAccount();
const { handleModalOpen } = useWalletModal();

const categroyInfo = useGetCategory(itemInfo.categoryId);

Expand Down Expand Up @@ -152,18 +156,44 @@ export const CollectionInfo = (props: Props) => {
</Flex>

{(relation === 'NOT_PURCHASE' || relation === 'UNKNOWN') && (
<Box>
<Button
color="#FFE900"
background="#665800"
onClick={() => {
if (!isConnected && !isConnecting) {
handleModalOpen();
} else {
modalData.modalDispatch({
type: 'OPEN_BUY',
buyData: itemInfo,
});
}
}}
>
Buy
</Button>
</Box>
)}

{relation === 'OWNER' && (
<Box>
<Button
color="#FFE900"
background="#665800"
onClick={() => {
modalData.modalDispatch({
type: 'OPEN_BUY',
buyData: itemInfo,
type: 'OPEN_DELIST',
delistData: {
groupId: itemInfo.groupId,
bucket_name: itemInfo.name,
create_at: itemInfo.createdAt,
owner: itemInfo.ownerAddress,
},
});
}}
>
Buy
Delist
</Button>
</Box>
)}
Expand Down
6 changes: 3 additions & 3 deletions src/components/resource/collection/CollectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ const CollectionList = (props: Props) => {
// name: generateGroupName(itemInfo.name, item.name),
// };
});
console.log('oidList', oidList);
// console.log('oidList', oidList);

const xx = useGetItemsByObjIds(oidList || []);
console.log('xx', xx);
// const xx = useGetItemsByObjIds(oidList || []);
// console.log('xx', xx[0]);

// const { list, loading } = useCollectionItems(
// itemInfo.name,
Expand Down
24 changes: 23 additions & 1 deletion src/components/resource/data/DataInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const DataInfo = (props: Props) => {

const modalData = useModal();
const { handleModalOpen } = useWalletModal();
console.log(itemInfo.categoryId);
// console.log(itemInfo.categoryId);

const categroyInfo = useGetCategory(itemInfo.categoryId);

Expand Down Expand Up @@ -159,6 +159,28 @@ export const DataInfo = (props: Props) => {
</Button>
</Box>
)}

{relation === 'OWNER' && (
<Box>
<Button
color="#FFE900"
background="#665800"
onClick={() => {
modalData.modalDispatch({
type: 'OPEN_DELIST',
delistData: {
groupId: itemInfo.groupId,
bucket_name: itemInfo.name,
create_at: itemInfo.createdAt,
owner: itemInfo.ownerAddress,
},
});
}}
>
Delist
</Button>
</Box>
)}
</ActionBox>
</Box>
</Box>
Expand Down
5 changes: 3 additions & 2 deletions src/components/resource/data/GetMyData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ export const GetMyData = (props: Props) => {
)}
</Flex>

{relation === 'NOT_PURCHASE' && <BuyData itemInfo={itemInfo} />}

{(relation === 'NOT_PURCHASE' || relation === 'UNKNOWN') && (
<BuyData itemInfo={itemInfo} />
)}
{relation !== 'NOT_PURCHASE' && (
<>
<Hr mt="25px" mb="25px" />
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useBuy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const useBuy = (
}
return false;
},
[status, BscBalanceVal, price, relayFee],
[status, price, relayFee, BscBalanceVal, state, address, navigator],
);
return { buy, relayFee };
};
6 changes: 2 additions & 4 deletions src/pages/Resource.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import styled from '@emotion/styled';
import { Box, Breadcrumb, BreadcrumbItem, Flex } from '@totejs/uikit';
import { Box, Flex } from '@totejs/uikit';
import { useMemo } from 'react';
import { useSearchParams } from 'react-router-dom';
import { useAccount } from 'wagmi';
import { Loader } from '../components/Loader';
import { ImgCon } from '../components/resource/ImgCon';
import { MyBreadcrumb } from '../components/resource/MyBreadcrumb';
import Overview from '../components/resource/Overview';
import { CollectionInfo } from '../components/resource/collection/CollectionInfo';
import CollectionList from '../components/resource/collection/CollectionList';
Expand All @@ -19,10 +20,7 @@ import {
} from '../hooks/useGetBucketOrObj';
import { useGetItemById } from '../hooks/useGetItemById';
import { useGetItemRelationWithAddr } from '../hooks/useGetItemRelationWithAddr';
import { useGfGetObjInfo } from '../hooks/useGfGetObjInfo';
import { reportEvent } from '../utils/ga';
import { MyBreadcrumb } from '../components/resource/MyBreadcrumb';
import { NoData } from '../components/NoData';

/**
* Have been listed
Expand Down

0 comments on commit 0bd139e

Please sign in to comment.