@vtex/faststore-plugin-buyer-portal 1.3.16 → 1.3.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/.github/workflows/betarelease.yaml +69 -0
  2. package/CHANGELOG.md +24 -6
  3. package/beta-release.sh +23 -0
  4. package/package.json +3 -2
  5. package/src/features/budgets/components/BudgetDeleteDrawer/BudgetDeleteDrawer.tsx +1 -1
  6. package/src/features/budgets/components/BudgetEditNotificationDrawer/BudgetEditNotificationDrawer.tsx +139 -0
  7. package/src/features/budgets/components/BudgetEditNotificationDrawer/budget-edit-notification-drawer.scss +34 -0
  8. package/src/features/budgets/components/BudgetNotificationForm/BudgetNotificationForm.tsx +361 -0
  9. package/src/features/budgets/components/BudgetNotificationForm/budget-notification-form.scss +219 -0
  10. package/src/features/budgets/components/BudgetNotificationsInfo/BudgetNotificationsInfo.tsx +116 -0
  11. package/src/features/budgets/components/BudgetNotificationsInfo/budget-notifications-info.scss +97 -0
  12. package/src/features/budgets/components/BudgetUsersTable/BudgetUsersTable.tsx +118 -0
  13. package/src/features/budgets/components/BudgetUsersTable/budget-users-table.scss +65 -0
  14. package/src/features/budgets/components/BudgetsTable/BudgetsTable.tsx +10 -0
  15. package/src/features/budgets/components/CreateBudgetAllocationDrawer/CreateBudgetAllocationDrawer.tsx +1 -1
  16. package/src/features/budgets/components/CreateBudgetDrawer/CreateBudgetDrawer.tsx +86 -25
  17. package/src/features/budgets/components/CreateBudgetDrawer/create-budget-drawer.scss +6 -0
  18. package/src/features/budgets/components/DeleteBudgetAllocationDrawer/DeleteBudgetAllocationDrawer.tsx +1 -1
  19. package/src/features/budgets/components/EditBudgetDrawer/EditBudgetDrawer.tsx +40 -1
  20. package/src/features/budgets/components/EditBudgetDrawer/edit-budget-drawer.scss +5 -0
  21. package/src/features/budgets/hooks/useDebouncedSearchBudgetNotification.ts +37 -0
  22. package/src/features/budgets/hooks/useListUsers.ts +1 -1
  23. package/src/features/budgets/layouts/BudgetsDetailsLayout/BudgetsDetailsLayout.tsx +9 -1
  24. package/src/features/budgets/layouts/BudgetsDetailsLayout/budget-details-layout.scss +14 -1
  25. package/src/features/budgets/layouts/BudgetsLayout/BudgetsLayout.tsx +39 -0
  26. package/src/features/budgets/layouts/BudgetsLayout/budgets-layout.scss +1 -1
  27. package/src/features/budgets/types/index.ts +17 -0
  28. package/src/features/shared/components/AutocompleteDropdown/AutocompleteDropdownItem.tsx +4 -0
  29. package/src/features/shared/components/QuantitySelectorWithPercentage/QuantitySelectorWithPercentage.tsx +150 -0
  30. package/src/features/shared/components/index.ts +24 -23
  31. package/src/features/shared/types/CurrencyType.d.ts +4 -0
  32. package/src/features/shared/types/index.ts +4 -3
  33. package/src/features/shared/utils/budgetAmountParse.ts +24 -0
  34. package/src/features/shared/utils/constants.ts +1 -1
@@ -0,0 +1,69 @@
1
+ # This Action runs on experimental branch and publishes an experimental version to npm
2
+ name: CD Beta
3
+
4
+ on:
5
+ push:
6
+ branches:
7
+ - beta
8
+
9
+ jobs:
10
+ build:
11
+ name: BuyerPortal Beta
12
+ timeout-minutes: 15
13
+ runs-on: ubuntu-latest
14
+
15
+ steps:
16
+ - name: Check out code
17
+ uses: actions/checkout@v4
18
+ with:
19
+ fetch-depth: 2
20
+
21
+ - name: Setup Node.js environment
22
+ uses: actions/setup-node@v4
23
+ with:
24
+ node-version: 20
25
+ cache: "yarn"
26
+ registry-url: "https://registry.npmjs.org"
27
+
28
+ - name: Configure CI Git User
29
+ run: |
30
+ git config user.name vtexgithubbot
31
+ git config user.email vtexgithubbot@github.com
32
+
33
+ - name: Install dependencies
34
+ run: yarn
35
+
36
+ - name: Get current version
37
+ id: get_version
38
+ run: |
39
+ CURRENT_VERSION=$(node -p "require('./package.json').version")
40
+ echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
41
+
42
+ - name: Generate experimental version
43
+ id: generate_version
44
+ run: |
45
+ # Extract base version (remove any existing prerelease suffix)
46
+ BASE_VERSION=$(echo "${{ steps.get_version.outputs.current_version }}" | sed -E 's/(-.*)?$//')
47
+ # Generate timestamp-based identifier
48
+ TIMESTAMP=$(date +%Y%m%d%H%M%S)
49
+ # Create experimental version
50
+ EXPERIMENTAL_VERSION="${BASE_VERSION}-experimental.${TIMESTAMP}"
51
+ echo "experimental_version=$EXPERIMENTAL_VERSION" >> $GITHUB_OUTPUT
52
+ echo "Publishing experimental version: $EXPERIMENTAL_VERSION"
53
+
54
+ - name: Update package.json version
55
+ run: |
56
+ npm version ${{ steps.generate_version.outputs.experimental_version }} --no-git-tag-version
57
+
58
+ - name: Publish experimental version
59
+ run: yarn publish --non-interactive --tag experimental
60
+ env:
61
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
62
+
63
+ - name: Push changes and tags
64
+ run: |
65
+ git config user.email "vtexgithubbot@github.com"
66
+ git config user.name "vtexgithubbot"
67
+ git add package.json
68
+ git commit -m "chore: publish experimental version ${{ steps.generate_version.outputs.experimental_version }}" || echo "No changes to commit"
69
+ git push origin experimental || echo "No changes to push"
package/CHANGELOG.md CHANGED
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.3.18] - 2025-11-05
11
+
12
+ ### Added
13
+
14
+ - Responsiviness to Roles and Roles Details page
15
+
16
+ ### Added
17
+
18
+ - Notifications details on budget and integration
19
+
20
+ ### Added
21
+
22
+ - Add budget notification page
23
+
24
+ ## [1.3.17] - 2025-11-03
25
+
26
+ ### Added
27
+
28
+ - Create BETA publish flow
29
+
10
30
  ## [1.3.16] - 2025-11-03
11
31
 
12
32
  ### Added
@@ -100,13 +120,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
100
120
  ## [1.2.4] - 2025-10-16
101
121
 
102
122
  ### Added
103
-
104
- - Responsiviness to Roles and Roles Details page
105
-
106
- ### Added
107
-
108
123
  - Responsiviness adjustment to to Buying policies page
109
124
 
125
+
110
126
  ### Added
111
127
 
112
128
  - Responsiviness to Buying policies page
@@ -195,7 +211,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
195
211
  - Add CHANGELOG file
196
212
  - Add README file
197
213
 
198
- [unreleased]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.16...HEAD
214
+ [unreleased]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.18...HEAD
199
215
  [1.2.3]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.2.2...1.2.3
200
216
  [1.2.3]: https://github.com/vtex/faststore-plugin-buyer-portal/releases/tag/1.2.3
201
217
  [1.2.4]: https://github.com/vtex/faststore-plugin-buyer-portal/releases/tag/1.2.4
@@ -210,6 +226,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
210
226
 
211
227
  # <<<<<<< HEAD
212
228
 
229
+ [1.3.18]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.17...v1.3.18
230
+ [1.3.17]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.16...v1.3.17
213
231
  [1.3.16]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.15...v1.3.16
214
232
  [1.3.15]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.14...v1.3.15
215
233
  [1.3.14]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.13...v1.3.14
@@ -0,0 +1,23 @@
1
+ #!/bin/bash
2
+
3
+ BRANCH_NAME="beta"
4
+
5
+ echo "Attempting to checkout branch: $BRANCH_NAME"
6
+
7
+ git fetch --all
8
+
9
+ echo "Delete current $BRANCH_NAME"
10
+ git branch -D "$BRANCH_NAME"
11
+
12
+ echo "Create branch $BRANCH_NAME"
13
+ git checkout -b "$BRANCH_NAME"
14
+
15
+ git add .
16
+
17
+ echo "Update $BRANCH_NAME"
18
+ git commit -m "Update BETA environment"
19
+
20
+ git push --set-upstream origin +$BRANCH_NAME
21
+
22
+ echo "Go back to previous branch on local workspace"
23
+ git checkout -
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/faststore-plugin-buyer-portal",
3
- "version": "1.3.16",
3
+ "version": "1.3.18",
4
4
  "description": "A plugin for faststore with buyer portal",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -8,7 +8,8 @@
8
8
  "lint:fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix",
9
9
  "prepare": "husky",
10
10
  "release": "yarn release:stable",
11
- "release:stable": "yarn check --integrity && yarn release-it -c .release-it.json --ci --no-npm"
11
+ "release:stable": "yarn check --integrity && yarn release-it -c .release-it.json --ci --no-npm",
12
+ "release:beta": "./beta-release.sh"
12
13
  },
13
14
  "lint-staged": {
14
15
  "*.{js,jsx,ts,tsx}": [
@@ -11,7 +11,7 @@ import {
11
11
  InputText,
12
12
  } from "../../../shared/components";
13
13
  import { useDebounce } from "../../../shared/hooks";
14
- import { useDeleteBudget } from "../../hooks";
14
+ import { useDeleteBudget } from "../../hooks/useDeleteBudget";
15
15
 
16
16
  export interface BudgetDeleteDrawerProps
17
17
  extends Omit<BasicDrawerProps, "children"> {
@@ -0,0 +1,139 @@
1
+ import { useCallback, useState } from "react";
2
+
3
+ import { useRouter } from "next/router";
4
+
5
+ import { useUI } from "@faststore/ui";
6
+
7
+ import { BasicDrawer, type BasicDrawerProps } from "../../../shared/components";
8
+ import { useBuyerPortal } from "../../../shared/hooks";
9
+ import { parseAmount } from "../../../shared/utils/budgetAmountParse";
10
+ import { useUpdateBudget } from "../../hooks";
11
+ import { BudgetNotificationForm } from "../BudgetNotificationForm/BudgetNotificationForm";
12
+
13
+ import type { BudgetInput, BudgetNotification } from "../../types";
14
+
15
+ interface BudgetEditNotificationDrawerProps
16
+ extends Omit<BasicDrawerProps, "children"> {
17
+ budget: BudgetInput;
18
+ budgetId: string;
19
+ orgUnitId: string;
20
+ contractId: string;
21
+ }
22
+
23
+ export function BudgetEditNotificationDrawer({
24
+ budget,
25
+ budgetId,
26
+ close,
27
+ orgUnitId,
28
+ contractId,
29
+ ...props
30
+ }: BudgetEditNotificationDrawerProps) {
31
+ const { pushToast } = useUI();
32
+ const { clientContext } = useBuyerPortal();
33
+ const router = useRouter();
34
+
35
+ const [notifications, setNotifications] = useState<
36
+ BudgetNotification | undefined
37
+ >(budget.notifications);
38
+ const [showNotificationsUsersError, setShowNotificationsUsersError] =
39
+ useState(false);
40
+
41
+ const { mutate: updateBudget, isLoading } = useUpdateBudget({
42
+ options: {
43
+ onSuccess: () => {
44
+ pushToast({ message: "Budget updated successfully.", status: "INFO" });
45
+ close();
46
+ router.reload();
47
+ },
48
+ onError: (error: Error) => {
49
+ pushToast({
50
+ message: error?.message || "An error occurred. Please try again.",
51
+ status: "ERROR",
52
+ });
53
+ },
54
+ },
55
+ });
56
+
57
+ const handleChange = useCallback(
58
+ <K extends keyof BudgetInput>(field: K, value: BudgetInput[K]) => {
59
+ if (field !== "notifications") return;
60
+
61
+ const next = value as BudgetInput["notifications"];
62
+
63
+ setNotifications(next);
64
+ },
65
+ [notifications]
66
+ );
67
+
68
+ const handleSubmit = () => {
69
+ const notificationsEnabled = Boolean(notifications?.hasNotification);
70
+ const hasUsers = (notifications?.users?.length ?? 0) > 0;
71
+
72
+ if (notificationsEnabled && !hasUsers) {
73
+ setShowNotificationsUsersError(true);
74
+ pushToast({
75
+ message: "Add at least one user to notifications or turn it off.",
76
+ status: "ERROR",
77
+ });
78
+ return;
79
+ }
80
+ setShowNotificationsUsersError(false);
81
+
82
+ const payload: BudgetInput = {
83
+ ...budget,
84
+ endDate: budget.endDate || budget.expirationDate,
85
+ amount: budget.amount ? String(budget.amount).replace(",", "") : "0",
86
+ allocations: budget?.allocations ?? [],
87
+ notifications: notifications ?? {
88
+ hasNotification: false,
89
+ thresholds: [],
90
+ users: [],
91
+ },
92
+ };
93
+
94
+ updateBudget({
95
+ budgetId,
96
+ cookie: clientContext.cookie,
97
+ customerId: contractId,
98
+ data: payload,
99
+ unitId: orgUnitId,
100
+ });
101
+ };
102
+
103
+ return (
104
+ <BasicDrawer
105
+ data-fs-bp-budget-notifications-drawer
106
+ close={close}
107
+ {...props}
108
+ >
109
+ <BasicDrawer.Heading title="Edit notifications" onClose={close} />
110
+
111
+ <BasicDrawer.Body>
112
+ <BudgetNotificationForm
113
+ budget={{ ...budget, notifications }}
114
+ handleChange={handleChange}
115
+ totalAmount={parseAmount(budget.amount)}
116
+ currency="USD"
117
+ locale="en-US"
118
+ unitId={orgUnitId}
119
+ contractId={contractId}
120
+ showUsersError={showNotificationsUsersError}
121
+ />
122
+ </BasicDrawer.Body>
123
+
124
+ <BasicDrawer.Footer data-fs-bp-budget-notifications-drawer-footer>
125
+ <BasicDrawer.Button variant="ghost" onClick={close}>
126
+ Cancel
127
+ </BasicDrawer.Button>
128
+ <BasicDrawer.Button
129
+ variant="confirm"
130
+ onClick={handleSubmit}
131
+ disabled={isLoading}
132
+ isLoading={isLoading}
133
+ >
134
+ Save
135
+ </BasicDrawer.Button>
136
+ </BasicDrawer.Footer>
137
+ </BasicDrawer>
138
+ );
139
+ }
@@ -0,0 +1,34 @@
1
+
2
+
3
+ [data-fs-bp-budget-notifications-drawer] {
4
+ @import "../../../shared/components/BasicDrawer/basic-drawer.scss";
5
+ @import "../../../shared/components/EmptyState/empty-state.scss";
6
+ @import "../../../shared/components/InputText/input-text.scss";
7
+ @import "../../../shared/components/ErrorMessage/error-message.scss";
8
+
9
+ &[data-fs-bp-basic-drawer] > [data-fs-bp-basic-drawer-footer] {
10
+ justify-content: flex-end;
11
+ gap: var(--fs-spacing-1);
12
+ }
13
+
14
+ &[data-fs-bp-basic-drawer][data-fs-slide-over-size="partial"] {
15
+ width: 100%;
16
+ max-width: none;
17
+
18
+ @include media(">=tablet") {
19
+ max-width: 30rem;
20
+ }
21
+
22
+ @include media(">=notebook") {
23
+ max-width: 40rem;
24
+ }
25
+ }
26
+
27
+ [data-fs-bp-basic-drawer-body] {
28
+ overflow-y: auto;
29
+ }
30
+
31
+ [data-fs-bp-budget-notifications-drawer-name] {
32
+ color: #0366dd;
33
+ }
34
+ }