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

Rewards code review #136

Merged
merged 2 commits into from
Dec 3, 2024
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
Binary file added bun.lockb
Binary file not shown.
2 changes: 2 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ function App() {

const queryClient = new QueryClient()

// todo: we don't need SelectionProvider and DataProvider in app.concero.io anymore, these have to be removed.
// todo: the dark mode should be implemented via themeProvider later
return (
<PostHogProvider>
<I18Provider>
Expand Down
1 change: 1 addition & 0 deletions src/components/modals/RewardsUserHistory/UserAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const UserAction = ({ action }: UserActionProps) => {
}

const getQuestInfo = () => {
// todo: can we remove all "as" type casts?
const { name } = action.data as UserActionQuestData
setValue(`Quest completed: ${name}`)
}
Expand Down
6 changes: 6 additions & 0 deletions src/components/rewards/Quests/QuestsGroup/QuestsGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ export const QuestsGroup = ({ user }: QuestsCardProps) => {
const handleGetQuests = async () => {
let userQuestActions: IUserAction[] = []

// todo: calling fetchQuests twice
if (!user && !address) {
setQuests(await fetchQuests())
}

if (!user) return

// todo: promise.all
userQuestActions = await fetchUserQuestActions(user.address)
const fetchedQuests = await fetchQuests()

// todo: what is this used for?
const newQuests = fetchedQuests.map(quest => {
const userAction = userQuestActions.find(action => {
return action.documentId.toLocaleLowerCase() === quest._id.toLocaleLowerCase()
Expand All @@ -39,14 +42,17 @@ export const QuestsGroup = ({ user }: QuestsCardProps) => {
}

useEffect(() => {
// todo: this should not be named a handle as its not connected to a button
void handleGetQuests()
}, [user])

// todo: let's send sorted data from BE and not use filters and finds on the frontend
const campaignQuest = quests.find((quest: IQuest) => quest.type === QuestType.Campaign)
const dailyQuests = quests.filter((quest: IQuest) => quest.type === QuestType.Daily)
const primaryQuests = quests.filter((quest: IQuest) => quest.type === QuestType.Primary)
const secondaryQuests = quests.filter((quest: IQuest) => quest.type === QuestType.Secondary)

// todo: we have dailyQuests, therefore quests should be renamed
return (
<div className="gap-xxl">
{campaignQuest && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
align-items: center;
margin: var(--sp-lg);
}

/*todo: rename to rewardsWrapper*/
.rewardsWrap {
max-width: 600px;
width: 100%;
Expand Down
1 change: 1 addition & 0 deletions src/components/screens/RewardsScreen/RewardsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const RewardsScreen = () => {
setUser(currentUser!)
}

// todo: refactor user part into a separate component
return (
<>
<div className={classNames.rewardsScreenContainer}>
Expand Down
Loading