-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving the template to ts and fixing issues from the pr review
- Loading branch information
Showing
62 changed files
with
190 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 21 additions & 12 deletions
33
...ews-template/api/actions/enqueueEmails.js → ...ews-template/api/actions/enqueueEmails.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 0 additions & 33 deletions
33
shopify/product-reviews-template/api/actions/scheduledShopifySync.js
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
shopify/product-reviews-template/api/actions/scheduledShopifySync.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { ActionOptions } from "gadget-server"; | ||
import { globalShopifySync } from "gadget-server/shopify"; | ||
|
||
const HourInMs = 60 * 60 * 1000; | ||
|
||
export const run: ActionRun = async ({ params, logger, api, connections }) => { | ||
const syncOnlyModels = connections.shopify.enabledModels | ||
.filter((model) => model.syncOnly) | ||
.map((model) => model.apiIdentifier); | ||
|
||
const syncSince = new Date(Date.now() - 25 * HourInMs); | ||
|
||
await globalShopifySync({ | ||
apiKeys: connections.shopify.apiKeys, | ||
syncSince, | ||
models: syncOnlyModels, | ||
}); | ||
}; | ||
|
||
export const options: ActionOptions = { | ||
triggers: { | ||
scheduler: [ | ||
{ | ||
every: "day", | ||
at: "14:21 UTC", | ||
}, | ||
], | ||
}, | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import renderEmail from "../utilities/renderEmail"; | ||
|
||
export const run: ActionRun = async ({ | ||
params, | ||
logger, | ||
api, | ||
connections, | ||
emails, | ||
currentAppUrl, | ||
}) => { | ||
const { singleUseCode, email } = params; | ||
|
||
if (!email || !singleUseCode) throw new Error("Missing required params"); | ||
|
||
await emails.sendMail({ | ||
to: email, | ||
subject: "Review your purchase", | ||
html: await renderEmail({ currentAppUrl, singleUseCode }), | ||
}); | ||
}; | ||
|
||
export const params = { | ||
email: { | ||
type: "string", | ||
}, | ||
singleUseCode: { | ||
type: "string", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions
23
shopify/product-reviews-template/api/utilities/renderEmail.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from "react"; | ||
import { render } from "@react-email/render"; | ||
import { Container, Button } from "@react-email/components"; | ||
|
||
export default async ({ | ||
singleUseCode, | ||
currentAppUrl, | ||
}: { | ||
singleUseCode: string; | ||
currentAppUrl: string; | ||
}) => { | ||
return await render( | ||
<Container> | ||
{/* Add more text in here */} | ||
<Button | ||
href={`${currentAppUrl}/review/${singleUseCode}`} | ||
style={{ color: "#61dafb", padding: "10px 20px" }} | ||
> | ||
Review | ||
</Button> | ||
</Container> | ||
); | ||
}; |
Oops, something went wrong.