Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slack notification ts migration #124

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Slack notification ts migration #124

wants to merge 14 commits into from

Conversation

DevAOC
Copy link
Collaborator

@DevAOC DevAOC commented Nov 11, 2024

Whoops, forgot to make this one

@DevAOC DevAOC requested a review from rdraward November 11, 2024 21:39
Copy link
Collaborator

@rdraward rdraward left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to only use type coercion when necessary. In most cases, we can remove null or undefined issues by adding a check first

Feedback is just on typing - the 🎩 worked no problem

@@ -39,15 +40,15 @@ export async function onSuccess({ params, record, logger, api, trigger }) {
token: shop.slackAccessToken,
channel: shop.slackChannelId,
text: `You made a sale! ${
record.paymentDetails.credit_card_name || "Unknown"
(record.paymentDetails as { credit_card_name?: string })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good reminder that we probably want some docs on working with JSON field values in TS

shopify/slack-notification-template/web/routes/index.tsx Outdated Show resolved Hide resolved
@@ -151,17 +165,20 @@ const SlackChannelSelectionForm = ({
/>
}
>
{options.length > 0 && (
{options.length > 0 ? (
<Listbox
onSelect={(value) => {
setInputValue(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is undefined valid? We can always check here and not set the input if it is not (so we don't have to cast as a string below)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not able to find an alternative

shopify/slack-notification-template/web/routes/index.tsx Outdated Show resolved Hide resolved
shopify/slack-notification-template/web/routes/index.tsx Outdated Show resolved Hide resolved
@DevAOC DevAOC requested a review from rdraward November 13, 2024 20:49
Copy link
Collaborator

@rdraward rdraward left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎩 ✅
One small type comment. It is a bummer that global actions don't return types (yet) because that would clean up the frontend a bit

Another small suggestion for the .template/docs/setup.md file: for the SLACK_SCOPES env var instruction, can we just provide the comma-separated list here? It is annoying to have to copy-paste or type out the 4 scopes manually

(channel) => channel.value === value
)[0].label
)[0].label as string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove the as string here because the Channel type does not allow for null or undefined

Suggested change
)[0].label as string
)[0].label

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants