Skip to content

Commit

Permalink
dont override default reward type for new rewards (#3511)
Browse files Browse the repository at this point in the history
* dont override default reward type for new rewards

* .
  • Loading branch information
mattcasey authored Jan 25, 2024
1 parent 9432687 commit 1c57904
Showing 1 changed file with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ export function RewardPropertiesForm({
const { getFeatureTitle } = useSpaceFeatures();
const [isDateTimePickerOpen, setIsDateTimePickerOpen] = useState(false);
const [isExpanded, setIsExpanded] = useState(!!expandedByDefault);
const [rewardType, setRewardType] = useState(values?.customReward ? 'Custom' : ('Token' as RewardType));
const allowedSubmittersValue: RoleOption[] = (values?.allowedSubmitterRoles ?? []).map((id) => ({
const [rewardType, setRewardType] = useState<RewardType>(
values.customReward ? 'Custom' : isNewReward || values.rewardToken ? 'Token' : 'None'
);
const allowedSubmittersValue: RoleOption[] = (values.allowedSubmitterRoles ?? []).map((id) => ({
id,
group: 'role'
}));
Expand All @@ -110,14 +112,6 @@ export function RewardPropertiesForm({
setRewardApplicationTypeRaw(updatedType);
}, []);

useEffect(() => {
if (isTruthy(values?.customReward)) {
setRewardType('Custom');
} else if (!values?.rewardToken || !values?.rewardAmount || !values?.chainId) {
setRewardType('None');
}
}, [values?.customReward, values?.rewardAmount, values?.rewardToken, values?.chainId]);

async function applyUpdates(updates: Partial<UpdateableRewardFields>) {
if ('customReward' in updates) {
const customReward = updates.customReward;
Expand Down

0 comments on commit 1c57904

Please sign in to comment.