Merge branch 'develop' of https://github.com/rowyio/rowy into develop

This commit is contained in:
Sidney Alcantara
2022-09-26 12:53:17 +10:00
4 changed files with 102 additions and 13 deletions

View File

@@ -3,15 +3,6 @@ import WarningIcon from "@mui/icons-material/WarningAmber";
import { TableSettings } from "@src/types/table";
import { IWebhook } from "@src/components/TableModals/WebhooksModal/utils";
export const webhookTypes = [
"basic",
"typeform",
"sendgrid",
//"shopify",
//"twitter",
//"stripe",
] as const;
const requestType = [
"declare type WebHookRequest {",
" /**",

View File

@@ -2,5 +2,6 @@ import basic from "./basic";
import typeform from "./typeform";
import sendgrid from "./sendgrid";
import webform from "./webform";
import stripe from "./stripe";
export { basic, typeform, sendgrid, webform };
export { basic, typeform, sendgrid, webform, stripe };

View File

@@ -0,0 +1,95 @@
import { Typography, Link, TextField } from "@mui/material";
import InlineOpenInNewIcon from "@src/components/InlineOpenInNewIcon";
import { TableSettings } from "@src/types/table";
import { IWebhook } from "@src/components/TableModals/WebhooksModal/utils";
export const webhookStripe = {
name: "Stripe",
parser: {
additionalVariables: null,
extraLibs: null,
template: (
table: TableSettings
) => `const sendgridParser: Parser = async ({ req, db, ref }) => {
const event = req.body
switch (event.type) {
case "payment_intent.succeeded":
break;
case "payment_intent.payment_failed":
break;
default:
// all other types
}
};`,
},
condition: {
additionalVariables: null,
extraLibs: null,
template: (
table: TableSettings
) => `const condition: Condition = async({ref,req,db}) => {
// feel free to add your own code logic here
return true;
}`,
},
auth: (webhookObject: IWebhook, setWebhookObject: (w: IWebhook) => void) => {
return (
<>
<Typography gutterBottom>
Get your{" "}
<Link
href="https://dashboard.stripe.com/apikeys"
target="_blank"
rel="noopener noreferrer"
variant="inherit"
>
secret key
<InlineOpenInNewIcon />
</Link>{" "}
and{" "}
<Link
href="https://dashboard.stripe.com/webhooks"
target="_blank"
rel="noopener noreferrer"
variant="inherit"
>
signing key
<InlineOpenInNewIcon />
</Link>{" "}
from Stripe dashboard.
<br />
Then add the secret below.
</Typography>
<TextField
id="stripe-secret-key"
label="Secret key"
value={webhookObject.auth.secretKey}
fullWidth
multiline
onChange={(e) => {
setWebhookObject({
...webhookObject,
auth: { ...webhookObject.auth, secretKey: e.target.value },
});
}}
/>
<TextField
id="stripe-signing-secret"
label="Signing key"
value={webhookObject.auth.signingSecret}
fullWidth
multiline
onChange={(e) => {
setWebhookObject({
...webhookObject,
auth: { ...webhookObject.auth, signingSecret: e.target.value },
});
}}
/>
</>
);
},
};
export default webhookStripe;

View File

@@ -1,6 +1,7 @@
import { TableSettings } from "@src/types/table";
import { generateId } from "@src/utils/table";
import { typeform, basic, sendgrid, webform } from "./Schemas";
import { typeform, basic, sendgrid, webform, stripe } from "./Schemas";
export const webhookTypes = [
"basic",
"typeform",
@@ -8,7 +9,7 @@ export const webhookTypes = [
"webform",
//"shopify",
//"twitter",
//"stripe",
"stripe",
] as const;
const requestType = [
@@ -53,7 +54,7 @@ export const webhookNames: Record<WebhookType, string> = {
//github:"GitHub",
// shopify: "Shopify",
// twitter: "Twitter",
// stripe: "Stripe",
stripe: "Stripe",
basic: "Basic",
webform: "Web form",
};
@@ -82,6 +83,7 @@ export const webhookSchemas = {
typeform,
sendgrid,
webform,
stripe,
};
export function emptyWebhookObject(