feat: xlog achievements
This commit is contained in:
@@ -66,5 +66,7 @@
|
||||
"What is Mira? Where can I get some?" : "Mira 是什么?我在哪里可以获得?",
|
||||
"Tip": "赞赏",
|
||||
"Tip the post: {{name}}": "赞赏文章:{{name}}",
|
||||
"Custom": "自定义"
|
||||
"Custom": "自定义",
|
||||
"Mintable": "可铸造",
|
||||
"Comming soon": "即将推出"
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { AchievementSection } from "crossbell.js"
|
||||
import type { AchievementSection } from "~/models/site.model"
|
||||
import { Image } from "~/components/ui/Image"
|
||||
import { AchievementModal } from "~/components/common/AchievementModal"
|
||||
import { useEffect, useState } from "react"
|
||||
@@ -50,10 +50,14 @@ export const AchievementItem: React.FC<{
|
||||
? group.items.filter((item) => item.status === "MINTABLE").pop()
|
||||
: null
|
||||
|
||||
const achievementComming = isOwner
|
||||
? group.items.filter((item) => item.status === "COMMING").pop()
|
||||
: null
|
||||
|
||||
const [opened, setOpened] = useState(false)
|
||||
|
||||
if (isOwner) {
|
||||
if (!achievement && !achievementMintable) {
|
||||
if (!achievement && !achievementMintable && !achievementComming) {
|
||||
return null
|
||||
}
|
||||
} else {
|
||||
@@ -73,7 +77,10 @@ export const AchievementItem: React.FC<{
|
||||
}}
|
||||
>
|
||||
<Badge
|
||||
media={(achievement || achievementMintable)!.info.media}
|
||||
media={
|
||||
(achievement || achievementMintable || achievementComming)!.info
|
||||
.media
|
||||
}
|
||||
className={`mb-1 ${!achievement && "grayscale"}`}
|
||||
size={size}
|
||||
/>
|
||||
@@ -110,7 +117,7 @@ export const AchievementItem: React.FC<{
|
||||
)
|
||||
.humanize(),
|
||||
})
|
||||
: "Mintable"}
|
||||
: t(achievementMintable ? "Mintable" : "Comming soon")}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Modal, Stepper } from "@mantine/core"
|
||||
import type { AchievementSection } from "crossbell.js"
|
||||
import type { AchievementSection } from "~/models/site.model"
|
||||
import { Image } from "~/components/ui/Image"
|
||||
import Tilt from "react-parallax-tilt"
|
||||
import { Badge } from "~/components/common/AchievementItem"
|
||||
@@ -29,8 +29,11 @@ export const AchievementModal: React.FC<{
|
||||
? group.items.filter((item) => item.status === "MINTABLE").pop()
|
||||
: null
|
||||
|
||||
const achievementComming = isOwner
|
||||
? group.items.filter((item) => item.status === "COMMING").pop()
|
||||
: null
|
||||
|
||||
const router = useRouter()
|
||||
const handle = router.query.handle as string
|
||||
const mintAchievement = useMintAchievement()
|
||||
|
||||
const mint = async (tokenId: number) => {
|
||||
@@ -69,7 +72,10 @@ export const AchievementModal: React.FC<{
|
||||
>
|
||||
<div
|
||||
className="inline-flex flex-col text-center items-center text-white"
|
||||
key={(achievement || achievementMintable)!.info.tokenId}
|
||||
key={
|
||||
(achievement || achievementMintable || achievementComming)!.info
|
||||
.name
|
||||
}
|
||||
>
|
||||
<Tilt
|
||||
className={`inline-block w-80 h-80 relative rounded-full bg-white mb-4 preserve-3d shadow-[inset_#a8a29e_34px_-34px_74px] p-[4%] ${
|
||||
@@ -86,7 +92,10 @@ export const AchievementModal: React.FC<{
|
||||
<Image
|
||||
fill
|
||||
alt="achievement"
|
||||
src={(achievement || achievementMintable)!.info.media}
|
||||
src={
|
||||
(achievement || achievementMintable || achievementComming)!.info
|
||||
.media
|
||||
}
|
||||
className="relative w-full h-full"
|
||||
style={{
|
||||
transform: "translateZ(20px)",
|
||||
@@ -98,7 +107,10 @@ export const AchievementModal: React.FC<{
|
||||
{group.info.title} {achievement && `#${achievement.tokenId}`}
|
||||
</span>
|
||||
<span className="text-lg text-gray-100 capitalize truncate">
|
||||
{(achievement || achievementMintable)!.info.description}
|
||||
{
|
||||
(achievement || achievementMintable || achievementComming)!.info
|
||||
.description
|
||||
}
|
||||
</span>
|
||||
<span className="text-gray-300 leading-snug flex items-center justify-center">
|
||||
{achievement ? (
|
||||
@@ -126,7 +138,7 @@ export const AchievementModal: React.FC<{
|
||||
</span>
|
||||
</>
|
||||
) : (
|
||||
<>Mintable</>
|
||||
t(achievementMintable ? "Mintable" : "Comming soon")
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
+107
-4
@@ -583,13 +583,116 @@ export async function getTips(
|
||||
return tips
|
||||
}
|
||||
|
||||
export const getAchievements = (characterId: number) => {
|
||||
return indexer.getAchievements(characterId)
|
||||
export type AchievementSection = {
|
||||
info: {
|
||||
name: string
|
||||
title: string
|
||||
}
|
||||
groups: {
|
||||
info: {
|
||||
name: string
|
||||
title: string
|
||||
}
|
||||
items: {
|
||||
tokenId: number
|
||||
name: string
|
||||
status: "INACTIVE" | "MINTABLE" | "MINTED" | "COMMING"
|
||||
mintedAt: string | null
|
||||
transactionHash: string | null
|
||||
info: {
|
||||
tokenId: number
|
||||
name: string
|
||||
description: string
|
||||
media: string
|
||||
attributes: [
|
||||
{
|
||||
trait_type: string
|
||||
value: string
|
||||
},
|
||||
]
|
||||
}
|
||||
}[]
|
||||
}[]
|
||||
}
|
||||
|
||||
export const mintAchievement = async (input: {
|
||||
export async function getAchievements(characterId: number) {
|
||||
const crossbellAchievements = (await indexer.getAchievements(characterId))
|
||||
?.list as AchievementSection[] | undefined
|
||||
const xLogAchievements: AchievementSection[] = [
|
||||
{
|
||||
info: {
|
||||
name: "xlog-journey",
|
||||
title: "xLog Journey",
|
||||
},
|
||||
groups: [
|
||||
{
|
||||
info: {
|
||||
name: "showcase-superstar",
|
||||
title: "Showcase Superstar",
|
||||
},
|
||||
items: [
|
||||
{
|
||||
info: {
|
||||
attributes: [
|
||||
{
|
||||
trait_type: "tier",
|
||||
value: "base",
|
||||
},
|
||||
],
|
||||
description: "I am a superstar on xLog!",
|
||||
media:
|
||||
"ipfs://QmVnTtYC4yQ7D1eGb3Ke9NVDadovSPZeg2q2cYA6j275Um/influencer/influencer:special.png",
|
||||
tokenId: 0,
|
||||
name: "Showcase Superstar",
|
||||
},
|
||||
tokenId: 0,
|
||||
name: "showcase-superstar",
|
||||
status: "COMMING",
|
||||
mintedAt: null,
|
||||
transactionHash: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
info: {
|
||||
name: "mirror-xyz-migrator",
|
||||
title: "Mirror.xyz Migrator",
|
||||
},
|
||||
items: [
|
||||
{
|
||||
info: {
|
||||
attributes: [
|
||||
{
|
||||
trait_type: "tier",
|
||||
value: "base",
|
||||
},
|
||||
],
|
||||
description: "I migrated from Mirror.xyz to xLog!",
|
||||
media:
|
||||
"ipfs://bafybeicqfeaco6skylodk3cridjvntdxvbdaqhbtkky7exsxgdrzfp7gae",
|
||||
tokenId: 0,
|
||||
name: "Mirror.xyz Migrator",
|
||||
},
|
||||
tokenId: 0,
|
||||
name: "mirror-xyz-migrator",
|
||||
status: "COMMING",
|
||||
mintedAt: null,
|
||||
transactionHash: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
return {
|
||||
list: [...xLogAchievements, ...(crossbellAchievements || [])],
|
||||
}
|
||||
}
|
||||
|
||||
export async function mintAchievement(input: {
|
||||
characterId: number
|
||||
achievementId: number
|
||||
}) => {
|
||||
}) {
|
||||
return indexer.mintAchievement(input.characterId, input.achievementId)
|
||||
}
|
||||
|
||||
@@ -42,10 +42,10 @@ export default function AchievementsPage() {
|
||||
|
||||
return (
|
||||
<DashboardMain title="Achievements">
|
||||
<div className="min-w-[270px] max-w-screen-xl flex flex-col xl:flex-row space-y-8 xl:space-y-0">
|
||||
<div className="min-w-[270px] max-w-screen-lg flex flex-col space-y-8">
|
||||
<>
|
||||
{achievement.data?.list?.map((series) => {
|
||||
let length = series.groups.length
|
||||
let length = series.groups?.length
|
||||
if (!length) {
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user