contentoh-components-library 21.4.30 → 21.4.32

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 (170) hide show
  1. package/dist/assets/images/defaultImages/check_circle.svg +10 -0
  2. package/dist/components/atoms/Avatar/index.js +3 -2
  3. package/dist/components/atoms/Card/index.js +46 -5
  4. package/dist/components/atoms/Card/styles.js +3 -1
  5. package/dist/components/atoms/CheckBox/index.js +7 -2
  6. package/dist/components/atoms/CheckBox/styles.js +1 -1
  7. package/dist/components/atoms/ImageCarousel/ImgeSlider.stories.js +90 -0
  8. package/dist/components/atoms/ImageCarousel/index.js +120 -0
  9. package/dist/components/atoms/ImageCarousel/styles.js +18 -0
  10. package/dist/components/atoms/InputFormatter/styles.js +1 -1
  11. package/dist/components/atoms/PercentTag/PercentTag.stories.js +31 -0
  12. package/dist/components/atoms/PercentTag/index.js +23 -0
  13. package/dist/components/atoms/PercentTag/styles.js +22 -0
  14. package/dist/components/atoms/RatingStars/RatingStars.stories.js +30 -0
  15. package/dist/components/atoms/RatingStars/index.js +53 -0
  16. package/dist/components/atoms/RatingStars/styles.js +18 -0
  17. package/dist/components/atoms/RetailerCatalog/RetailerCatalog.stories.js +48 -0
  18. package/dist/components/atoms/RetailerCatalog/index.js +69 -0
  19. package/dist/components/atoms/RetailerCatalog/styles.js +20 -0
  20. package/dist/components/atoms/RetailerOption/RetailerOption.stories.js +33 -0
  21. package/dist/components/atoms/RetailerOption/index.js +62 -0
  22. package/dist/components/atoms/RetailerOption/styles.js +20 -0
  23. package/dist/components/atoms/RetailersList/RetailersList.stories.js +45 -0
  24. package/dist/components/atoms/RetailersList/index.js +46 -0
  25. package/dist/components/atoms/RetailersList/styles.js +18 -0
  26. package/dist/components/atoms/SliderToolTip/styles.js +1 -1
  27. package/dist/components/atoms/UserCatalog/UserCatalog.stories.js +73 -0
  28. package/dist/components/atoms/UserCatalog/index.js +101 -0
  29. package/dist/components/atoms/UserCatalog/styles.js +18 -0
  30. package/dist/components/atoms/UserOption/UserOption.stories.js +40 -0
  31. package/dist/components/atoms/UserOption/index.js +130 -0
  32. package/dist/components/atoms/UserOption/styles.js +20 -0
  33. package/dist/components/atoms/UserSelector/UserSelector.stories.js +40 -0
  34. package/dist/components/atoms/UserSelector/index.js +98 -0
  35. package/dist/components/atoms/UserSelector/styles.js +32 -0
  36. package/dist/components/molecules/CarouselImagesLogin/index.js +1 -1
  37. package/dist/components/molecules/GridItem/GridItem.stories.js +123 -0
  38. package/dist/components/molecules/GridItem/index.js +152 -0
  39. package/dist/components/molecules/GridItem/styles.js +20 -0
  40. package/dist/components/molecules/HeaderItem/ColumnItem.js +23 -0
  41. package/dist/components/molecules/HeaderItem/HeaderItem.stories.js +70 -0
  42. package/dist/components/molecules/HeaderItem/index.js +42 -0
  43. package/dist/components/molecules/HeaderItem/styles.js +30 -0
  44. package/dist/components/molecules/HeaderTop/index.js +68 -11
  45. package/dist/components/molecules/RowItem/ColumnItem.js +23 -0
  46. package/dist/components/molecules/RowItem/RowItem.stories.js +5242 -0
  47. package/dist/components/molecules/RowItem/index.js +58 -0
  48. package/dist/components/molecules/RowItem/styles.js +30 -0
  49. package/dist/components/molecules/StripeCardForm/StripeCardForm.stories.js +32 -0
  50. package/dist/components/molecules/StripeCardForm/index.js +94 -0
  51. package/dist/components/molecules/StripeCardForm/paymentForm.js +199 -0
  52. package/dist/components/molecules/StripeCardForm/styles.js +27 -0
  53. package/dist/components/molecules/StripeCardSelector/CardSelector.stories.js +30 -0
  54. package/dist/components/molecules/StripeCardSelector/index.js +125 -0
  55. package/dist/components/molecules/StripeCardSelector/styles.js +22 -0
  56. package/dist/components/molecules/StripeCardSelector/utils.js +56 -0
  57. package/dist/components/molecules/TagAndInput/index.js +1 -1
  58. package/dist/components/organisms/Chat/Chat.stories.js +27 -8
  59. package/dist/components/organisms/Chat/ContainerItems/index.js +19 -3
  60. package/dist/components/organisms/Chat/ContainerItems/styles.js +1 -1
  61. package/dist/components/organisms/Chat/ContentChat/index.js +350 -197
  62. package/dist/components/organisms/Chat/Footer/index.js +48 -39
  63. package/dist/components/organisms/Chat/index.js +49 -4
  64. package/dist/components/organisms/Chat/styles.js +1 -1
  65. package/dist/components/organisms/FullProductNameHeader/index.js +2 -2
  66. package/dist/components/organisms/GridProducts/GridProducts.stories.js +5097 -0
  67. package/dist/components/organisms/GridProducts/index.js +63 -0
  68. package/dist/components/organisms/GridProducts/styles.js +18 -0
  69. package/dist/components/organisms/GridProducts/utils.js +149 -0
  70. package/dist/components/organisms/Modal/styles.js +1 -1
  71. package/dist/components/organisms/PanelLayout/PanelLayout.stories.js +87 -0
  72. package/dist/components/organisms/PanelLayout/index.js +29 -0
  73. package/dist/components/organisms/PanelLayout/styles.js +32 -0
  74. package/dist/components/organisms/SideModal/SideModal.stories.js +42 -0
  75. package/dist/components/organisms/SideModal/index.js +72 -0
  76. package/dist/components/organisms/SideModal/styles.js +18 -0
  77. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +6 -4
  78. package/dist/components/pages/ProviderProductEdition/index.js +117 -142
  79. package/dist/components/pages/ProviderProductEdition/styles.js +1 -1
  80. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +7 -3
  81. package/dist/components/pages/RetailerProductEdition/index.js +276 -274
  82. package/dist/components/pages/RetailerProductEdition/styles.js +1 -1
  83. package/dist/components/pages/RetailerProductEdition/utils.js +61 -2
  84. package/dist/index.js +247 -52
  85. package/package.json +4 -1
  86. package/src/assets/images/defaultImages/check_circle.svg +10 -0
  87. package/src/components/atoms/Avatar/index.js +8 -2
  88. package/src/components/atoms/Card/index.js +35 -2
  89. package/src/components/atoms/Card/styles.js +41 -5
  90. package/src/components/atoms/CheckBox/index.js +4 -1
  91. package/src/components/atoms/CheckBox/styles.js +2 -0
  92. package/src/components/atoms/ImageCarousel/ImgeSlider.stories.js +76 -0
  93. package/src/components/atoms/ImageCarousel/index.js +103 -0
  94. package/src/components/atoms/ImageCarousel/styles.js +79 -0
  95. package/src/components/atoms/InputFormatter/styles.js +2 -1
  96. package/src/components/atoms/PercentTag/PercentTag.stories.js +7 -0
  97. package/src/components/atoms/PercentTag/index.js +9 -0
  98. package/src/components/atoms/PercentTag/styles.js +69 -0
  99. package/src/components/atoms/RatingStars/RatingStars.stories.js +10 -0
  100. package/src/components/atoms/RatingStars/index.js +31 -0
  101. package/src/components/atoms/RatingStars/styles.js +28 -0
  102. package/src/components/atoms/RetailerCatalog/RetailerCatalog.stories.js +36 -0
  103. package/src/components/atoms/RetailerCatalog/index.js +49 -0
  104. package/src/components/atoms/RetailerCatalog/styles.js +30 -0
  105. package/src/components/atoms/RetailerOption/RetailerOption.stories.js +15 -0
  106. package/src/components/atoms/RetailerOption/index.js +53 -0
  107. package/src/components/atoms/RetailerOption/styles.js +41 -0
  108. package/src/components/atoms/RetailersList/RetailersList.stories.js +33 -0
  109. package/src/components/atoms/RetailersList/index.js +20 -0
  110. package/src/components/atoms/RetailersList/styles.js +19 -0
  111. package/src/components/atoms/SliderToolTip/styles.js +1 -1
  112. package/src/components/atoms/UserCatalog/UserCatalog.stories.js +67 -0
  113. package/src/components/atoms/UserCatalog/index.js +100 -0
  114. package/src/components/atoms/UserCatalog/styles.js +24 -0
  115. package/src/components/atoms/UserOption/UserOption.stories.js +25 -0
  116. package/src/components/atoms/UserOption/index.js +95 -0
  117. package/src/components/atoms/UserOption/styles.js +61 -0
  118. package/src/components/atoms/UserSelector/UserSelector.stories.js +25 -0
  119. package/src/components/atoms/UserSelector/index.js +86 -0
  120. package/src/components/atoms/UserSelector/styles.js +55 -0
  121. package/src/components/molecules/CarouselImagesLogin/index.js +1 -1
  122. package/src/components/molecules/GridItem/GridItem.stories.js +126 -0
  123. package/src/components/molecules/GridItem/index.js +105 -0
  124. package/src/components/molecules/GridItem/styles.js +104 -0
  125. package/src/components/molecules/HeaderItem/ColumnItem.js +9 -0
  126. package/src/components/molecules/HeaderItem/HeaderItem.stories.js +24 -0
  127. package/src/components/molecules/HeaderItem/index.js +26 -0
  128. package/src/components/molecules/HeaderItem/styles.js +27 -0
  129. package/src/components/molecules/HeaderTop/index.js +52 -6
  130. package/src/components/molecules/RowItem/ColumnItem.js +9 -0
  131. package/src/components/molecules/RowItem/RowItem.stories.js +5660 -0
  132. package/src/components/molecules/RowItem/index.js +45 -0
  133. package/src/components/molecules/RowItem/styles.js +40 -0
  134. package/src/components/molecules/StripeCardForm/StripeCardForm.stories.js +14 -0
  135. package/src/components/molecules/StripeCardForm/index.js +45 -0
  136. package/src/components/molecules/StripeCardForm/paymentForm.js +126 -0
  137. package/src/components/molecules/StripeCardForm/styles.js +84 -0
  138. package/src/components/molecules/StripeCardSelector/CardSelector.stories.js +12 -0
  139. package/src/components/molecules/StripeCardSelector/index.js +59 -0
  140. package/src/components/molecules/StripeCardSelector/styles.js +15 -0
  141. package/src/components/molecules/StripeCardSelector/utils.js +17 -0
  142. package/src/components/molecules/TagAndInput/index.js +10 -8
  143. package/src/components/organisms/Chat/Chat.stories.js +27 -7
  144. package/src/components/organisms/Chat/ContainerItems/index.js +18 -2
  145. package/src/components/organisms/Chat/ContainerItems/styles.js +14 -2
  146. package/src/components/organisms/Chat/ContentChat/index.js +88 -12
  147. package/src/components/organisms/Chat/Footer/index.js +11 -0
  148. package/src/components/organisms/Chat/index.js +46 -4
  149. package/src/components/organisms/Chat/styles.js +4 -0
  150. package/src/components/organisms/FullProductNameHeader/index.js +1 -1
  151. package/src/components/organisms/GridProducts/GridProducts.stories.js +5485 -0
  152. package/src/components/organisms/GridProducts/index.js +50 -0
  153. package/src/components/organisms/GridProducts/styles.js +14 -0
  154. package/src/components/organisms/GridProducts/utils.js +111 -0
  155. package/src/components/organisms/Modal/styles.js +4 -1
  156. package/src/components/organisms/OrderDetail/utils/Table/utils.js +6 -16
  157. package/src/components/organisms/PanelLayout/PanelLayout.stories.js +63 -0
  158. package/src/components/organisms/PanelLayout/index.js +11 -0
  159. package/src/components/organisms/PanelLayout/styles.js +39 -0
  160. package/src/components/organisms/SideModal/SideModal.stories.js +23 -0
  161. package/src/components/organisms/SideModal/index.js +50 -0
  162. package/src/components/organisms/SideModal/styles.js +30 -0
  163. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +6 -4
  164. package/src/components/pages/ProviderProductEdition/index.js +97 -129
  165. package/src/components/pages/ProviderProductEdition/styles.js +5 -1
  166. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +6 -2
  167. package/src/components/pages/RetailerProductEdition/index.js +111 -142
  168. package/src/components/pages/RetailerProductEdition/styles.js +4 -0
  169. package/src/components/pages/RetailerProductEdition/utils.js +37 -0
  170. package/src/index.js +15 -0
@@ -0,0 +1,49 @@
1
+ import { useState } from "react";
2
+ import { Avatar } from "../Avatar";
3
+ import { Container } from "./styles";
4
+ import { useEffect } from "react";
5
+ import { useCloseModal } from "../../../global-files/customHooks";
6
+ import { RetailersList } from "../RetailersList";
7
+
8
+ export const RetailerCatalog = ({
9
+ retailers = [],
10
+ limit = 3,
11
+ article,
12
+ id = "retailers-catalog",
13
+ }) => {
14
+ const [retLimit, setRetLimit] = useState(0);
15
+ const [showRetailers, setShowRetailers] = useCloseModal(id);
16
+
17
+ useEffect(() => {
18
+ setRetLimit(limit);
19
+ }, [retailers]);
20
+
21
+ return (
22
+ <Container
23
+ onClick={(e) => {
24
+ setShowRetailers(!showRetailers);
25
+ }}
26
+ id={id}
27
+ >
28
+ {retailers.map(
29
+ (retailer, i) =>
30
+ i < limit && (
31
+ <Avatar
32
+ key={retailer.id + "-" + i}
33
+ image={`https://content-management-images.s3.amazonaws.com/retailers/${retailer.id}.png`}
34
+ altText={retailer?.name}
35
+ imageType={"medium-image"}
36
+ />
37
+ )
38
+ )}
39
+ {retailers.length > retLimit && (
40
+ <div className="retailers-limit">
41
+ <p>+{retailers.length - retLimit}</p>
42
+ </div>
43
+ )}
44
+ {showRetailers && (
45
+ <RetailersList retailers={retailers} article={article} />
46
+ )}
47
+ </Container>
48
+ );
49
+ };
@@ -0,0 +1,30 @@
1
+ import styled from "styled-components";
2
+ import { FontFamily } from "../../../global-files/variables";
3
+
4
+ export const Container = styled.div`
5
+ display: flex;
6
+ align-items: center;
7
+ justify-content: center;
8
+ cursor: pointer;
9
+ position: relative;
10
+ width: 100%;
11
+
12
+ .retailers-limit {
13
+ width: 26px;
14
+ height: 26px;
15
+ border-radius: 50%;
16
+ background-color: #f0f0f0;
17
+
18
+ p {
19
+ font-family: ${FontFamily.Lato};
20
+ font-size: 12px;
21
+ line-height: 26px;
22
+ color: #262626;
23
+ text-align: center;
24
+ }
25
+ }
26
+
27
+ > * + * {
28
+ margin-left: -5px;
29
+ }
30
+ `;
@@ -0,0 +1,15 @@
1
+ import { RetailerOption } from ".";
2
+
3
+ export default {
4
+ title: "Components/atoms/RetailerOptions",
5
+ component: RetailerOption,
6
+ };
7
+
8
+ const Template = (args) => <RetailerOption {...args} />;
9
+ export const RetailerOptionDefault = Template.bind({});
10
+ RetailerOptionDefault.args = {
11
+ retailer: {
12
+ id: 58,
13
+ name: "The Home Depot Golden",
14
+ },
15
+ };
@@ -0,0 +1,53 @@
1
+ import { useState } from "react";
2
+ import { Avatar } from "../Avatar";
3
+ import { Container } from "./styles";
4
+ import { useEffect } from "react";
5
+
6
+ export const RetailerOption = ({ retailer, services = {} }) => {
7
+ const [service, setService] = useState([]);
8
+
9
+ useEffect(() => {
10
+ if (services[retailer.id]) {
11
+ setService(Object.keys(services[retailer.id]));
12
+ }
13
+ }, [services]);
14
+
15
+ return (
16
+ <Container>
17
+ <div className="avatar-and-retailer">
18
+ <Avatar
19
+ image={`https://content-management-images.s3.amazonaws.com/retailers/${retailer.id}.png`}
20
+ altText={retailer?.name}
21
+ imageType={"medium-image"}
22
+ />
23
+ <p className="retailer-name">{retailer?.name}</p>
24
+ </div>
25
+ <div className="services-icons">
26
+ <span
27
+ key="datasheet"
28
+ className={`material-icons small ${
29
+ service.includes("datasheet") && "is-active"
30
+ }`}
31
+ >
32
+ &#xf8ee;
33
+ </span>
34
+ <span
35
+ key="description"
36
+ className={`material-icons small ${
37
+ service.includes("description") && "is-active"
38
+ }`}
39
+ >
40
+ &#xe873;
41
+ </span>
42
+ <span
43
+ key="images"
44
+ className={`material-icons small ${
45
+ service.includes("images") && "is-active"
46
+ }`}
47
+ >
48
+ &#xe3f4;
49
+ </span>
50
+ </div>
51
+ </Container>
52
+ );
53
+ };
@@ -0,0 +1,41 @@
1
+ import styled from "styled-components";
2
+ import { FontFamily } from "../../../global-files/variables";
3
+
4
+ export const Container = styled.div`
5
+ display: flex;
6
+ padding: 7px;
7
+ border: 1px solid #f0f0f0;
8
+ align-items: center;
9
+ justify-content: space-between;
10
+ border-radius: 5px;
11
+
12
+ .avatar-and-retailer {
13
+ display: flex;
14
+ align-items: center;
15
+ .retailer-name {
16
+ font-family: ${FontFamily.Lato};
17
+ font-size: 12px;
18
+ color: #262626;
19
+ }
20
+
21
+ > * + * {
22
+ margin-left: 10px;
23
+ }
24
+ }
25
+
26
+ .services-icons {
27
+ display: flex;
28
+
29
+ span {
30
+ color: #f0f0f0;
31
+ font-size: 14px;
32
+ &.is-active {
33
+ color: #8a6caa;
34
+ }
35
+ }
36
+
37
+ > * + * {
38
+ margin-left: 9px;
39
+ }
40
+ }
41
+ `;
@@ -0,0 +1,33 @@
1
+ import { RetailersList } from ".";
2
+
3
+ export default {
4
+ title: "Components/atoms/RetailersList",
5
+ component: RetailersList,
6
+ };
7
+
8
+ const Template = (args) => <RetailersList {...args} />;
9
+ export const RetailersListDefault = Template.bind({});
10
+ RetailersListDefault.args = {
11
+ retailers: [
12
+ {
13
+ id: 58,
14
+ name: "The Home Depot Golden",
15
+ },
16
+ {
17
+ id: 59,
18
+ name: "The Home Depot Platinum",
19
+ },
20
+ {
21
+ id: 60,
22
+ name: "The Home Depot Resizing",
23
+ },
24
+ {
25
+ id: 61,
26
+ name: "Home Depot TAB",
27
+ },
28
+ {
29
+ id: 68,
30
+ name: "The Home Depot Dropship",
31
+ },
32
+ ],
33
+ };
@@ -0,0 +1,20 @@
1
+ import { Container } from "./styles";
2
+ import { RetailerOption } from "../RetailerOption";
3
+ import { useState, useEffect } from "react";
4
+ import axios from "axios";
5
+
6
+ export const RetailersList = ({ retailers, article, id }) => {
7
+ const [services, setServices] = useState({});
8
+
9
+ useEffect(() => {
10
+ if (article) setServices(article.statusByRetailer);
11
+ }, [article]);
12
+
13
+ return (
14
+ <Container id={id}>
15
+ {retailers.map((retailer, i) => (
16
+ <RetailerOption key={i} retailer={retailer} services={services} />
17
+ ))}
18
+ </Container>
19
+ );
20
+ };
@@ -0,0 +1,19 @@
1
+ import styled from "styled-components";
2
+
3
+ export const Container = styled.div`
4
+ width: 370px;
5
+ max-height: 200px;
6
+ overflow: auto;
7
+ position: absolute;
8
+ z-index: 500;
9
+ right: 0%;
10
+ top: 100%;
11
+ border: 1px solid #f0f0f0;
12
+ padding: 10px;
13
+ padding-right: 5px;
14
+ background-color: white;
15
+
16
+ > * + * {
17
+ margin-top: 5px;
18
+ }
19
+ `;
@@ -46,7 +46,7 @@ export const Slider = styled.div`
46
46
  }
47
47
  &.bottom-slide {
48
48
  top: 100%;
49
- right: calc(100% + -70px);
49
+ right: calc(100% + -100px);
50
50
  }
51
51
  ul,
52
52
  li {
@@ -0,0 +1,67 @@
1
+ import { UserCatalog } from ".";
2
+
3
+ export default {
4
+ title: "Components/atoms/UserCatalog",
5
+ component: UserCatalog,
6
+ };
7
+
8
+ const Template = (args) => <UserCatalog {...args} />;
9
+ export const UserCatalogDefault = Template.bind({});
10
+ UserCatalogDefault.args = {
11
+ product: "product",
12
+ datasheet: 54,
13
+ description: 54,
14
+ images: 55,
15
+ auditor: 37,
16
+ auditors: [
17
+ {
18
+ name: "José",
19
+ last_name: "Castañeda",
20
+ id_user: 37,
21
+ },
22
+ {
23
+ name: "Eduardo ",
24
+ last_name: " Reyes",
25
+ id_user: 195,
26
+ },
27
+ ],
28
+ textSpecialists: [
29
+ {
30
+ name: "Especialista",
31
+ last_name: "Textos",
32
+ id_user: 36,
33
+ },
34
+ {
35
+ name: "ESPECIALISTA TXTS PRUEBA",
36
+ last_name: "",
37
+ id_user: 54,
38
+ },
39
+ {
40
+ name: "Gerson",
41
+ last_name: "Martínez",
42
+ id_user: 57,
43
+ },
44
+ {
45
+ name: "Angel",
46
+ last_name: "Perea",
47
+ id_user: 232,
48
+ },
49
+ ],
50
+ imagesSpecialists: [
51
+ {
52
+ name: "Especialista",
53
+ last_name: "Imágenes",
54
+ id_user: 35,
55
+ },
56
+ {
57
+ name: "ESPECIALISTA ED PRUEBA",
58
+ last_name: "",
59
+ id_user: 55,
60
+ },
61
+ {
62
+ name: "Uriel",
63
+ last_name: "Herrera",
64
+ id_user: 196,
65
+ },
66
+ ],
67
+ };
@@ -0,0 +1,100 @@
1
+ import { Container } from "./styles";
2
+ import { Avatar } from "../Avatar";
3
+ import { getProfilePicture } from "../../../global-files/data";
4
+ import { UserOption } from "../UserOption";
5
+ import { useCloseModal } from "../../../global-files/customHooks";
6
+ export const UserCatalog = ({
7
+ datasheet,
8
+ description,
9
+ images,
10
+ auditor,
11
+ auditors = [],
12
+ textSpecialists = [],
13
+ imagesSpecialists = [],
14
+ id = "list-modal",
15
+ onAssign,
16
+ product,
17
+ }) => {
18
+ const [showList, setShowList] = useCloseModal(id);
19
+
20
+ return (
21
+ <Container
22
+ id={id}
23
+ onClick={(e) => {
24
+ if (!e.target.closest(`#${id} .users-assigned-list`))
25
+ setShowList(!showList);
26
+ }}
27
+ >
28
+ {datasheet && (
29
+ <Avatar
30
+ image={getProfilePicture(datasheet, 26, 26)}
31
+ altText={"datasheet specialist"}
32
+ imageType={"medium-image"}
33
+ />
34
+ )}
35
+ {description && (
36
+ <Avatar
37
+ image={getProfilePicture(description, 26, 26)}
38
+ altText={"description specialist"}
39
+ imageType={"medium-image"}
40
+ />
41
+ )}
42
+ {images && (
43
+ <Avatar
44
+ image={getProfilePicture(images, 26, 26)}
45
+ altText={"images specialist"}
46
+ imageType={"medium-image"}
47
+ />
48
+ )}
49
+ {auditor && (
50
+ <Avatar
51
+ image={getProfilePicture(auditor, 26, 26)}
52
+ altText={"auditor"}
53
+ imageType={"medium-image"}
54
+ />
55
+ )}
56
+ {showList && (
57
+ <div className="users-assigned-list">
58
+ {product.datasheet_status !== "NS" && (
59
+ <UserOption
60
+ onAssign={onAssign}
61
+ product={product}
62
+ userId={datasheet}
63
+ usersArray={textSpecialists}
64
+ id={id + "-datasheet"}
65
+ index={"datasheet"}
66
+ />
67
+ )}
68
+ {product.description_status !== "NS" && (
69
+ <UserOption
70
+ onAssign={onAssign}
71
+ product={product}
72
+ userId={description}
73
+ usersArray={textSpecialists}
74
+ id={id + "-description"}
75
+ index={"description"}
76
+ />
77
+ )}
78
+ {product.images_status !== "NS" && (
79
+ <UserOption
80
+ onAssign={onAssign}
81
+ product={product}
82
+ userId={images}
83
+ usersArray={imagesSpecialists}
84
+ id={id + "-images"}
85
+ index={"image"}
86
+ />
87
+ )}
88
+ <UserOption
89
+ onAssign={onAssign}
90
+ product={product}
91
+ userId={auditor}
92
+ usersArray={auditors}
93
+ id={id + "-auditor"}
94
+ index={"auditor"}
95
+ />
96
+ </div>
97
+ )}
98
+ </Container>
99
+ );
100
+ };
@@ -0,0 +1,24 @@
1
+ import styled from "styled-components";
2
+
3
+ export const Container = styled.div`
4
+ display: flex;
5
+ justify-content: center;
6
+ width: 100%;
7
+ height: 100%;
8
+ cursor: pointer;
9
+ position: relative;
10
+
11
+ .users-assigned-list {
12
+ background-color: white;
13
+ padding: 10px;
14
+ box-shadow: 0px 2px 4px #00000040;
15
+ position: absolute;
16
+ top: 100%;
17
+ left: 0;
18
+ z-index: 400;
19
+ }
20
+
21
+ > * + * {
22
+ margin-left: -10px;
23
+ }
24
+ `;
@@ -0,0 +1,25 @@
1
+ import { UserOption } from ".";
2
+
3
+ export default {
4
+ title: "Components/atoms/UserOption",
5
+ component: UserOption,
6
+ };
7
+
8
+ const Template = (args) => <UserOption {...args} />;
9
+ export const UserOptionDefault = Template.bind({});
10
+ UserOptionDefault.args = {
11
+ userId: 37,
12
+ index: "datasheet",
13
+ usersArray: [
14
+ {
15
+ name: "José",
16
+ last_name: "Castañeda",
17
+ id_user: 37,
18
+ },
19
+ {
20
+ name: "Eduardo ",
21
+ last_name: " Reyes",
22
+ id_user: 195,
23
+ },
24
+ ],
25
+ };
@@ -0,0 +1,95 @@
1
+ import { Container } from "./styles";
2
+ import { Avatar } from "../Avatar";
3
+ import { useState } from "react";
4
+ import { useEffect } from "react";
5
+ import { getProfilePicture } from "../../../global-files/data";
6
+ import { servicesCodeIcon } from "../../organisms/OrderDetail/utils/Table/utils";
7
+ import { UserSelector } from "../UserSelector";
8
+ import { useCloseModal } from "../../../global-files/customHooks";
9
+
10
+ export const UserOption = ({
11
+ userId,
12
+ index,
13
+ usersArray,
14
+ id,
15
+ onAssign,
16
+ product,
17
+ }) => {
18
+ index === "auditor" && console.log(userId);
19
+ const [userAssigned, setUserAssigned] = useState({});
20
+ const [showSelector, setShowSelector] = useCloseModal(id);
21
+ const [assignationTarget, setAssignationTarget] = useState("");
22
+ const [concept, setConcept] = useState("");
23
+ const [target, setTarget] = useState("");
24
+
25
+ const icons = servicesCodeIcon;
26
+
27
+ useEffect(() => {
28
+ if (usersArray) {
29
+ usersArray.forEach((user) => {
30
+ if (user.id_user === userId) {
31
+ setUserAssigned(user);
32
+ }
33
+ });
34
+ }
35
+ }, [userId, usersArray]);
36
+
37
+ useEffect(() => {
38
+ switch (index) {
39
+ case "datasheet":
40
+ case "description":
41
+ setAssignationTarget(`id_${index}_especialist`);
42
+ setConcept(index);
43
+ setTarget("especialist");
44
+ break;
45
+ case "image":
46
+ setAssignationTarget(`id_${index}s_especialist`);
47
+ setConcept(index + "s");
48
+ setTarget("especialist");
49
+ break;
50
+ case "auditor":
51
+ setAssignationTarget(`id_${index}`);
52
+ setConcept(index);
53
+ setTarget(index);
54
+ break;
55
+ default:
56
+ break;
57
+ }
58
+ }, [index]);
59
+
60
+ return (
61
+ <Container
62
+ onClick={(e) => {
63
+ setShowSelector(!showSelector);
64
+ e.stopPropagation();
65
+ }}
66
+ id={id}
67
+ >
68
+ <div className="image-and-name">
69
+ <Avatar
70
+ image={getProfilePicture(userAssigned?.id_user, 26, 26)}
71
+ altText={"datasheet especialist"}
72
+ imageType={"medium-image"}
73
+ />
74
+ <p>
75
+ {userAssigned?.name} {userAssigned?.last_name}
76
+ </p>
77
+ </div>
78
+ <div className="icon-container">{icons[index]}</div>
79
+ {showSelector && (
80
+ <UserSelector
81
+ id={id}
82
+ searchLabel="Buscar Usuario"
83
+ index={index}
84
+ usersArray={usersArray}
85
+ position="absolute"
86
+ onAssign={onAssign}
87
+ product={product}
88
+ assignationTarget={assignationTarget}
89
+ target={target}
90
+ concept={concept}
91
+ />
92
+ )}
93
+ </Container>
94
+ );
95
+ };
@@ -0,0 +1,61 @@
1
+ import styled from "styled-components";
2
+ import { FontFamily } from "../../../global-files/variables";
3
+
4
+ export const Container = styled.div`
5
+ border: 1px solid #f0f0f0;
6
+ border-radius: 5px;
7
+ color: #262626;
8
+ font-size: 12px;
9
+ font-family: ${FontFamily.Lato};
10
+ display: flex;
11
+ align-items: center;
12
+ padding: 5px 10px;
13
+ justify-content: space-between;
14
+ cursor: pointer;
15
+ position: relative;
16
+ background-color: white;
17
+
18
+ .image-and-name {
19
+ display: flex;
20
+ align-items: center;
21
+
22
+ div + p {
23
+ margin-left: 10px;
24
+ white-space: nowrap;
25
+ }
26
+
27
+ & + * {
28
+ margin-left: 10px;
29
+ }
30
+ }
31
+
32
+ .icon-container {
33
+ position: relative;
34
+ span {
35
+ color: #808080;
36
+ cursor: pointer;
37
+
38
+ & + span {
39
+ display: none;
40
+ position: absolute;
41
+ right: 120%;
42
+ top: 50%;
43
+ transform: translateY(-50%);
44
+ white-space: nowrap;
45
+ border: 1px solid #f0f0f0;
46
+ padding: 5px;
47
+ background-color: white;
48
+ }
49
+
50
+ &:hover {
51
+ & + span {
52
+ display: block;
53
+ }
54
+ }
55
+ }
56
+ }
57
+
58
+ & + * {
59
+ margin-top: 5px;
60
+ }
61
+ `;
@@ -0,0 +1,25 @@
1
+ import { UserSelector } from ".";
2
+
3
+ export default {
4
+ title: "Components/atoms/UserSelector",
5
+ component: UserSelector,
6
+ };
7
+
8
+ const Template = (args) => <UserSelector {...args} />;
9
+ export const UserSelectorDefault = Template.bind({});
10
+ UserSelectorDefault.args = {
11
+ searchLabel: "Buscar auditor",
12
+ index: "auditor",
13
+ usersArray: [
14
+ {
15
+ name: "José",
16
+ last_name: "Castañeda",
17
+ id_user: 37,
18
+ },
19
+ {
20
+ name: "Eduardo ",
21
+ last_name: " Reyes",
22
+ id_user: 195,
23
+ },
24
+ ],
25
+ };