Skip to content

Commit

Permalink
Merge pull request #2241 from wondrous-dev/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
andywong418 authored Mar 26, 2024
2 parents d034ce1 + e39c07d commit e9d4e1b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const LinkClickButton = ({ step, cmtyUser, handleLinkClick, startCmtyUserPolling
questStepId: step?.id,
});
const query = btoa(linkQuery);
return `${baseUrl}/verify-link?query=${query}`;
return `${baseUrl}/verify-link?query=${encodeURIComponent(query)}`;
}, [step]);

const onClick = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useDiscordRoles } from "utils/discord";
import GlobalContext from "utils/context/GlobalContext";
import ErrorField from "components/Shared/ErrorField";
import { useDiscordRoleRewardData } from "components/Rewards/utils";
import { ERRORS_LABELS, QUEST_STATUSES } from "utils/constants";

const PublishQuestModal = ({
onClose,
Expand Down Expand Up @@ -98,7 +99,7 @@ const PublishQuestCardBody = ({ guildDiscordChannels, quest, orgId, existingNoti
const [mentionChannel, setMentionChannel] = useState(false);
const [discordRoleTagged, handleDiscordRoleTagged] = useState(null);
const [message, setMessage] = useState(`${quest?.title} is now available! Check it out here and make a submission`);
const [publishQuest] = useMutation(PUSH_QUEST_DISCORD_NOTFICATION, {
const [publishQuest, { error }] = useMutation(PUSH_QUEST_DISCORD_NOTFICATION, {
onCompleted: () => {
setSnackbarAlertOpen(true);
setSnackbarAlertMessage("Success!");
Expand All @@ -108,7 +109,18 @@ const PublishQuestCardBody = ({ guildDiscordChannels, quest, orgId, existingNoti
});
setOpenPublishModal(false);
},
onError: (error) => {
const errorCode: any = error?.graphQLErrors[0]?.extensions.errorCode;
const errMessage = ERRORS_LABELS[errorCode] || "Error publishing quest";
setSnackbarAlertOpen(true);
setSnackbarAlertMessage(errMessage);
setSnackbarAlertAnchorOrigin({
vertical: "top",
horizontal: "center",
});
},
});
const mutationError = error?.graphQLErrors[0]?.extensions.errorCode;
const channels = guildDiscordChannels?.map((channel) => ({
label: channel.name,
value: channel.id,
Expand All @@ -122,6 +134,7 @@ const PublishQuestCardBody = ({ guildDiscordChannels, quest, orgId, existingNoti
}
}, [guildDiscordChannels]);

const isInactiveQuest = quest?.status === QUEST_STATUSES.INACTIVE;
return (
<>
<Modal
Expand Down Expand Up @@ -173,8 +186,8 @@ const PublishQuestCardBody = ({ guildDiscordChannels, quest, orgId, existingNoti
)}
<Box display="flex" width={"100%"} marginTop="8px">
<Box flex={1} />
<SharedSecondaryButton disabled={!channel} onClick={() => setOpenPublishModal(true)}>
Publish
<SharedSecondaryButton disabled={!channel || isInactiveQuest} onClick={() => setOpenPublishModal(true)}>
{isInactiveQuest ? "Quest is inactive" : "Publish"}
</SharedSecondaryButton>
</Box>
</>
Expand Down
1 change: 1 addition & 0 deletions wondrous-bot-admin/src/utils/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ export const ERRORS_LABELS = {
[REQUIREMENTS_NOT_MET_ERRORS.LEVEL]: "You must reach at least level {requiredLevel} to embark on this quest",
[REQUIREMENTS_NOT_MET_ERRORS.DISCORD_ROLE]: "You must have {discordRole} role to take this quest",
[REQUIREMENTS_NOT_MET_ERRORS.QUEST]: "You must complete {questTitle} before taking this quest",
quest_not_active: "This quest is not active. Please activate it first",
};

export const DAO_CATEGORIES_KEYS = {
Expand Down

0 comments on commit e9d4e1b

Please sign in to comment.