Skip to content

Commit 7092a9a

Browse files
authored
Merge pull request #6 from codee-sh/fix/slack-blocks
Fix - slack blocks
2 parents 138fbfe + d63fe38 commit 7092a9a

5 files changed

Lines changed: 32 additions & 2 deletions

File tree

.changeset/fruity-clocks-design.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@codee-sh/medusa-plugin-notification-emails": patch
3+
---
4+
5+
refactor: update Slack template service to omit unnecessary fields

src/templates/slack/inventory-level/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const templateBlocks = [
3939
type: "plain_text",
4040
text: "Open in Panel",
4141
},
42-
url: `/app/inventory/{{data.inventory_level.inventory_item.id}}`,
42+
url: `{{data.backend_url}}/app/inventory/{{data.inventory_level.inventory_item.id}}`,
4343
style: "primary",
4444
},
4545
],

src/templates/slack/slack-template-service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
import {
66
pickValueFromObject,
77
multiInterpolate,
8+
omit,
89
} from "../../utils"
910
import {
1011
templateBlocks as InventoryLevelTemplateBlocks,
@@ -186,7 +187,7 @@ export class SlackTemplateService extends AbstractTemplateService<any> {
186187
})
187188

188189
block = {
189-
...block,
190+
...omit(block, "fieldsPath", "fieldTemplate"),
190191
fields: interpolatedFieldBlocks,
191192
}
192193
}

src/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export * from "./is-object";
88
export * from "./attribute-helpers";
99
export * from "./i18n/i18n";
1010
export * from "./transforms";
11+
export * from "./omit";
1112
export * from "./data/modules";
1213
export * from "./data/currencies";
1314
export * from "./data/countries";

src/utils/omit.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Creates a new object without the specified keys
3+
* Does not mutate the original object
4+
*
5+
* @param obj - Source object
6+
* @param keys - Keys to omit from the object
7+
* @returns New object without the specified keys
8+
*
9+
* @example
10+
* const obj = { a: 1, b: 2, c: 3 }
11+
* omit(obj, 'a', 'c') // { b: 2 }
12+
*/
13+
export function omit<T extends Record<string, any>, K extends keyof T>(
14+
obj: T,
15+
...keys: K[]
16+
): Omit<T, K> {
17+
const result = { ...obj }
18+
keys.forEach((key) => {
19+
delete result[key]
20+
})
21+
return result as Omit<T, K>
22+
}
23+

0 commit comments

Comments
 (0)