mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-04-24 03:00:09 -04:00
* feat: set up quests dashboard move quest explorer to /quests/general * feat: prepare containers for path-of-the-engaged and initiation quests * chore(release): 0.2.0 * feat: add metacollab and web 3 onboarding categories * feat: move initiation quests from notion -> metaOS awyiss it's happening * chore: lint quickfix * feat: add descriptions, objectives, checkbox, collapse/expand * add Dockerfile to .gitignore * go * quick fix * upload proof modal * config and install * upload proof works * show status of quests (pending, etc..) * remove initiation & update engaged quests * fix quest categories add bridgebuilders, builders, patrons, fix icons * typecheck fix * fix address for bridgebuilders quests * design of chain progress + small fix * minor fixes * using latest version of quest-chains sdk * basic UI for quests * using children for react-markdown * better styling for quest tiles * completed quest chain styling * fixed toasts * fixed imageLink * added link to quest chains * minor fixes * added back to onboarding paths link * fixed external link icon as absolute pos * reduce gaps for mobile Co-authored-by: Vid <vid@meisterlabs.com> Co-authored-by: dan13ram <dan13ram@gmail.com>
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import { graphql } from '@quest-chains/sdk';
|
|
import { useEffect, useMemo, useState } from 'react';
|
|
|
|
import { UserStatusType } from './useUserStatus';
|
|
|
|
type UserProgresstype = {
|
|
progress: {
|
|
total: number;
|
|
inReviewCount: number;
|
|
completeCount: number;
|
|
};
|
|
canMint: boolean;
|
|
};
|
|
|
|
export const useUserProgress = (
|
|
address: string | undefined | null,
|
|
questChain: graphql.QuestChainInfoFragment | null,
|
|
userStatus: UserStatusType,
|
|
): UserProgresstype => {
|
|
const [progress, setProgress] = useState({
|
|
total: 0,
|
|
inReviewCount: 0,
|
|
completeCount: 0,
|
|
});
|
|
useEffect(() => {
|
|
if (questChain) {
|
|
if (questChain?.quests) {
|
|
const inReviewCount = questChain.quests.filter(
|
|
(quest) =>
|
|
!quest.paused &&
|
|
userStatus[quest.questId]?.status === graphql.Status.Review,
|
|
).length;
|
|
const completeCount = questChain.quests.filter(
|
|
(quest) =>
|
|
!quest.paused &&
|
|
userStatus[quest.questId]?.status === graphql.Status.Pass,
|
|
).length;
|
|
|
|
setProgress({
|
|
inReviewCount: inReviewCount || 0,
|
|
completeCount: completeCount || 0,
|
|
total: questChain.quests.filter((q) => !q.paused).length || 0,
|
|
});
|
|
}
|
|
}
|
|
}, [questChain, userStatus]);
|
|
|
|
const canMint = useMemo(
|
|
() =>
|
|
!!address &&
|
|
!!questChain?.token &&
|
|
!questChain.token.owners.find((o) => o.id === address.toLowerCase()) &&
|
|
progress.completeCount > 0 &&
|
|
progress.completeCount === progress.total,
|
|
[questChain, address, progress],
|
|
);
|
|
|
|
return { progress, canMint };
|
|
};
|