slice-machine-ui 2.16.2-alpha.jp-fix-cr-modal-rules-of-hooks.1 → 2.16.2-alpha.xru-remove-review-form.1

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 (38) hide show
  1. package/out/404.html +1 -1
  2. package/out/_next/static/QRyyOxfzW3aBB_FoMnWN9/_buildManifest.js +1 -0
  3. package/out/_next/static/chunks/397-e6c340070a3bcb41.js +1 -0
  4. package/out/_next/static/chunks/pages/{_app-9cae9ef879a366c6.js → _app-abd459ca7e254c7b.js} +46 -46
  5. package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-61a3846ae1654f54.js → [customTypeId]-389d1b7a492fb3e7.js} +1 -1
  6. package/out/_next/static/chunks/pages/{custom-types-093f2e2213561492.js → custom-types-2a5fd94ee42ba593.js} +1 -1
  7. package/out/_next/static/chunks/pages/{index-0e27ae9805b59004.js → index-02dd147957c8b40f.js} +1 -1
  8. package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-91a4eb622fa3cb7c.js → [pageTypeId]-3589bd1f9138a97b.js} +1 -1
  9. package/out/_next/static/chunks/pages/{settings-0da3553b3a0acc99.js → settings-170379902605f38a.js} +1 -1
  10. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/{[variation]-c71823bf02dc292d.js → [variation]-6de02b8ed13b680d.js} +1 -1
  11. package/out/_next/static/chunks/pages/{slices-7e816c2b32cc6f19.js → slices-071bb494907adf0f.js} +1 -1
  12. package/out/_next/static/css/{f0e6d8449ce2bb46.css → 9c9a7de81f9ac811.css} +1 -1
  13. package/out/changelog.html +1 -1
  14. package/out/changes.html +1 -1
  15. package/out/custom-types/[customTypeId].html +1 -1
  16. package/out/custom-types.html +1 -1
  17. package/out/index.html +1 -1
  18. package/out/labs.html +1 -1
  19. package/out/page-types/[pageTypeId].html +1 -1
  20. package/out/settings.html +1 -1
  21. package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
  22. package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
  23. package/out/slices.html +1 -1
  24. package/package.json +3 -3
  25. package/src/legacy/components/App/index.tsx +0 -2
  26. package/src/modules/loading/types.ts +0 -1
  27. package/src/modules/useSliceMachineActions.ts +0 -23
  28. package/src/modules/userContext/index.ts +1 -33
  29. package/src/modules/userContext/types.ts +0 -13
  30. package/src/styles/modal.css +0 -22
  31. package/test/lib/builders/EditModal.test.tsx +102 -5
  32. package/test/src/modules/userContext.test.ts +1 -50
  33. package/out/_next/static/b5TDcD5T7XZWO6tB8rLgd/_buildManifest.js +0 -1
  34. package/src/legacy/components/ReviewModal/ReviewForm.tsx +0 -169
  35. package/src/legacy/components/ReviewModal/ReviewFormSelect.tsx +0 -35
  36. package/src/legacy/components/ReviewModal/ReviewModal.tsx +0 -56
  37. package/src/legacy/components/ReviewModal/index.ts +0 -1
  38. /package/out/_next/static/{b5TDcD5T7XZWO6tB8rLgd → QRyyOxfzW3aBB_FoMnWN9}/_ssgManifest.js +0 -0
@@ -1,11 +1,6 @@
1
1
  import { describe, expect, it } from "vitest";
2
2
 
3
- import {
4
- sendAReviewCreator,
5
- skipReviewCreator,
6
- userContextReducer,
7
- } from "@/modules/userContext";
8
- import { UserContextStoreType } from "@/modules/userContext/types";
3
+ import { userContextReducer } from "@/modules/userContext";
9
4
 
10
5
  describe("[UserContext module]", () => {
11
6
  describe("[Reducer]", () => {
@@ -18,49 +13,5 @@ describe("[UserContext module]", () => {
18
13
  // @ts-expect-error TS(2345) FIXME: Argument of type '{}' is not assignable to paramet... Remove this comment to see the full error message
19
14
  expect(userContextReducer({}, { type: "NO.MATCH" })).toEqual({});
20
15
  });
21
-
22
- it("should update user review onboarding to true when given USER_CONTEXT/SEND_REVIEW action", () => {
23
- // @ts-expect-error TS(2739) FIXME: Type '{ hasSendAReview: false;... Remove this comment to see the full error message
24
- const initialState: UserContextStoreType = {
25
- userReview: {
26
- onboarding: false,
27
- },
28
- };
29
-
30
- const action = sendAReviewCreator({
31
- reviewType: "onboarding",
32
- });
33
-
34
- const expectedState: UserContextStoreType = {
35
- ...initialState,
36
- userReview: {
37
- onboarding: true,
38
- },
39
- };
40
-
41
- expect(userContextReducer(initialState, action)).toEqual(expectedState);
42
- });
43
-
44
- it("should update user review onboarding to true when given USER_CONTEXT/SKIP_REVIEW action", () => {
45
- // @ts-expect-error TS(2739) FIXME: Type '{ hasSendAReview: false;... Remove this comment to see the full error message
46
- const initialState: UserContextStoreType = {
47
- userReview: {
48
- onboarding: false,
49
- },
50
- };
51
-
52
- const action = skipReviewCreator({
53
- reviewType: "onboarding",
54
- });
55
-
56
- const expectedState: UserContextStoreType = {
57
- ...initialState,
58
- userReview: {
59
- onboarding: true,
60
- },
61
- };
62
-
63
- expect(userContextReducer(initialState, action)).toEqual(expectedState);
64
- });
65
16
  });
66
17
  });
@@ -1 +0,0 @@
1
- self.__BUILD_MANIFEST=function(s,c,a,e,t,i,d,n,b,u,f,h,l,k,p,j,g,o,r){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/":[a,p,j,"static/chunks/pages/index-0e27ae9805b59004.js"],"/_error":["static/chunks/pages/_error-fedd2c6ebd3d27b9.js"],"/changelog":[s,e,"static/chunks/870-a72b74312773efea.js","static/chunks/pages/changelog-80a618708f44f25f.js"],"/changes":[s,t,"static/chunks/8eec4907-b712959d9f984b68.js","static/chunks/918-fa4f2563cb5fd014.js",c,d,"static/css/d98ebc475f8423a3.css","static/chunks/pages/changes-d40c17939854b984.js"],"/custom-types":[a,p,j,"static/chunks/pages/custom-types-093f2e2213561492.js"],"/custom-types/[customTypeId]":[s,n,b,u,f,e,i,h,g,c,a,l,k,o,r,"static/chunks/pages/custom-types/[customTypeId]-61a3846ae1654f54.js"],"/labs":["static/chunks/pages/labs-c6df252ea5d8fb6f.js"],"/page-types/[pageTypeId]":[s,n,b,u,f,e,i,h,g,c,a,l,k,o,r,"static/chunks/pages/page-types/[pageTypeId]-91a4eb622fa3cb7c.js"],"/settings":["static/css/e5f781f20e24a5ea.css","static/chunks/pages/settings-0da3553b3a0acc99.js"],"/slices":[s,t,i,c,d,k,"static/css/efa5152b7c0f35c0.css","static/chunks/pages/slices-7e816c2b32cc6f19.js"],"/slices/[lib]/[sliceName]/[variation]":[s,t,n,b,u,f,e,i,h,c,l,d,"static/css/cdee5b195444f185.css","static/chunks/pages/slices/[lib]/[sliceName]/[variation]-c71823bf02dc292d.js"],"/slices/[lib]/[sliceName]/[variation]/simulator":[t,"static/chunks/72585f70-28b4d7d5384b3703.js","static/chunks/157-fca2f00f6df07660.js","static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-063fa88ba75f483e.js"],sortedPages:["/","/_app","/_error","/changelog","/changes","/custom-types","/custom-types/[customTypeId]","/labs","/page-types/[pageTypeId]","/settings","/slices","/slices/[lib]/[sliceName]/[variation]","/slices/[lib]/[sliceName]/[variation]/simulator"]}}("static/chunks/59b4e022-ef680789f7cc9b11.js","static/chunks/34-2911c905c8a6e9d9.js","static/chunks/867-8164160c810122c6.js","static/chunks/183-85de38d65a85dc2c.js","static/chunks/c8eae200-966ce352f7b5d2b9.js","static/chunks/44-a2056f993381ad0f.js","static/chunks/658-8231c0b729e0124a.js","static/chunks/f36c6662-1f3a854183168b10.js","static/chunks/4c744e84-480e426e4b1cfef3.js","static/chunks/065a3ddb-9a38ca0d60f0bf2f.js","static/chunks/1cc2734a-09fb3b997ad1eb70.js","static/chunks/349-7118116b93278f73.js","static/chunks/630-93339694ef30b82d.js","static/chunks/268-6d5fc7642a1b87c8.js","static/chunks/895-8c214ba470a4e23c.js","static/css/4e475d945cf8a890.css","static/chunks/385-b949173dfa03dd3e.js","static/chunks/882-28837678beff7e51.js","static/css/56f2a6684a524374.css"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
@@ -1,169 +0,0 @@
1
- import { Field, Form, Formik } from "formik";
2
- import { FC } from "react";
3
- import Modal from "react-modal";
4
- import { useSelector } from "react-redux";
5
- import {
6
- Box,
7
- Button,
8
- Card,
9
- Close,
10
- Flex,
11
- Heading,
12
- Text,
13
- Textarea,
14
- } from "theme-ui";
15
-
16
- import { telemetry } from "@/apiClient";
17
- import SliceMachineModal from "@/legacy/components/SliceMachineModal";
18
- import { isLoading } from "@/modules/loading";
19
- import { LoadingKeysEnum } from "@/modules/loading/types";
20
- import { isModalOpen } from "@/modules/modal";
21
- import { ModalKeysEnum } from "@/modules/modal/types";
22
- import useSliceMachineActions from "@/modules/useSliceMachineActions";
23
- import { SliceMachineStoreType } from "@/redux/type";
24
-
25
- import { ReviewFormSelect } from "./ReviewFormSelect";
26
-
27
- Modal.setAppElement("#__next");
28
-
29
- const reviewType = "onboarding";
30
-
31
- export const ReviewForm: FC = () => {
32
- const { isReviewLoading, isLoginModalOpen } = useSelector(
33
- (store: SliceMachineStoreType) => ({
34
- isReviewLoading: isLoading(store, LoadingKeysEnum.REVIEW),
35
- isLoginModalOpen: isModalOpen(store, ModalKeysEnum.LOGIN),
36
- }),
37
- );
38
- const { skipReview, sendAReview, startLoadingReview, stopLoadingReview } =
39
- useSliceMachineActions();
40
-
41
- const onSendAReview = (rating: number, comment: string): void => {
42
- startLoadingReview();
43
- void telemetry.track({
44
- event: "review",
45
- rating,
46
- comment,
47
- type: reviewType,
48
- });
49
- sendAReview(reviewType);
50
- stopLoadingReview();
51
- };
52
-
53
- const validateReview = ({ rating }: { rating: number; comment: string }) => {
54
- if (!rating) {
55
- return { id: "Please choose a rating" };
56
- }
57
- };
58
-
59
- return (
60
- <SliceMachineModal
61
- isOpen
62
- shouldCloseOnOverlayClick={false}
63
- onRequestClose={() => skipReview(reviewType)}
64
- closeTimeoutMS={500}
65
- contentLabel={"Review Modal"}
66
- portalClassName={"ReviewModal"}
67
- style={{
68
- content: {
69
- display: "flex",
70
- position: "initial",
71
- padding: "none",
72
- top: "initial",
73
- left: "initial",
74
- minHeight: "initial",
75
- },
76
- overlay: {
77
- top: "initial",
78
- left: "initial",
79
- right: 16,
80
- bottom: 16,
81
- position: "absolute",
82
- height: "fit-content",
83
- width: "fit-content",
84
- backgroundColor: "unset",
85
- },
86
- }}
87
- >
88
- <Formik
89
- validateOnMount
90
- initialValues={{
91
- rating: 0,
92
- comment: "",
93
- }}
94
- validate={validateReview}
95
- onSubmit={(values) => {
96
- onSendAReview(values.rating, values.comment);
97
- }}
98
- >
99
- {({ isValid }) => (
100
- <Form id="review-form">
101
- <Card>
102
- <Flex
103
- sx={{
104
- p: "16px",
105
- pl: 4,
106
- bg: "headSection",
107
- alignItems: "center",
108
- justifyContent: "space-between",
109
- borderRadius: "8px 8px 0px 0px",
110
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
111
- borderBottom: (t) => `1px solid ${t.colors?.borders}`,
112
- }}
113
- >
114
- <Heading sx={{ fontSize: "20px", mr: 4 }}>
115
- Share feedback
116
- </Heading>
117
- <Close type="button" onClick={() => skipReview(reviewType)} />
118
- </Flex>
119
- <Flex
120
- sx={{
121
- flexDirection: "column",
122
- padding: "16px 24px 32px",
123
- bg: "headSection",
124
- }}
125
- >
126
- <Text variant={"xs"} as={"p"} sx={{ maxWidth: 302, mb: 3 }}>
127
- Overall, how satisfied or dissatisfied are you with your Slice
128
- Machine experience so far?
129
- </Text>
130
- <Box
131
- mb={2}
132
- sx={{
133
- display: "flex",
134
- flex: 1,
135
- justifyContent: "space-between",
136
- }}
137
- >
138
- <Text variant={"xs"} as={"p"}>
139
- Very unsatisfied
140
- </Text>
141
- <Text variant={"xs"} as={"p"}>
142
- Very satisfied
143
- </Text>
144
- </Box>
145
- <Field name={"rating"} component={ReviewFormSelect} />
146
- <Field
147
- name={"comment"}
148
- type="text"
149
- placeholder="Tell us more..."
150
- as={Textarea}
151
- autoComplete="off"
152
- sx={{ height: 80, mb: 3 }}
153
- data-testid="review-form-comment"
154
- />
155
- <Button
156
- form={"review-form"}
157
- type="submit"
158
- disabled={!isValid || isReviewLoading || isLoginModalOpen}
159
- >
160
- Submit
161
- </Button>
162
- </Flex>
163
- </Card>
164
- </Form>
165
- )}
166
- </Formik>
167
- </SliceMachineModal>
168
- );
169
- };
@@ -1,35 +0,0 @@
1
- import { FieldProps } from "formik";
2
- import { FC } from "react";
3
- import { Box, Button } from "theme-ui";
4
-
5
- const ratingSelectable = [1, 2, 3, 4, 5];
6
-
7
- export const ReviewFormSelect: FC<FieldProps> = (props) => {
8
- const { field, form } = props;
9
-
10
- return (
11
- <Box sx={{ mb: 3, display: "flex", justifyContent: "space-between" }}>
12
- {ratingSelectable.map((rating, index) => (
13
- <Button
14
- variant="secondary"
15
- type="button"
16
- key={index}
17
- onClick={() => void form.setFieldValue("rating", rating)}
18
- className={field.value === rating ? "selected" : ""}
19
- sx={{
20
- "&:not(:last-of-type)": {
21
- mr: 1,
22
- },
23
- "&.selected": {
24
- backgroundColor: "code.gray",
25
- color: "white",
26
- },
27
- }}
28
- data-testid={`review-form-score-${rating}`}
29
- >
30
- {rating}
31
- </Button>
32
- ))}
33
- </Box>
34
- );
35
- };
@@ -1,56 +0,0 @@
1
- import { FC } from "react";
2
- import { useSelector } from "react-redux";
3
-
4
- import { hasLocal } from "@/legacy/lib/models/common/ModelData";
5
- import { selectAllCustomTypes } from "@/modules/availableCustomTypes";
6
- import { getLibraries } from "@/modules/slices";
7
- import { getLastSyncChange, getUserReview } from "@/modules/userContext";
8
- import { SliceMachineStoreType } from "@/redux/type";
9
-
10
- import { ReviewForm } from "./ReviewForm";
11
-
12
- export const ReviewModal: FC = () => {
13
- const { userReview, customTypes, libraries, lastSyncChange } = useSelector(
14
- (store: SliceMachineStoreType) => ({
15
- userReview: getUserReview(store),
16
- customTypes: selectAllCustomTypes(store),
17
- libraries: getLibraries(store),
18
- lastSyncChange: getLastSyncChange(store),
19
- }),
20
- );
21
-
22
- const sliceCount =
23
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
24
- libraries && libraries.length
25
- ? libraries.reduce((count, lib) => {
26
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
27
- if (!lib) return count;
28
- return count + lib.components.length;
29
- }, 0)
30
- : 0;
31
-
32
- const hasSliceWithinCustomType = customTypes.some(
33
- (customType) =>
34
- hasLocal(customType) &&
35
- customType.local.tabs.some(
36
- (tab) => tab.sliceZone && tab.sliceZone?.value.length > 0,
37
- ),
38
- );
39
-
40
- const hasPushedAnHourAgo = Boolean(
41
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
42
- lastSyncChange && Date.now() - lastSyncChange >= 3600000,
43
- );
44
-
45
- const isOnboardingDone =
46
- sliceCount >= 1 &&
47
- customTypes.length >= 1 &&
48
- hasSliceWithinCustomType &&
49
- hasPushedAnHourAgo;
50
-
51
- if (!userReview.onboarding && isOnboardingDone) {
52
- return <ReviewForm />;
53
- }
54
-
55
- return null;
56
- };
@@ -1 +0,0 @@
1
- export { ReviewModal } from "./ReviewModal";