@vtex/faststore-plugin-buyer-portal 1.0.7 → 1.0.9

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 (96) hide show
  1. package/package.json +1 -1
  2. package/plugin.config.js +26 -2
  3. package/public/buyer-portal-icons.svg +219 -0
  4. package/src/components/AddressLine/AddressLine.tsx +46 -0
  5. package/src/components/AddressLine/address-line.scss +45 -0
  6. package/src/components/AddressesCard/AddressesCard.tsx +89 -46
  7. package/src/components/Card/Card.scss +41 -35
  8. package/src/components/ContractsCard/ContractsCard.tsx +80 -44
  9. package/src/components/CustomerSwitch/CustomerSwitchDrawer.tsx +2 -2
  10. package/src/components/CustomerSwitch/CustomerSwitchSearch.tsx +18 -26
  11. package/src/components/DropdownFilter/DropdownFilter.tsx +65 -0
  12. package/src/components/DropdownFilter/dropdown-filter.scss +15 -0
  13. package/src/components/HierarchyTree/HierarchyTree.tsx +76 -0
  14. package/src/components/HierarchyTree/hierarchy-tree.scss +9 -0
  15. package/src/components/Icon/Icon.tsx +64 -0
  16. package/src/components/Icon/index.ts +1 -0
  17. package/src/components/InternalSearch/InternalSearch.tsx +26 -0
  18. package/src/components/InternalSearch/internal-search.scss +18 -0
  19. package/src/components/InternalTopbar/InternalTopbar.tsx +74 -0
  20. package/src/components/InternalTopbar/internal-top-bar.scss +51 -0
  21. package/src/components/Navbar/Navbar.tsx +7 -5
  22. package/src/components/Navbar/navbar.scss +2 -1
  23. package/src/components/OrgUnitsHierarchyTree/OrgUnitsHierarchyTree.tsx +52 -0
  24. package/src/components/OrgUnitsHierarchyTree/org-units-hierarchy-tree.scss +72 -0
  25. package/src/components/OrganizationalUnitsCard/OrganizationalUnitsCard.tsx +129 -80
  26. package/src/components/ProfileCard/ProfileCard.tsx +45 -41
  27. package/src/components/ProfileSummary/ProfileSummary.tsx +13 -3
  28. package/src/components/ProfileSummary/profile-summary.scss +25 -4
  29. package/src/components/SelfManagementDrawer/SelfManagementDrawer.tsx +1 -0
  30. package/src/components/SelfManagementDrawer/SelfManagementDrawerHeader.tsx +3 -3
  31. package/src/components/SelfManagementDrawer/self-management-drawer.scss +78 -73
  32. package/src/components/SelfManagementSignInButton/SelfManagementSignInButton.tsx +2 -2
  33. package/src/components/SortFilter/SortFilter.tsx +58 -0
  34. package/src/components/SortFilter/sort-filter.scss +18 -0
  35. package/src/components/Tag/Tag.tsx +11 -0
  36. package/src/components/Tag/tag.scss +10 -0
  37. package/src/components/UsersCard/UsersCard.tsx +79 -44
  38. package/src/hooks/useQueryParams.ts +38 -0
  39. package/src/layouts/AddressDetailsLayout/AddressDetailsLayout.tsx +134 -0
  40. package/src/layouts/AddressDetailsLayout/address-details-layout.scss +131 -0
  41. package/src/layouts/AddressesLayout/AddressesLayout.tsx +119 -0
  42. package/src/layouts/AddressesLayout/addresses-layout.scss +83 -0
  43. package/src/layouts/ContractsLayout/ContractsLayout.tsx +83 -0
  44. package/src/layouts/ContractsLayout/contracts-layout.scss +50 -0
  45. package/src/layouts/GlobalLayout/GlobalLayout.tsx +12 -0
  46. package/src/layouts/GlobalLayout/global-layout.scss +1 -0
  47. package/src/layouts/HomeLayout/HomeLayout.tsx +35 -0
  48. package/src/layouts/HomeLayout/home-layout.scss +30 -0
  49. package/src/layouts/OrgUnitsLayout/OrgUnitsLayout.tsx +36 -0
  50. package/src/layouts/OrgUnitsLayout/org-units-layout.scss +34 -0
  51. package/src/layouts/UserDetailsLayout/UserDetailsLayout.tsx +87 -0
  52. package/src/layouts/UserDetailsLayout/user-details-layout.scss +53 -0
  53. package/src/layouts/UsersLayout/UsersLayout.tsx +109 -0
  54. package/src/layouts/UsersLayout/users-layout.scss +71 -0
  55. package/src/layouts/index.scss +8 -0
  56. package/src/mock/addresses-data.ts +244 -0
  57. package/src/mock/contracts-data.ts +31 -0
  58. package/src/mock/org-units-data.ts +203 -0
  59. package/src/mock/organization-data.ts +13 -0
  60. package/src/mock/profile-data.ts +5 -54
  61. package/src/mock/users-data.ts +20 -0
  62. package/src/pages/address-details.tsx +23 -0
  63. package/src/pages/addresses.tsx +24 -0
  64. package/src/pages/contracts.tsx +24 -0
  65. package/src/pages/home.tsx +15 -0
  66. package/src/pages/org-units.tsx +16 -0
  67. package/src/pages/user-details.tsx +32 -0
  68. package/src/pages/users.tsx +37 -0
  69. package/src/services/get-address-details.service.ts +11 -0
  70. package/src/services/get-addresses.service.ts +42 -0
  71. package/src/services/get-contracts.service.ts +40 -0
  72. package/src/services/get-org-units-hierarchy.service.ts +9 -0
  73. package/src/services/get-organization.service.ts +5 -0
  74. package/src/services/get-user-details.service.ts +6 -0
  75. package/src/services/get-users.service.ts +46 -0
  76. package/src/themes/index.scss +30 -69
  77. package/src/types/AddressData.ts +20 -0
  78. package/src/types/ContractData.ts +6 -0
  79. package/src/types/OrgUnitsData.ts +9 -0
  80. package/src/types/OrganizationData.ts +12 -0
  81. package/src/types/ProfileData.ts +7 -0
  82. package/src/types/UserData.ts +8 -0
  83. package/src/utils/addresLabelToPropMapping.ts +13 -0
  84. package/src/utils/getTreeDepth.ts +10 -0
  85. package/src/utils/search.tsx +60 -0
  86. package/src/components/Icons/Active.tsx +0 -18
  87. package/src/components/Icons/Address.tsx +0 -20
  88. package/src/components/Icons/Delete.tsx +0 -14
  89. package/src/components/Icons/Edit.tsx +0 -9
  90. package/src/components/Icons/FilledFolder.tsx +0 -14
  91. package/src/components/Icons/Info.tsx +0 -12
  92. package/src/components/Icons/Link.tsx +0 -11
  93. package/src/components/Icons/Load.tsx +0 -42
  94. package/src/components/Icons/Profile.tsx +0 -15
  95. package/src/components/Icons/index.ts +0 -15
  96. package/src/pages/buyer-portal.tsx +0 -35
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/faststore-plugin-buyer-portal",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "A plugin for faststore with buyer portal",
5
5
  "main": "index.js",
6
6
  "dependencies": {},
package/plugin.config.js CHANGED
@@ -1,9 +1,33 @@
1
1
  module.exports = {
2
2
  name: "poc-plugin",
3
3
  pages: {
4
- "buyer-portal": {
4
+ home: {
5
5
  path: "/buyer-portal",
6
- appLayout: false
6
+ appLayout: false,
7
+ },
8
+ "org-units": {
9
+ path: "/org-units",
10
+ appLayout: false,
11
+ },
12
+ contracts: {
13
+ path: "/contracts",
14
+ appLayout: false,
15
+ },
16
+ addresses: {
17
+ path: "/addresses",
18
+ appLayout: false,
19
+ },
20
+ "address-details": {
21
+ path: "/address/[id]",
22
+ appLayout: false,
23
+ },
24
+ users: {
25
+ path: "/users",
26
+ appLayout: false,
27
+ },
28
+ "user-details": {
29
+ path: "/user/[id]",
30
+ appLayout: false,
7
31
  },
8
32
  },
9
33
  };
@@ -0,0 +1,219 @@
1
+ <svg style="display:none">
2
+ <symbol id="Active" xmlns="http://www.w3.org/2000/svg" fill="currentColor"
3
+ viewBox="0 -960 960 960">
4
+ <path
5
+ d="M320-280h320v-80H320v80Zm118-120 226-226-57-55-169 169-86-86-56 56 142 142Zm42 320q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z" />
6
+ </symbol>
7
+
8
+ <symbol
9
+ id="Add"
10
+ xmlns="http://www.w3.org/2000/svg"
11
+ viewBox="0 -960 960 960"
12
+ fill="currentColor"
13
+ >
14
+ <path d="M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z" />
15
+ </symbol>
16
+
17
+ <symbol
18
+ id="Address" xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"
19
+ fill="currentColor">
20
+ <path
21
+ d="M120-120v-560h160v-160h400v320h160v400H520v-160h-80v160H120Zm80-80h80v-80h-80v80Zm0-160h80v-80h-80v80Zm0-160h80v-80h-80v80Zm160 160h80v-80h-80v80Zm0-160h80v-80h-80v80Zm0-160h80v-80h-80v80Zm160 320h80v-80h-80v80Zm0-160h80v-80h-80v80Zm0-160h80v-80h-80v80Zm160 480h80v-80h-80v80Zm0-160h80v-80h-80v80Z" />
22
+ </symbol>
23
+
24
+ <symbol
25
+ id="ArrowDropDown"
26
+ xmlns="http://www.w3.org/2000/svg"
27
+ viewBox="0 -960 960 960"
28
+ fill="currentColor"
29
+ >
30
+ <path d="M480-360 280-560h400L480-360Z" />
31
+ </symbol>
32
+
33
+ <symbol
34
+ id="ArrowRight"
35
+ xmlns="http://www.w3.org/2000/svg"
36
+ viewBox="0 -960 960 960"
37
+ fill="currentColor"
38
+ >
39
+ <path d="M400-280v-400l200 200-200 200Z" />
40
+ </symbol>
41
+
42
+ <symbol id="ArrowSquareOut" xmlns="http://www.w3.org/2000/svg" fill="currentColor"
43
+ viewBox="0 0 256 256">
44
+ <rect width="256" height="256" fill="none"></rect>
45
+ <polyline points="216 100 216 40 156 40" fill="none" stroke="currentColor"
46
+ stroke-linecap="round" stroke-linejoin="round"></polyline>
47
+ <line x1="144" y1="112" x2="216" y2="40" fill="none" stroke="currentColor"
48
+ stroke-linecap="round" stroke-linejoin="round"></line>
49
+ <path d="M184,144v64a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V80a8,8,0,0,1,8-8h64" fill="none"
50
+ stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path>
51
+ </symbol>
52
+
53
+ <symbol id="Back"
54
+ xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="currentColor">
55
+ <path d="m313-440 224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z" />
56
+ </symbol>
57
+
58
+ <symbol id="CaretRight" xmlns="http://www.w3.org/2000/svg" fill="currentColor"
59
+ viewBox="0 0 256 256">
60
+ <rect width="256" height="256" fill="none"></rect>
61
+ <polyline points="96 48 176 128 96 208" fill="none" stroke="currentColor" stroke-linecap="round"
62
+ stroke-linejoin="round"></polyline>
63
+ </symbol>
64
+
65
+
66
+ <symbol
67
+ id="Delete" xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"
68
+ fill="currentColor">
69
+ <path
70
+ d="M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z" />
71
+ </symbol>
72
+
73
+ <symbol
74
+ id="Down" xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="currentColor">
75
+ <path d="M480-344 246-576h468L480-344Z" />
76
+ </symbol>
77
+
78
+ <symbol
79
+ id="Edit"
80
+ xmlns="http://www.w3.org/2000/svg"
81
+ viewBox="0 -960 960 960"
82
+ fill="currentColor"
83
+ >
84
+ <path
85
+ d="M200-200h57l391-391-57-57-391 391v57Zm-80 80v-170l528-527q12-11 26.5-17t30.5-6q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L290-120H120Zm640-584-56-56 56 56Zm-141 85-28-29 57 57-29-28Z" />
86
+ </symbol>
87
+
88
+ <symbol
89
+ id="FilledFolder"
90
+ xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="currentColor">
91
+ <path
92
+ d="M160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h240l80 80h320q33 0 56.5 23.5T880-640v400q0 33-23.5 56.5T800-160H160Z" />
93
+ </symbol>
94
+
95
+ <symbol
96
+ id="Folder"
97
+ xmlns="http://www.w3.org/2000/svg"
98
+ viewBox="0 -960 960 960"
99
+ fill="currentColor"
100
+ >
101
+ <path
102
+ d="M160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h240l80 80h320q33 0 56.5 23.5T880-640v400q0 33-23.5 56.5T800-160H160Zm0-80h640v-400H447l-80-80H160v480Zm0 0v-480 480Z" />
103
+ </symbol>
104
+
105
+ <symbol
106
+ id="FolderSpecial"
107
+ xmlns="http://www.w3.org/2000/svg"
108
+ viewBox="0 -960 960 960"
109
+ fill="currentColor"
110
+ >
111
+ <path
112
+ d="m504-292 92-70 92 70-34-114 92-74H632l-36-112-36 112H446l92 74-34 114ZM160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h240l80 80h320q33 0 56.5 23.5T880-640v400q0 33-23.5 56.5T800-160H160Zm0-80h640v-400H447l-80-80H160v480Zm0 0v-480 480Z" />
113
+ </symbol>
114
+
115
+ <symbol id="Info" xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"
116
+ fill="currentColor">
117
+ <path
118
+ d="M440-280h80v-240h-80v240Zm40-320q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm0 520q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z" />
119
+ </symbol>
120
+
121
+ <symbol id="Link" xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="currentColor">
122
+ <path d="m256-240-56-56 384-384H240v-80h480v480h-80v-344L256-240Z" />
123
+ </symbol>
124
+
125
+
126
+ <symbol id="Load" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
127
+ <g stroke="currentColor">
128
+ <circle
129
+ cx="12"
130
+ cy="12"
131
+ r="9.5"
132
+ fill="none"
133
+ stroke-linecap="round"
134
+ stroke-width="3"
135
+ >
136
+ <animate
137
+ attributeName="stroke-dasharray"
138
+ calcMode="spline"
139
+ dur="1.5s"
140
+ keySplines="0.42,0,0.58,1;0.42,0,0.58,1;0.42,0,0.58,1"
141
+ keyTimes="0;0.475;0.95;1"
142
+ repeatCount="indefinite"
143
+ values="0 150;42 150;42 150;42 150"
144
+ />
145
+ <animate
146
+ attributeName="stroke-dashoffset"
147
+ calcMode="spline"
148
+ dur="1.5s"
149
+ keySplines="0.42,0,0.58,1;0.42,0,0.58,1;0.42,0,0.58,1"
150
+ keyTimes="0;0.475;0.95;1"
151
+ repeatCount="indefinite"
152
+ values="0;-16;-59;-59"
153
+ />
154
+ </circle>
155
+ <animateTransform
156
+ attributeName="transform"
157
+ dur="2s"
158
+ repeatCount="indefinite"
159
+ type="rotate"
160
+ values="0 12 12;360 12 12"
161
+ />
162
+ </g>
163
+ </symbol>
164
+
165
+ <symbol
166
+ id="LocalPostOffice"
167
+ xmlns="http://www.w3.org/2000/svg"
168
+ viewBox="0 -960 960 960"
169
+ fill="currentColor"
170
+ >
171
+ <path
172
+ d="M640-200v80q0 17-11.5 28.5T600-80H120q-17 0-28.5-11.5T80-120v-320q0-17 11.5-28.5T120-480h120v-160q0-100 70-170t170-70h160q100 0 170 70t70 170v560h-80v-120H640Zm0-80h160v-360q0-66-47-113t-113-47H480q-66 0-113 47t-47 113v160h280q17 0 28.5 11.5T640-440v160ZM400-560v-80h320v80H400Zm-40 274 200-114H160l200 114Zm0 70L160-330v170h400v-170L360-216ZM160-400v240-240Z" />
173
+ </symbol>
174
+
175
+
176
+ <symbol
177
+ id="MoreVert"
178
+ xmlns="http://www.w3.org/2000/svg"
179
+ viewBox="0 -960 960 960"
180
+ fill="currentColor"
181
+ >
182
+ <path
183
+ d="M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z" />
184
+ </symbol>
185
+
186
+
187
+ <symbol
188
+ id="OpenInNew"
189
+ xmlns="http://www.w3.org/2000/svg"
190
+ viewBox="0 -960 960 960"
191
+ fill="currentColor"
192
+ >
193
+ <path
194
+ d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h280v80H200v560h560v-280h80v280q0 33-23.5 56.5T760-120H200Zm188-212-56-56 372-372H560v-80h280v280h-80v-144L388-332Z" />
195
+ </symbol>
196
+
197
+
198
+ <symbol
199
+ id="Profile"
200
+ xmlns="http://www.w3.org/2000/svg"
201
+ viewBox="0 0 14 14"
202
+ fill="none"
203
+ >
204
+ <path
205
+ d="M7.00065 7.00114C6.08398 7.00114 5.29926 6.67475 4.64648 6.02197C3.99371 5.3692 3.66732 4.58447 3.66732 3.66781C3.66732 2.75114 3.99371 1.96642 4.64648 1.31364C5.29926 0.660862 6.08398 0.334473 7.00065 0.334473C7.91732 0.334473 8.70204 0.660862 9.35482 1.31364C10.0076 1.96642 10.334 2.75114 10.334 3.66781C10.334 4.58447 10.0076 5.3692 9.35482 6.02197C8.70204 6.67475 7.91732 7.00114 7.00065 7.00114ZM0.333984 13.6678V11.3345C0.333984 10.8623 0.455512 10.4282 0.698568 10.0324C0.941623 9.63656 1.26454 9.33447 1.66732 9.12614C2.52843 8.69559 3.40343 8.37267 4.29232 8.15739C5.18121 7.94211 6.08398 7.83447 7.00065 7.83447C7.91732 7.83447 8.8201 7.94211 9.70899 8.15739C10.5979 8.37267 11.4729 8.69559 12.334 9.12614C12.7368 9.33447 13.0597 9.63656 13.3027 10.0324C13.5458 10.4282 13.6673 10.8623 13.6673 11.3345V13.6678H0.333984Z"
206
+ fill="currentColor"
207
+ />
208
+ </symbol>
209
+
210
+ <symbol
211
+ id="StarFolder"
212
+ xmlns="http://www.w3.org/2000/svg"
213
+ viewBox="0 -960 960 960"
214
+ fill="currentColor"
215
+ >
216
+ <path
217
+ d="M154-128q-43.72 0-74.86-31.14Q48-190.27 48-234v-492q0-43.72 31.14-74.86T154-832h220l106 106h326q43.72 0 74.86 31.14T912-620v386q0 43.73-31.14 74.86Q849.72-128 806-128H154Zm339.67-136 104.16-79.68L702-264l-38-130 104-84H638l-40-126-40 126H428l104.17 84.23L493.67-264Z" />
218
+ </symbol>
219
+ </svg>
@@ -0,0 +1,46 @@
1
+ import { Toggle } from "@faststore/ui";
2
+ import Link from "next/link";
3
+ import { Tag } from "../Tag/Tag";
4
+ import { Icon } from "../Icon";
5
+
6
+ export type AddressLineProps = {
7
+ id: string;
8
+ name: string;
9
+ tags: string[];
10
+ status: boolean;
11
+ href: string;
12
+ };
13
+
14
+ export const AddressLine = ({
15
+ name,
16
+ tags,
17
+ id,
18
+ href,
19
+ status,
20
+ }: AddressLineProps) => (
21
+ <li data-fs-addresses-line>
22
+ <Icon
23
+ name="LocalPostOffice"
24
+ width={20}
25
+ height={20}
26
+ data-fs-addresses-line-icon
27
+ />
28
+ <Link title={name} href={href} data-fs-addresses-line-name>
29
+ {name}
30
+ </Link>
31
+
32
+ {tags.map((tag, index) => (
33
+ <Tag key={index}>{tag}</Tag>
34
+ ))}
35
+
36
+ <Toggle id={id} defaultChecked={status} />
37
+ <button data-fs-addresses-dropdown-trigger>
38
+ <Icon
39
+ name="MoreVert"
40
+ width={20}
41
+ height={20}
42
+ data-fs-addresses-dropdown-trigger-icon
43
+ />
44
+ </button>
45
+ </li>
46
+ );
@@ -0,0 +1,45 @@
1
+ [data-fs-addresses-line] {
2
+ width: 100%;
3
+ display: flex;
4
+ align-items: center;
5
+ justify-content: space-between;
6
+ position: relative;
7
+
8
+ padding: var(--fs-spacing-2) 0;
9
+ border-top: var(--fs-border-width) solid #e5e5e5;
10
+
11
+ display: flex;
12
+ align-items: center;
13
+
14
+ [data-fs-addresses-line-icon] {
15
+ color: #0068d7;
16
+ margin-right: var(--fs-spacing-1);
17
+ }
18
+
19
+ [data-fs-addresses-line-name] {
20
+ width: 25%;
21
+ margin-right: var(--fs-spacing-3);
22
+ font-weight: var(--fs-text-weight-medium);
23
+ font-size: var(--fs-text-size-1);
24
+ line-height: calc(var(--fs-spacing-3) + var(--fs-spacing-0));
25
+ text-decoration: none;
26
+ cursor: pointer;
27
+ color: #1f1f1f;
28
+ white-space: nowrap;
29
+ overflow: hidden;
30
+ text-overflow: ellipsis;
31
+ }
32
+
33
+ [data-fs-toggle] {
34
+ margin-left: auto;
35
+ margin-right: calc(var(--fs-spacing-3) + var(--fs-spacing-0));
36
+ }
37
+
38
+ [data-fs-addresses-dropdown-trigger] {
39
+ cursor: pointer;
40
+
41
+ [data-fs-addresses-dropdown-trigger-icon] {
42
+ color: #707070;
43
+ }
44
+ }
45
+ }
@@ -1,89 +1,132 @@
1
1
  import {
2
- IconButton, Icon, Toggle, Dropdown,
2
+ Icon as UIIcon,
3
+ IconButton,
4
+ Toggle,
5
+ Dropdown,
3
6
  DropdownItem,
4
7
  DropdownMenu,
5
8
  DropdownButton,
6
- } from '@faststore/ui'
9
+ } from "@faststore/ui";
7
10
  import Link from "next/link";
8
11
 
9
- import { Card, CardBody, CardFooter, CardHeader } from '../Card'
10
- import * as Icons from "../Icons";
11
-
12
- export type AddressInformation = {
13
- addressId: string,
14
- street: string,
15
- addressType: string,
16
- isActive: boolean,
17
- }
12
+ import { Card, CardBody, CardFooter, CardHeader } from "../Card";
13
+ import { Tag } from "../Tag/Tag";
14
+ import { useRouter } from "next/router";
15
+ import { AddressData } from "../../types/AddressData";
16
+ import { Icon } from "../Icon";
18
17
 
19
18
  type AddressesCardProps = {
20
- addresses: AddressInformation[]
21
- }
19
+ addresses: AddressData[];
20
+ };
22
21
 
23
22
  export default function AddressesCard({ addresses }: AddressesCardProps) {
23
+ const { push } = useRouter();
24
+
24
25
  return (
25
- <section data-fs-home-card>
26
- <Card>
27
- <CardHeader>
28
- <div data-fs-card-title>Addresses <span data-fs-card-title-counter>{addresses.length}</span></div>
29
- <IconButton icon={<Icon name="PlusCircle" width={20} height={20} />}
30
- aria-label={`$addresses action`} onClick={() => { }} />
31
- </CardHeader>
32
- <CardBody>
33
- {addresses.length && addresses.map((address: AddressInformation) => {
26
+ <Card>
27
+ <CardHeader>
28
+ <div data-fs-card-title>
29
+ Addresses <span data-fs-card-title-counter>{addresses.length}</span>
30
+ </div>
31
+ <IconButton
32
+ icon={<UIIcon name="PlusCircle" width={20} height={20} />}
33
+ aria-label={`$addresses action`}
34
+ onClick={() => {}}
35
+ />
36
+ </CardHeader>
37
+ <CardBody>
38
+ {addresses.length &&
39
+ addresses.slice(0, 5).map((address) => {
34
40
  return (
35
- <div>
41
+ <div key={address.id}>
36
42
  <hr data-fs-divider />
37
43
 
38
- <div data-fs-card-row key={address.addressId}>
44
+ <div data-fs-card-row key={address.id}>
39
45
  <div data-fs-card-information-row>
40
46
  <div data-fs-card-information-icon>
41
- <Icons.Address height={24} width={24} />
47
+ <Icon name="LocalPostOffice" height={24} width={24} />
42
48
  </div>
43
49
  <div data-fs-card-information-title>
44
- <span >{address.street}</span>
50
+ <span title={address.name}>{address.name}</span>
45
51
  </div>
52
+
46
53
  <div data-fs-card-information-type>
47
- <span data-fs-shipping-tag>{address.addressType}</span>
54
+ {address.tags.map((tag) => (
55
+ <Tag>{tag}</Tag>
56
+ ))}
48
57
  </div>
49
58
  </div>
50
59
  <div data-fs-card-action-row>
51
- <Toggle id="addressActive" defaultChecked={address.isActive} />
60
+ <Toggle
61
+ id="addressActive"
62
+ defaultChecked={address.status}
63
+ />
52
64
 
53
65
  <Dropdown>
54
- <DropdownButton><Icon name='DotsThree' data-fs-menu-action-button /></DropdownButton>
66
+ <DropdownButton>
67
+ <UIIcon name="DotsThree" data-fs-menu-action-button />
68
+ </DropdownButton>
55
69
  <DropdownMenu>
56
- <DropdownItem>
57
- <Icon name="ArrowSquareOut" data-fs-dropdown-icon />Open
70
+ <DropdownItem data-fs-card-dropdown-item>
71
+ <Icon name="ArrowSquareOut" data-fs-dropdown-icon />
72
+ Open
58
73
  </DropdownItem>
59
74
  <DropdownItem>
60
- <Icons.Edit width={24} height={24} data-fs-dropdown-icon />Edit
75
+ <Icon
76
+ name="Edit"
77
+ width={24}
78
+ height={24}
79
+ data-fs-dropdown-icon
80
+ />
81
+ Edit
61
82
  </DropdownItem>
62
83
  <DropdownItem>
63
- <Icons.Delete width={24} height={24} data-fs-dropdown-icon /> Delete
84
+ <Icon
85
+ name="Delete"
86
+ width={24}
87
+ height={24}
88
+ data-fs-dropdown-icon
89
+ />{" "}
90
+ Delete
64
91
  </DropdownItem>
65
92
  <DropdownItem>
66
93
  <div data-fs-dropdown-active-item>
67
94
  <div data-fs-dropdown-active-item-label>
68
- <Icons.Active width={24} height={24} data-fs-dropdown-icon /> Active
95
+ <Icon
96
+ name="Active"
97
+ width={24}
98
+ height={24}
99
+ data-fs-dropdown-icon
100
+ />{" "}
101
+ Active
69
102
  </div>
70
- <Toggle id="addressActiveMenu" defaultChecked={address.isActive} data-fs-internal-toggle />
103
+ <Toggle
104
+ id="addressActiveMenu"
105
+ defaultChecked={address.status}
106
+ data-fs-internal-toggle
107
+ />
71
108
  </div>
72
109
  </DropdownItem>
73
110
  </DropdownMenu>
74
111
  </Dropdown>
75
112
  </div>
76
113
  </div>
77
- </div>)
114
+ </div>
115
+ );
78
116
  })}
79
- </CardBody>
80
- <CardFooter>
81
- <Link href="/" data-fs-card-footer-link>
82
- <span>Manage addresses</span>
83
- </Link>
84
- <IconButton icon={<Icon name="CaretRight" data-fs-card-footer-icon />} aria-label="manage-addresses" />
85
- </CardFooter>
86
- </Card>
87
- </section>
88
- )
117
+ </CardBody>
118
+ <CardFooter>
119
+ <Link href="/addresses" data-fs-card-footer-link>
120
+ <span>Manage addresses</span>
121
+ </Link>
122
+ <IconButton
123
+ onClick={() => {
124
+ push("/addresses");
125
+ }}
126
+ icon={<Icon name="CaretRight" data-fs-card-footer-icon />}
127
+ aria-label="manage-addresses"
128
+ />
129
+ </CardFooter>
130
+ </Card>
131
+ );
89
132
  }