Skip to content

Commit 39b04b8

Browse files
committed
Improved UI
1 parent 290c822 commit 39b04b8

File tree

2 files changed

+3
-45
lines changed

2 files changed

+3
-45
lines changed

packages/nextjs/app/profile/_components/BoughtArticles.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const BoughtArticles: NextPage = () => {
4646
const {
4747
data: boughtEvents,
4848
// isLoading: createIsLoadingEvents,
49-
error: boughtErrorReadingEvents,
49+
// error: boughtErrorReadingEvents,
5050
} = useScaffoldEventHistory({
5151
contractName: "BasedShop",
5252
eventName: "ArticleBought",

packages/nextjs/app/profile/_components/_bought/PostCard.tsx

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import Image from "next/image";
55
import BookmarkButton from "../../../../components/punk-society/BookmarkButton";
66
import { ProfileAddress } from "../../../../components/punk-society/ProfileAddress";
77
import { formatEther } from "viem";
8-
import { useAccount } from "wagmi";
9-
import { MagnifyingGlassPlusIcon, ShareIcon, ShoppingCartIcon, XMarkIcon } from "@heroicons/react/24/outline";
10-
import { useScaffoldReadContract, useScaffoldWriteContract } from "~~/hooks/scaffold-eth";
8+
import { MagnifyingGlassPlusIcon, ShareIcon, XMarkIcon } from "@heroicons/react/24/outline";
9+
import { useScaffoldReadContract } from "~~/hooks/scaffold-eth";
1110
import { notification } from "~~/utils/scaffold-eth";
1211
import { NFTMetaData } from "~~/utils/simpleNFT/nftsMetadata";
1312

@@ -23,17 +22,6 @@ export interface Post extends Partial<NFTMetaData> {
2322

2423
export const PostCard = ({ post }: { post: Post }) => {
2524
const [isModalOpen, setIsModalOpen] = useState(false);
26-
const [loading, setLoading] = useState(false);
27-
28-
const { address: connectedAddress } = useAccount();
29-
const { writeContractAsync } = useScaffoldWriteContract("BasedShop");
30-
31-
const { data: profileInfo } = useScaffoldReadContract({
32-
contractName: "BasedProfile",
33-
functionName: "profiles",
34-
args: [post.user],
35-
watch: true,
36-
});
3725

3826
const { data: articlePrice } = useScaffoldReadContract({
3927
contractName: "BasedShop",
@@ -42,10 +30,6 @@ export const PostCard = ({ post }: { post: Post }) => {
4230
watch: true,
4331
});
4432

45-
const defaultProfilePicture = "/guest-profile.jpg";
46-
47-
const profilePicture = profileInfo && profileInfo[2] ? profileInfo[2] : defaultProfilePicture;
48-
4933
const handleOpenModal = () => {
5034
setIsModalOpen(true);
5135
};
@@ -76,32 +60,6 @@ export const PostCard = ({ post }: { post: Post }) => {
7660
}
7761
};
7862

79-
const handleBuyArticle = async () => {
80-
if (!connectedAddress) {
81-
notification.error("Please connect your wallet");
82-
return;
83-
}
84-
85-
setLoading(true);
86-
87-
try {
88-
const contractResponse = await writeContractAsync({
89-
functionName: "buyArticle",
90-
args: [BigInt(post.postId || 0)],
91-
value: articlePrice,
92-
});
93-
94-
if (contractResponse) {
95-
notification.success("Posted successfully!");
96-
}
97-
} catch (error) {
98-
console.error("Error during posting:", error);
99-
notification.error("Posting failed, please try again.");
100-
} finally {
101-
setLoading(false);
102-
}
103-
};
104-
10563
const formatDate = (timestamp: number): string => {
10664
const date = new Date(timestamp * 1000); // Convert to milliseconds
10765
return date.toLocaleDateString(); // Format the date as needed

0 commit comments

Comments
 (0)