Skip to content

Commit

Permalink
Merge pull request #2197 from wondrous-dev/add-pokt-pda-edit
Browse files Browse the repository at this point in the history
feat: add pokt edit pda
  • Loading branch information
andywong418 authored Jan 30, 2024
2 parents 4e82a1b + 6522b49 commit febe04a
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 9 deletions.
4 changes: 4 additions & 0 deletions wondrous-bot-admin/src/components/CreateTemplate/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ const mapReward = (reward) => {
} else if (reward?.type === PAYMENT_OPTIONS.PDA) {
return {
type: reward?.type,
pdaRewardData: {
pdaSubtype: reward?.pdaSubtype || reward?.pdaRewardData?.pdaSubtype,
pdaPoints: Number(reward?.pdaPoints) || Number(reward?.pdaRewardData?.pdaPoints),
},
};
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,14 @@ const QuestRewardComponent = ({
},
[PAYMENT_OPTIONS.PDA]: {
Component: ({ reward }) => {
return <RewardWrapper Icon={GatewayPDAIcon} text={"Citizen PDA"} />;
return (
<RewardWrapper
Icon={GatewayPDAIcon}
text={`${reward?.pdaSubtype || reward?.pdaRewardData?.pdaSubtype} - ${
reward?.pdaRewardData?.pdaPoints
} pts`}
/>
);
},
handleOnRemove: (reward) => handlePDARewardRemove({ reward, setQuestSettings }),
},
Expand Down
10 changes: 10 additions & 0 deletions wondrous-bot-admin/src/components/Rewards/RewardModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ const RewardModal = ({
createPaymentMethod,
setCmtyStoreItemReward,
cmtyStoreItemReward,
setPdaPoints,
setPdaSubtype,
pdaPoints,
pdaSubtype,
} = rewardModalState;

const handleAddRewardOnModal = () => {
Expand Down Expand Up @@ -132,6 +136,8 @@ const RewardModal = ({
type: rewardType,
handleOnRewardAdd,
handleToggle: handleRewardModalToggle,
pdaPoints,
pdaSubtype,
});
}
default:
Expand Down Expand Up @@ -280,6 +286,10 @@ const RewardModal = ({
poapReward={poapReward}
setPoapReward={setPoapReward}
guildId={discordRoleData[0]?.guildId}
setPdaPoints={setPdaPoints}
setPdaSubtype={setPdaSubtype}
pdaPoints={pdaPoints}
pdaSubtype={pdaSubtype}
/>
</Grid>
</Grid>
Expand Down
26 changes: 21 additions & 5 deletions wondrous-bot-admin/src/components/Rewards/RewardUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@ export const RewardMethod = ({
guildId,
setCmtyStoreItemReward,
cmtyStoreItemReward,
setPdaPoints,
setPdaSubtype,
pdaPoints,
pdaSubtype,
}) => {
const [getPoapEventInfo] = useLazyQuery(GET_POAP_EVENT);
const [displayRoleDisclaimer, setDisplayRoleDisclaimer] = useState(false);
Expand Down Expand Up @@ -458,11 +462,23 @@ export const RewardMethod = ({
<>
<Label>PDA Type</Label>
<SelectComponent options={pdaTypeOptions} value={pdaTypeOptions[0].value} disabled onChange={() => {}} />
<RewardText>
Please note that you can configure the <span style={{ fontWeight: "bold" }}> point </span>field of the PDA by
changing the points reward of this quest and the <span style={{ fontWeight: "bold" }}>pdaSubtype</span> field
by changing the quest title. For now, we only support the Citizen PDA type.
</RewardText>
<Label>PDA Subtype</Label>
<TextField
placeholder="Please enter the PDA subtype for this reward"
value={pdaSubtype}
error={errors?.pdaSubtype}
onChange={(value) => setPdaSubtype(value)}
multiline={false}
/>
<Label>PDA points</Label>
<TextField
placeholder="Please input the PDA points awarded for this reward"
value={pdaPoints}
error={errors?.pdaPoints}
onChange={(value) => setPdaPoints(value)}
multiline={false}
type="number"
/>
</>
);
}
Expand Down
12 changes: 11 additions & 1 deletion wondrous-bot-admin/src/components/Rewards/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,11 @@ export const handleAddPoap = ({ poapReward, setErrors, errors, handleOnRewardAdd
handleToggle();
};

export const handleaddPDAItem = ({ type, handleToggle, handleOnRewardAdd }) => {
export const handleaddPDAItem = ({ type, pdaPoints, pdaSubtype, handleToggle, handleOnRewardAdd }) => {
handleOnRewardAdd({
type,
pdaPoints,
pdaSubtype,
});
handleToggle();
};
Expand Down Expand Up @@ -262,6 +264,8 @@ export const useAddRewardModalState = (defaultRewardType = PAYMENT_OPTIONS.DISCO
const [discordRoleReward, setDiscordRoleReward] = useState(null);
const [paymentMethod, setPaymentMethod] = useState(null);
const [cmtyStoreItemReward, setCmtyStoreItemReward] = useState(null);
const [pdaSubtype, setPdaSubtype] = useState("");
const [pdaPoints, setPdaPoints] = useState(null);
const [tokenReward, setTokenReward] = useState({
tokenName: null,
contractAddress: null,
Expand Down Expand Up @@ -294,6 +298,8 @@ export const useAddRewardModalState = (defaultRewardType = PAYMENT_OPTIONS.DISCO
setIsRewardModalOpen(false);
setDiscordRoleReward(null);
setPaymentMethod(null);
setPdaPoints(null);
setPdaSubtype("");
setTokenReward({
tokenName: null,
contractAddress: null,
Expand Down Expand Up @@ -337,6 +343,10 @@ export const useAddRewardModalState = (defaultRewardType = PAYMENT_OPTIONS.DISCO
cmtyStoreItemReward,
setCmtyStoreItemReward,
resetStates,
setPdaPoints,
setPdaSubtype,
pdaPoints,
pdaSubtype,
...tokenRewardData,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const selectReward = ({ type, value }) => {
Icon: StoreItemRewardIcon,
},
[PAYMENT_OPTIONS.PDA]: {
text: "Citizen PDA",
text: value,
Icon: GatewayPDAIcon,
},
};
Expand Down
12 changes: 12 additions & 0 deletions wondrous-bot-admin/src/graphql/fragments/quest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ export const MinimalQuestFragment = gql`
expiryDate
eventSecret
}
pdaRewardData {
pdaSubtype
pdaPoints
}
paymentMethodId
amount
storeItemId
Expand Down Expand Up @@ -120,6 +124,10 @@ export const QuestFragment = gql`
expiryDate
eventSecret
}
pdaRewardData {
pdaSubtype
pdaPoints
}
paymentMethodId
amount
storeItemId
Expand Down Expand Up @@ -200,6 +208,10 @@ export const QuestFragment = gql`
expiryDate
eventSecret
}
pdaRewardData {
pdaSubtype
pdaPoints
}
paymentMethodId
amount
paymentMethod {
Expand Down
12 changes: 12 additions & 0 deletions wondrous-bot-admin/src/graphql/queries/quest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export const GET_QUESTS_FOR_ORG = gql`
expiryDate
eventSecret
}
pdaRewardData {
pdaSubtype
pdaPoints
}
paymentMethodId
amount
storeItemId
Expand Down Expand Up @@ -96,6 +100,10 @@ export const GET_ORG_LEVEL_REWARDS = gql`
expiryDate
eventSecret
}
pdaRewardData {
pdaSubtype
pdaPoints
}
paymentMethodId
amount
paymentMethod {
Expand Down Expand Up @@ -191,6 +199,10 @@ export const GET_QUEST_REWARDS = gql`
expiryDate
eventSecret
}
pdaRewardData {
pdaSubtype
pdaPoints
}
paymentMethodId
amount
storeItemId
Expand Down
1 change: 0 additions & 1 deletion wondrous-bot-admin/src/utils/transformQuestConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ export function transformQuestConfig(obj: InputQuestStep[]): OutputQuestStep[] {
} else if (step.type === TYPES.REFERRAL) {
outputStep.value = step?.prompt;
} else if (step.type === TYPES.VERIFY_GITCOIN_PASSPORT_SCORE) {
console.log("step", step);
outputStep.value = {
prompt: step?.prompt,
gitcoinPassportMinimumScoreThreshold: step?.additionalData?.gitcoinPassportMinimumScoreThreshold,
Expand Down

0 comments on commit febe04a

Please sign in to comment.