Skip to content

Commit

Permalink
Merge pull request #2250 from wondrous-dev/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
andywong418 authored Apr 17, 2024
2 parents aa55a62 + fd2867a commit ca2a52a
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Grid } from "@mui/material";
import TextField from "components/Shared/TextField";
import { Label } from "./styles";

const RegexComponent = ({ error, value, onChange, TextInputStyle, ...rest }) => {
const handleOnChange = (key, val) => {
onChange({
...value,
[key]: val,
});
};
console.log("value", value);
return (
<Grid display="flex" gap="8px" flexDirection="column" width="100%">
<Label>Question / Prompt</Label>
<TextField
multiline={false}
value={value?.prompt || ""}
onChange={(value) => {
handleOnChange("prompt", value);
}}
{...rest}
error={error?.prompt}
/>
<Label>Regex to use for checking the answer</Label>
<TextField
placeholder="E.g. To make sure the answer starts with 0x, use ^0x"
value={value?.regex || ""}
onChange={(value) => handleOnChange("regex", value)}
multiline={false}
error={error}
{...rest}
/>
</Grid>
);
};

export default RegexComponent;
4 changes: 4 additions & 0 deletions wondrous-bot-admin/src/components/AddFormEntity/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export const COMPONENT_OPTIONS = [
label: "Attachments",
value: TYPES.ATTACHMENTS,
},
{
label: "Verify Text Answer with Regex",
value: TYPES.VERIFY_TEXT_WITH_REGEX,
},
{
label: "Like A Tweet",
value: TYPES.LIKE_TWEET,
Expand Down
5 changes: 5 additions & 0 deletions wondrous-bot-admin/src/components/CreateTemplate/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ const processSteps = (steps) =>
step["additionalData"] = {
tweetPhrase: next.value?.tweetPhrase,
};
} else if (next.type === TYPES.VERIFY_TEXT_WITH_REGEX) {
step.prompt = next.value?.prompt;
step["additionalData"] = {
regex: next.value?.regex,
};
} else if (next.type === TYPES.LIKE_YT_VIDEO) {
step.prompt = next.value?.prompt;
step["additionalData"] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const COMPONENTS_CONFIG: any = {
[TYPES.FOLLOW_TWITTER]: VerifyButton,
[TYPES.REPLY_TWEET]: VerifyButton,
[TYPES.RETWEET]: VerifyButton,
[TYPES.TWEET_WITH_PHRASE]: VerifyButton,
[TYPES.VERIFY_TEXT_WITH_REGEX]: VerifyButton,
[TYPES.CONNECT_WALLET]: ConnectWalletField,
};

Expand Down
1 change: 1 addition & 0 deletions wondrous-bot-admin/src/graphql/fragments/quest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export const QuestFragment = gql`
discordChannelIds
tweetHandle
tweetLink
regex
tweetPhrase
snapshotProposalLink
snapshotSpaceLink
Expand Down
2 changes: 2 additions & 0 deletions wondrous-bot-admin/src/graphql/queries/questSubmission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export const GET_USER_QUEST_SUBMISSIONS = gql`
tweetHandle
tweetLink
tweetPhrase
regex
snapshotProposalLink
snapshotSpaceLink
snapshotVoteTimes
Expand Down Expand Up @@ -192,6 +193,7 @@ export const GET_ONBOARDING_QUEST_SUBMISSIONS = gql`
tweetHandle
tweetLink
tweetPhrase
regex
snapshotProposalLink
snapshotSpaceLink
snapshotVoteTimes
Expand Down
7 changes: 7 additions & 0 deletions wondrous-bot-admin/src/services/validators/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const ALL_TYPES = [
TYPES.REPLY_TWEET,
TYPES.RETWEET,
TYPES.TWEET_WITH_PHRASE,
TYPES.VERIFY_TEXT_WITH_REGEX,
TYPES.SNAPSHOT_PROPOSAL_VOTE,
TYPES.SNAPSHOT_SPACE_VOTE,
TYPES.DISCORD_MESSAGE_IN_CHANNEL,
Expand Down Expand Up @@ -126,6 +127,12 @@ const stepTypes = {
tweetPhrase: Yup.string().required("Tweet phrase is required"),
}),
}),
[TYPES.VERIFY_TEXT_WITH_REGEX]: Yup.object().shape({
...sharedValidation,
additionalData: Yup.object().shape({
regex: Yup.string().required("Regex is required"),
}),
}),
[TYPES.SNAPSHOT_PROPOSAL_VOTE]: Yup.object().shape({
...twitterSnapshotSharedValidation,
additionalData: Yup.object().shape({
Expand Down
7 changes: 7 additions & 0 deletions wondrous-bot-admin/src/services/validators/questValidator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const ALL_TYPES = [
TYPES.REPLY_TWEET,
TYPES.RETWEET,
TYPES.TWEET_WITH_PHRASE,
TYPES.VERIFY_TEXT_WITH_REGEX,
TYPES.SNAPSHOT_PROPOSAL_VOTE,
TYPES.SNAPSHOT_SPACE_VOTE,
TYPES.DISCORD_MESSAGE_IN_CHANNEL,
Expand Down Expand Up @@ -104,6 +105,12 @@ const stepTypes = {
tweetPhrase: Yup.string().required("Tweet phrase is required"),
}),
}),
[TYPES.VERIFY_TEXT_WITH_REGEX]: Yup.object().shape({
...sharedValidation,
additionalData: Yup.object().shape({
regex: Yup.string().required("Regex is required"),
}),
}),
[TYPES.SNAPSHOT_PROPOSAL_VOTE]: Yup.object().shape({
...twitterSnapshotSharedValidation,
additionalData: Yup.object().shape({
Expand Down
2 changes: 2 additions & 0 deletions wondrous-bot-admin/src/utils/configComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import VerifyApeironIntegrations from "components/AddFormEntity/components/Verif
import ConnectWallet from "components/AddFormEntity/components/ConnectWallet";
import VerifyFhenixIntegrations from "components/AddFormEntity/components/VerifyFhenix";
import GitcoinPassportComponent from "components/AddFormEntity/components/GitcoinPassportComponent";
import RegexComponent from "components/AddFormEntity/components/RegexText";

const APEIRON_INTEGRATIONS = {
[TYPES.VERIFY_APEIRON_10_MINS_PLAYED]: VerifyApeironIntegrations,
Expand Down Expand Up @@ -57,6 +58,7 @@ export const CONFIG_COMPONENTS = {
[TYPES.MIGRATE_ORIGIN_USERS]: MigrateOriginUsers,
[TYPES.VERIFY_MARKETSFLARE_TRIAL]: VerifyMarketsFlareTrial,
[TYPES.VERIFY_GITCOIN_PASSPORT_SCORE]: GitcoinPassportComponent,
[TYPES.VERIFY_TEXT_WITH_REGEX]: RegexComponent,
...APEIRON_INTEGRATIONS,
...FHENIX_INTEGRATIONS,
};
7 changes: 4 additions & 3 deletions wondrous-bot-admin/src/utils/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const TYPES = {
LIKE_YT_VIDEO: "like_yt_video",
SUBSCRIBE_YT_CHANNEL: "subscribe_yt_channel",
CUSTOM_ONCHAIN_ACTION: "custom_onchain_action",
VERIFY_TEXT_WITH_REGEX: "verify_text_with_regex",
LIFI_VALUE_BRIDGED: "lifi_value_bridged",
MIGRATE_ORIGIN_USERS: "migrate_origin_users",
REFERRAL: "referral",
Expand Down Expand Up @@ -131,7 +132,7 @@ export const PAGES_WITHOUT_HEADER = [
"/activity",
"/onboarding/plan-select",
"/onboarding/finalize",
"/oauth/google/callback"
"/oauth/google/callback",
];

export const BG_TYPES = {
Expand Down Expand Up @@ -359,7 +360,7 @@ export const EXCLUDED_PATHS = [
"/referral",
"/referral-campaign",
"/activity",
"/oauth/google/callback"
"/oauth/google/callback",
];

export const TUTORIALS = {
Expand Down Expand Up @@ -554,4 +555,4 @@ export const LOCKED_PATHS = ["/store", "/store/items/create", "/store/items/:id"

export const LOCAL_STORAGE_ORG_ID_KEY = "default-org-id";

export const ALLOWLIST_ADMIN_IDS = ["46108748309069853", "54694658413953389"];
export const ALLOWLIST_ADMIN_IDS = ["46108748309069853", "54694658413953389"];
3 changes: 2 additions & 1 deletion wondrous-bot-admin/src/utils/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export const exportQuestSubmissionsToCsv = async ({ exportQuestSubmissionData, q
questStepType === TYPES.ATTACHMENTS ||
questStepType === TYPES.NUMBER ||
questStepType === TYPES.DATA_COLLECTION ||
questStepType === TYPES.CONNECT_WALLET
questStepType === TYPES.CONNECT_WALLET ||
questStepType === TYPES.VERIFY_TEXT_WITH_REGEX
) {
questStepTypeString = `${questStepTypeString} - ${questStep?.prompt}`;
} else if (questStepType === TYPES.DISCORD_EVENT_ATTENDANCE) {
Expand Down
10 changes: 10 additions & 0 deletions wondrous-bot-admin/src/utils/transformQuestConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type InputQuestStep = {
tweetLink?: string;
tweetHandle?: string;
tweetPhrase?: string;
regex?: string;
snapshotProposalLink?: string;
snapshotSpaceLink?: string;
snapshotVoteTimes?: number;
Expand Down Expand Up @@ -121,6 +122,10 @@ type OutputQuestStep = {
verifyTokenId?: string;
verifyTokenName?: string;
}
| {
prompt?: string;
regex?: string;
}
| {
prompt?: string;
options?: string[];
Expand Down Expand Up @@ -193,6 +198,11 @@ export function transformQuestConfig(obj: InputQuestStep[]): OutputQuestStep[] {
prompt: step?.prompt,
tweetPhrase: step?.additionalData?.tweetPhrase,
};
} else if (step.type === TYPES.VERIFY_TEXT_WITH_REGEX) {
outputStep.value = {
prompt: step?.prompt,
regex: step?.additionalData?.regex,
};
} else if (step.type === TYPES.LIKE_YT_VIDEO) {
outputStep.value = {
prompt: step?.prompt,
Expand Down

0 comments on commit ca2a52a

Please sign in to comment.