bukazu-portal-react 2.1.21 → 3.0.3

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 (191) hide show
  1. package/.github/workflows/dependabot.yml +11 -0
  2. package/.github/workflows/node.js.yml +31 -0
  3. package/.prettierrc +3 -6
  4. package/CHANGELOG.MD +5 -0
  5. package/babel.config.json +1 -1
  6. package/build/index.css +1 -2312
  7. package/build/portal.es.js +35483 -0
  8. package/build/portal.umd.js +596 -0
  9. package/{build/calendar.html → calendar.html} +2 -4
  10. package/coverage/clover.xml +28 -0
  11. package/coverage/coverage-final.json +2 -0
  12. package/coverage/lcov-report/base.css +224 -0
  13. package/coverage/lcov-report/block-navigation.js +87 -0
  14. package/coverage/lcov-report/favicon.png +0 -0
  15. package/coverage/lcov-report/helper.ts.html +142 -0
  16. package/coverage/lcov-report/index.html +116 -0
  17. package/coverage/lcov-report/prettify.css +1 -0
  18. package/coverage/lcov-report/prettify.js +2 -0
  19. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  20. package/coverage/lcov-report/sorter.js +196 -0
  21. package/coverage/lcov.info +36 -0
  22. package/cypress/{integration → e2e}/.examples/actions.spec.js +0 -0
  23. package/cypress/{integration → e2e}/.examples/aliasing.spec.js +0 -0
  24. package/cypress/{integration → e2e}/.examples/assertions.spec.js +0 -0
  25. package/cypress/{integration → e2e}/.examples/connectors.spec.js +0 -0
  26. package/cypress/{integration → e2e}/.examples/cookies.spec.js +0 -0
  27. package/cypress/{integration → e2e}/.examples/cypress_api.spec.js +0 -0
  28. package/cypress/{integration → e2e}/.examples/files.spec.js +0 -0
  29. package/cypress/{integration → e2e}/.examples/local_storage.spec.js +0 -0
  30. package/cypress/{integration → e2e}/.examples/location.spec.js +0 -0
  31. package/cypress/{integration → e2e}/.examples/misc.spec.js +0 -0
  32. package/cypress/{integration → e2e}/.examples/navigation.spec.js +0 -0
  33. package/cypress/{integration → e2e}/.examples/network_requests.spec.js +0 -0
  34. package/cypress/{integration → e2e}/.examples/querying.spec.js +0 -0
  35. package/cypress/{integration → e2e}/.examples/spies_stubs_clocks.spec.js +0 -0
  36. package/cypress/{integration → e2e}/.examples/traversal.spec.js +0 -0
  37. package/cypress/{integration → e2e}/.examples/utilities.spec.js +0 -0
  38. package/cypress/{integration → e2e}/.examples/viewport.spec.js +0 -0
  39. package/cypress/{integration → e2e}/.examples/waiting.spec.js +0 -0
  40. package/cypress/{integration → e2e}/.examples/window.spec.js +0 -0
  41. package/cypress/{integration → e2e}/booking.spec.js +0 -0
  42. package/cypress/{integration → e2e}/calendar.spec.js +0 -0
  43. package/cypress/{integration → e2e}/search.spec.js +0 -0
  44. package/cypress/support/commands.ts +37 -0
  45. package/cypress/support/component-index.html +12 -0
  46. package/cypress/support/component.ts +39 -0
  47. package/cypress/support/{index.js → e2e.js} +0 -0
  48. package/cypress.config.ts +15 -0
  49. package/{dev.js → dev.tsx} +1 -1
  50. package/index.html +15 -0
  51. package/{build/invalid-calendar.html → invalid-calendar.html} +0 -0
  52. package/jest.config.js +195 -0
  53. package/package.json +35 -40
  54. package/reviews.html +16 -0
  55. package/src/_lib/{SearchQueries.js → SearchQueries.ts} +8 -2
  56. package/src/_lib/{countries.js → countries.ts} +0 -0
  57. package/src/_lib/date_helper.ts +27 -0
  58. package/src/_lib/{queries.js → queries.ts} +24 -5
  59. package/src/components/App.tsx +132 -0
  60. package/src/components/AppContext.ts +14 -0
  61. package/src/components/CalendarPage/BookingForm.tsx +42 -0
  62. package/src/components/CalendarPage/Calendar.tsx +50 -0
  63. package/src/components/CalendarPage/CalendarPage.tsx +43 -0
  64. package/src/components/CalendarPage/CalendarParts/CalendarContext.tsx +89 -0
  65. package/src/components/CalendarPage/CalendarParts/CalendarHeader.tsx +72 -0
  66. package/src/components/CalendarPage/CalendarParts/DayClasses.ts +111 -0
  67. package/src/components/CalendarPage/CalendarParts/GenerateCalendar.tsx +64 -0
  68. package/src/components/CalendarPage/CalendarParts/Legend.tsx +33 -0
  69. package/src/components/CalendarPage/CalendarParts/MonthHeader.tsx +15 -0
  70. package/src/components/CalendarPage/CalendarParts/Months.tsx +37 -0
  71. package/src/components/CalendarPage/CalendarParts/RenderCells.tsx +94 -0
  72. package/src/components/CalendarPage/CalendarParts/SingleMonth.tsx +72 -0
  73. package/src/components/CalendarPage/CalendarParts/StartBooking.tsx +17 -0
  74. package/src/components/CalendarPage/CalendarParts/WeekDays.tsx +27 -0
  75. package/src/components/CalendarPage/FormCreator.tsx +213 -0
  76. package/src/components/CalendarPage/FormItems/{Date.js → Date.tsx} +10 -2
  77. package/src/components/CalendarPage/FormItems/{NumberSelect.js → NumberSelect.tsx} +1 -1
  78. package/src/components/CalendarPage/FormItems/{Select.js → Select.tsx} +0 -0
  79. package/src/components/CalendarPage/FormItems/{index.js → index.ts} +0 -0
  80. package/src/components/CalendarPage/PriceField/Price.tsx +58 -0
  81. package/src/components/CalendarPage/PriceField/Queries.ts +23 -0
  82. package/src/components/CalendarPage/PriceField/index.tsx +127 -0
  83. package/src/components/CalendarPage/Summary/{CostRow.js → CostRow.tsx} +19 -3
  84. package/src/components/CalendarPage/Summary/{CostSection.js → CostSection.tsx} +5 -1
  85. package/src/components/CalendarPage/Summary/{CostSummary.js → CostSummary.tsx} +19 -10
  86. package/src/components/CalendarPage/Summary/Description.tsx +27 -0
  87. package/src/components/CalendarPage/Summary/{InsurancesAndRequired.js → InsurancesAndRequired.tsx} +21 -2
  88. package/src/components/CalendarPage/Summary/Object.tsx +59 -0
  89. package/src/components/CalendarPage/Summary/{OnSite.js → OnSite.tsx} +9 -9
  90. package/src/components/CalendarPage/Summary/{OptionalNotOnSite.js → OptionalNotOnSite.tsx} +19 -18
  91. package/src/components/CalendarPage/Summary/{OptionalOnSite.js → OptionalOnSite.tsx} +6 -1
  92. package/src/components/CalendarPage/Summary/{Queries.js → Queries.ts} +3 -3
  93. package/src/components/CalendarPage/Summary/RentAndDiscount.tsx +30 -0
  94. package/src/components/CalendarPage/Summary/{Totals.js → Totals.tsx} +8 -3
  95. package/src/components/CalendarPage/Summary/cost_types.d.ts +31 -0
  96. package/src/components/CalendarPage/Summary/index.tsx +24 -0
  97. package/src/components/CalendarPage/calender_types.d.ts +16 -0
  98. package/src/components/CalendarPage/formParts/AssistanceMessage.tsx +60 -0
  99. package/src/components/CalendarPage/formParts/{BookingHelpers.js → BookingHelpers.tsx} +3 -3
  100. package/src/components/CalendarPage/formParts/{BookingOrOption.js → BookingOrOption.tsx} +6 -1
  101. package/src/components/CalendarPage/formParts/CancelInsuranceText.tsx +105 -0
  102. package/src/components/CalendarPage/formParts/{DefaultBookingFields.js → DefaultBookingFields.ts} +3 -1
  103. package/src/components/CalendarPage/formParts/DiscountCode.tsx +62 -0
  104. package/src/components/CalendarPage/formParts/{Guests.js → Guests.tsx} +10 -4
  105. package/src/components/CalendarPage/formParts/{OptionalBookingFields.js → OptionalBookingFields.tsx} +0 -0
  106. package/src/components/CalendarPage/formParts/{OptionalCosts.js → OptionalCosts.tsx} +1 -2
  107. package/src/components/CalendarPage/formParts/{SuccessMessage.js → SuccessMessage.tsx} +0 -0
  108. package/src/components/CalendarPage/formParts/Validations.tsx +78 -0
  109. package/src/components/CalendarPage/formParts/{discount.js → discount.tsx} +11 -2
  110. package/src/components/CalendarPage/formParts/form_types.d.ts +38 -0
  111. package/src/components/CalendarPage/formParts/{insurances.js → insurances.tsx} +14 -10
  112. package/src/components/CalendarPage/formParts/{radioButtons.js → radioButtons.tsx} +0 -0
  113. package/src/components/Error/{ApiError.js → ApiError.tsx} +6 -4
  114. package/src/components/Error/{IntegrationError.js → IntegrationError.tsx} +17 -11
  115. package/src/components/Error/{index.js → index.ts} +0 -0
  116. package/src/components/{ErrorBoundary.js → ErrorBoundary.tsx} +13 -5
  117. package/src/components/Modal/index.tsx +46 -0
  118. package/src/components/ReviewsPage/Queries.ts +26 -0
  119. package/src/components/ReviewsPage/ReviewsPage.tsx +43 -0
  120. package/src/components/ReviewsPage/Score.tsx +25 -0
  121. package/src/components/ReviewsPage/SingleReview.tsx +38 -0
  122. package/src/components/SafeBooking.tsx +97 -0
  123. package/src/components/SearchPage/Field.tsx +75 -0
  124. package/src/components/SearchPage/Filters.tsx +91 -0
  125. package/src/components/SearchPage/Paginator.tsx +63 -0
  126. package/src/components/SearchPage/Results.tsx +129 -0
  127. package/src/components/SearchPage/{SearchPage.js → SearchPage.tsx} +42 -31
  128. package/src/components/SearchPage/{SingleResult.js → SingleResult.tsx} +15 -8
  129. package/src/components/SearchPage/filters/Categories.tsx +57 -0
  130. package/src/components/SearchPage/filters/DateFilter.tsx +34 -0
  131. package/src/components/SearchPage/filters/List.tsx +80 -0
  132. package/src/components/SearchPage/filters/NumberFilter.tsx +37 -0
  133. package/src/components/SearchPage/filters/Radio.tsx +46 -0
  134. package/src/components/SearchPage/filters/Select.tsx +85 -0
  135. package/src/components/SearchPage/filters/__tests__/helper.spec.js +15 -0
  136. package/src/components/SearchPage/filters/filter_types.d.ts +25 -0
  137. package/src/components/SearchPage/filters/helper.ts +19 -0
  138. package/src/components/icons/ArrowLeft.svg.tsx +20 -0
  139. package/src/components/icons/{ArrowRight.svg.js → ArrowRight.svg.tsx} +0 -0
  140. package/src/components/icons/{Reload.svg.js → Reload.svg.tsx} +0 -0
  141. package/src/components/icons/{info.svg.js → info.svg.tsx} +0 -0
  142. package/src/components/icons/{loading.svg.js → loading.svg.tsx} +1 -1
  143. package/src/custom.d.ts +10 -0
  144. package/src/index.tsx +93 -0
  145. package/src/locales/de.json +4 -3
  146. package/src/locales/en.json +4 -3
  147. package/src/locales/es.json +4 -3
  148. package/src/locales/fr.json +4 -3
  149. package/src/locales/it.json +4 -3
  150. package/src/locales/nl.json +4 -3
  151. package/src/styles/main.css +2 -1
  152. package/src/styles/modal.css +1 -1
  153. package/src/styles/pagination.css +25 -23
  154. package/src/styles/result.css +33 -2
  155. package/src/styles/reviews.css +76 -0
  156. package/src/types.d.ts +85 -0
  157. package/tsconfig.json +17 -0
  158. package/vite.config.ts +31 -0
  159. package/build/index.html +0 -16
  160. package/build/index.js +0 -48528
  161. package/cypress.json +0 -9
  162. package/rollup.config.js +0 -30
  163. package/src/_lib/format.js +0 -16
  164. package/src/components/App.js +0 -164
  165. package/src/components/CalendarPage/BookingForm.js +0 -57
  166. package/src/components/CalendarPage/Calendar.js +0 -373
  167. package/src/components/CalendarPage/CalendarHeader.js +0 -58
  168. package/src/components/CalendarPage/CalendarPage.js +0 -158
  169. package/src/components/CalendarPage/FormCreator.js +0 -278
  170. package/src/components/CalendarPage/FormItems/Wrapper.js +0 -0
  171. package/src/components/CalendarPage/PriceField.js +0 -203
  172. package/src/components/CalendarPage/Summary/Description.js +0 -22
  173. package/src/components/CalendarPage/Summary/Object.js +0 -46
  174. package/src/components/CalendarPage/Summary/RentAndDiscount.js +0 -21
  175. package/src/components/CalendarPage/Summary/index.js +0 -19
  176. package/src/components/CalendarPage/formParts/AssistanceMessage.js +0 -47
  177. package/src/components/CalendarPage/formParts/CancelInsuranceText.js +0 -91
  178. package/src/components/CalendarPage/formParts/DiscountCode.js +0 -62
  179. package/src/components/CalendarPage/formParts/summary.js +0 -43
  180. package/src/components/Modal/index.js +0 -58
  181. package/src/components/ReviewsPage/ReviewsPage.js +0 -15
  182. package/src/components/SafeBooking.js +0 -69
  183. package/src/components/SearchPage/Field.js +0 -241
  184. package/src/components/SearchPage/Filters.js +0 -108
  185. package/src/components/SearchPage/Paginator.js +0 -59
  186. package/src/components/SearchPage/Results.js +0 -130
  187. package/src/components/SearchPage/filters/List.js +0 -63
  188. package/src/components/icons/ArrowLeft.svg.js +0 -18
  189. package/src/index.js +0 -74
  190. package/webpack.config.dev.js +0 -53
  191. package/webpack.config.js +0 -67
package/jest.config.js ADDED
@@ -0,0 +1,195 @@
1
+ /*
2
+ * For a detailed explanation regarding each configuration property, visit:
3
+ * https://jestjs.io/docs/configuration
4
+ */
5
+
6
+ module.exports = {
7
+ // All imported modules in your tests should be mocked automatically
8
+ // automock: false,
9
+
10
+ // Stop running tests after `n` failures
11
+ // bail: 0,
12
+
13
+ // The directory where Jest should store its cached dependency information
14
+ // cacheDirectory: "/tmp/jest_rs",
15
+
16
+ // Automatically clear mock calls, instances, contexts and results before every test
17
+ clearMocks: true,
18
+
19
+ // Indicates whether the coverage information should be collected while executing the test
20
+ collectCoverage: true,
21
+
22
+ // An array of glob patterns indicating a set of files for which coverage information should be collected
23
+ // collectCoverageFrom: undefined,
24
+
25
+ // The directory where Jest should output its coverage files
26
+ coverageDirectory: "coverage",
27
+
28
+ // An array of regexp pattern strings used to skip coverage collection
29
+ // coveragePathIgnorePatterns: [
30
+ // "/node_modules/"
31
+ // ],
32
+
33
+ // Indicates which provider should be used to instrument code for coverage
34
+ coverageProvider: "v8",
35
+
36
+ // A list of reporter names that Jest uses when writing coverage reports
37
+ // coverageReporters: [
38
+ // "json",
39
+ // "text",
40
+ // "lcov",
41
+ // "clover"
42
+ // ],
43
+
44
+ // An object that configures minimum threshold enforcement for coverage results
45
+ // coverageThreshold: undefined,
46
+
47
+ // A path to a custom dependency extractor
48
+ // dependencyExtractor: undefined,
49
+
50
+ // Make calling deprecated APIs throw helpful error messages
51
+ // errorOnDeprecated: false,
52
+
53
+ // The default configuration for fake timers
54
+ // fakeTimers: {
55
+ // "enableGlobally": false
56
+ // },
57
+
58
+ // Force coverage collection from ignored files using an array of glob patterns
59
+ // forceCoverageMatch: [],
60
+
61
+ // A path to a module which exports an async function that is triggered once before all test suites
62
+ // globalSetup: undefined,
63
+
64
+ // A path to a module which exports an async function that is triggered once after all test suites
65
+ // globalTeardown: undefined,
66
+
67
+ // A set of global variables that need to be available in all test environments
68
+ // globals: {},
69
+
70
+ // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
71
+ // maxWorkers: "50%",
72
+
73
+ // An array of directory names to be searched recursively up from the requiring module's location
74
+ // moduleDirectories: [
75
+ // "node_modules"
76
+ // ],
77
+
78
+ // An array of file extensions your modules use
79
+ // moduleFileExtensions: [
80
+ // "js",
81
+ // "mjs",
82
+ // "cjs",
83
+ // "jsx",
84
+ // "ts",
85
+ // "tsx",
86
+ // "json",
87
+ // "node"
88
+ // ],
89
+
90
+ // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
91
+ // moduleNameMapper: {},
92
+
93
+ // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
94
+ // modulePathIgnorePatterns: [],
95
+
96
+ // Activates notifications for test results
97
+ // notify: false,
98
+
99
+ // An enum that specifies notification mode. Requires { notify: true }
100
+ // notifyMode: "failure-change",
101
+
102
+ // A preset that is used as a base for Jest's configuration
103
+ // preset: undefined,
104
+
105
+ // Run tests from one or more projects
106
+ // projects: undefined,
107
+
108
+ // Use this configuration option to add custom reporters to Jest
109
+ // reporters: undefined,
110
+
111
+ // Automatically reset mock state before every test
112
+ // resetMocks: false,
113
+
114
+ // Reset the module registry before running each individual test
115
+ // resetModules: false,
116
+
117
+ // A path to a custom resolver
118
+ // resolver: undefined,
119
+
120
+ // Automatically restore mock state and implementation before every test
121
+ // restoreMocks: false,
122
+
123
+ // The root directory that Jest should scan for tests and modules within
124
+ // rootDir: undefined,
125
+
126
+ // A list of paths to directories that Jest should use to search for files in
127
+ roots: [
128
+ "src"
129
+ ],
130
+
131
+ // Allows you to use a custom runner instead of Jest's default test runner
132
+ // runner: "jest-runner",
133
+
134
+ // The paths to modules that run some code to configure or set up the testing environment before each test
135
+ // setupFiles: [],
136
+
137
+ // A list of paths to modules that run some code to configure or set up the testing framework before each test
138
+ // setupFilesAfterEnv: [],
139
+
140
+ // The number of seconds after which a test is considered as slow and reported as such in the results.
141
+ // slowTestThreshold: 5,
142
+
143
+ // A list of paths to snapshot serializer modules Jest should use for snapshot testing
144
+ // snapshotSerializers: [],
145
+
146
+ // The test environment that will be used for testing
147
+ // testEnvironment: "jest-environment-node",
148
+
149
+ // Options that will be passed to the testEnvironment
150
+ // testEnvironmentOptions: {},
151
+
152
+ // Adds a location field to test results
153
+ // testLocationInResults: false,
154
+
155
+ // The glob patterns Jest uses to detect test files
156
+ // testMatch: [
157
+ // "**/__tests__/**/*.[jt]s?(x)",
158
+ // "**/?(*.)+(spec|test).[tj]s?(x)"
159
+ // ],
160
+
161
+ // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
162
+ // testPathIgnorePatterns: [
163
+ // "/node_modules/"
164
+ // ],
165
+
166
+ // The regexp pattern or array of patterns that Jest uses to detect test files
167
+ // testRegex: [],
168
+
169
+ // This option allows the use of a custom results processor
170
+ // testResultsProcessor: undefined,
171
+
172
+ // This option allows use of a custom test runner
173
+ // testRunner: "jest-circus/runner",
174
+
175
+ // A map from regular expressions to paths to transformers
176
+ // transform: undefined,
177
+
178
+ // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
179
+ // transformIgnorePatterns: [
180
+ // "/node_modules/",
181
+ // "\\.pnp\\.[^\\/]+$"
182
+ // ],
183
+
184
+ // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
185
+ // unmockedModulePathPatterns: undefined,
186
+
187
+ // Indicates whether each individual test should be reported during the run
188
+ // verbose: undefined,
189
+
190
+ // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
191
+ // watchPathIgnorePatterns: [],
192
+
193
+ // Whether to use watchman for file crawling
194
+ // watchman: true,
195
+ };
package/package.json CHANGED
@@ -1,14 +1,13 @@
1
1
  {
2
2
  "name": "bukazu-portal-react",
3
- "version": "2.1.21",
3
+ "version": "3.0.3",
4
4
  "description": "A package for loading the calendar and search module from bukazu loading into a react app.",
5
- "main": "build/index.js",
6
5
  "repository": "https://github.com/BUKAZU/React-portal",
7
6
  "scripts": {
8
- "start": "webpack serve --open --config webpack.config.dev",
9
- "test": "cypress open",
10
- "build": "rollup -c",
11
- "watch": "rollup -c -w"
7
+ "test": "jest",
8
+ "test-cypress": "cypress open",
9
+ "build": "vite build",
10
+ "dev": "vite"
12
11
  },
13
12
  "author": "Bob van Oorschot",
14
13
  "license": "MIT",
@@ -21,17 +20,15 @@
21
20
  "@babel/plugin-proposal-class-properties": "^7.13.0",
22
21
  "@babel/preset-env": "^7.15.0",
23
22
  "@babel/preset-react": "^7.14.5",
24
- "@cypress/react": "^5.3.3",
25
- "@cypress/webpack-dev-server": "^1.1.3",
26
- "@rollup/plugin-commonjs": "^21.0.0",
27
- "@rollup/plugin-json": "^4.1.0",
28
- "autoprefixer": "^10.2.5",
29
- "babel-core": "^6.26.3",
30
- "babel-loader": "^8.2.2",
31
- "babel-runtime": "^6.26.0",
23
+ "@babel/preset-typescript": "^7.18.6",
24
+ "@jest/globals": "^29.4.1",
25
+ "@types/node": "^18.11.18",
26
+ "@types/react": "^18.0.26",
27
+ "@types/react-dom": "^18.0.10",
28
+ "@vitejs/plugin-react": "^3.0.1",
29
+ "autoprefixer": "^10.4.13",
32
30
  "chalk": "1.1.3",
33
- "css-loader": "0.28.7",
34
- "cypress": "^7.1.0",
31
+ "cypress": "^12.4.1",
35
32
  "dotenv": "4.0.0",
36
33
  "dotenv-expand": "4.2.0",
37
34
  "eslint": "^7.28.0",
@@ -39,40 +36,38 @@
39
36
  "eslint-plugin-prettier": "^3.4.0",
40
37
  "eslint-plugin-react": "^7.24.0",
41
38
  "fs-extra": "3.0.1",
42
- "jest": "24.5.0",
43
- "mini-css-extract-plugin": "^1.5.0",
44
- "npm-run-all": "^4.1.5",
45
- "postcss": "^8.2.12",
46
- "postcss-import": "^14.0.1",
47
- "postcss-loader": "^5.2.0",
48
- "postcss-modules": "^4.2.2",
49
- "postcss-nested": "^5.0.5",
50
- "postcss-preset-env": "^7.4.3",
39
+ "jest": "^29.4.1",
40
+ "path": "^0.12.7",
41
+ "path-browserify": "^1.0.0",
42
+ "postcss-import": "^15.1.0",
43
+ "postcss-nested": "^6.0.0",
44
+ "postcss-preset-env": "^8.0.1",
51
45
  "prettier": "^2.3.1",
46
+ "process": "^0.11.10",
52
47
  "react": "^16.4.1",
53
- "react-dev-utils": "^5.0.1",
54
48
  "react-dom": "^16.14.0",
55
49
  "resolve": "1.6.0",
56
- "rollup": "^2.56.2",
57
- "rollup-plugin-babel": "^4.4.0",
58
- "rollup-plugin-node-resolve": "^5.2.0",
59
- "rollup-plugin-postcss": "^4.0.1",
60
- "rollup-plugin-replace": "^2.2.0",
61
- "webpack": "^5",
62
- "webpack-cli": "^4.6.0",
63
- "webpack-dev-server": "^3.0.0",
50
+ "ts-jest": "^29.0.5",
51
+ "typescript": "^4.9.4",
52
+ "vite": "^4.0.4",
64
53
  "whatwg-fetch": "2.0.3"
65
54
  },
66
55
  "dependencies": {
67
- "@apollo/client": "^3.4.15",
68
- "array-includes": "^3.0.3",
69
- "array-sort": "^1.0.0",
70
- "date-fns": "^1.29.0",
56
+ "@apollo/client": "^3.7.5",
57
+ "date-fns": "^2.29.3",
71
58
  "formik": "^2.2.9",
72
59
  "graphql": "^15.6.0",
73
60
  "react-date-picker": "^8.1.1",
74
- "react-intl": "5",
75
- "react-js-pagination": "^3.0.2"
61
+ "react-intl": "^6.2.5",
62
+ "react-paginate": "^8.1.4"
63
+ },
64
+ "main": "./build/portal.umd.js",
65
+ "module": "./build/portal.es.js",
66
+ "exports": {
67
+ ".": {
68
+ "import": "./build/portal.es.js",
69
+ "require": "./build/portal.umd.js"
70
+ }
76
71
  },
77
72
  "eslintConfig": {
78
73
  "extends": [
package/reviews.html ADDED
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Bukazu Portal</title>
6
+ </head>
7
+ <body>
8
+ <h1>Bukazu Test Reviews</h1>
9
+
10
+ <!-- <div class="bukazu-app" id="bukazu-app" portal-code="050497a0" object-code="DE0002" language='nl' filters='123'></div> -->
11
+ <!-- <div class="bukazu-app" id="bukazu-app" portal-code="72902823" object-code="NL1443" language='nl' filters='123'></div> -->
12
+ <div id='bukazu-app' class='bukazu-app' portal-code="674de20e" object-code="NL0099" language="nl" page="reviews"></div>
13
+
14
+ <script src="./dev.tsx" type="module"></script>
15
+ </body>
16
+ </html>
@@ -1,4 +1,4 @@
1
- import { gql} from "@apollo/client";
1
+ import { gql } from '@apollo/client';
2
2
 
3
3
  export const HOUSES_QUERY = gql`
4
4
  query PortalSiteHousesQuery(
@@ -18,6 +18,7 @@ export const HOUSES_QUERY = gql`
18
18
  $skip: Int
19
19
  ) {
20
20
  PortalSite(id: $id) {
21
+ id
21
22
  houses(
22
23
  country_id: $country_id
23
24
  region_id: $region_id
@@ -45,6 +46,8 @@ export const HOUSES_QUERY = gql`
45
46
  city
46
47
  country_name
47
48
  minimum_week_price
49
+ rating
50
+ scoreAmount
48
51
  }
49
52
  }
50
53
  }
@@ -97,6 +100,8 @@ export const HOUSES_PRICE_QUERY = gql`
97
100
  city
98
101
  country_name
99
102
  minimum_week_price
103
+ rating
104
+ score_amount
100
105
  booking_price(starts_at: $starts_at, ends_at: $ends_at)
101
106
  }
102
107
  }
@@ -104,7 +109,7 @@ export const HOUSES_PRICE_QUERY = gql`
104
109
  `;
105
110
 
106
111
  export const HOUSE_COUNT_QUERY = gql`
107
- query PortalSiteHousesQuery(
112
+ query PortalSiteHouseCountQuery(
108
113
  $id: ID!
109
114
  $country_id: ID
110
115
  $region_id: String
@@ -119,6 +124,7 @@ export const HOUSE_COUNT_QUERY = gql`
119
124
  $weekprice_max: Int
120
125
  ) {
121
126
  PortalSite(id: $id) {
127
+ id
122
128
  houses(
123
129
  country_id: $country_id
124
130
  region_id: $region_id
File without changes
@@ -0,0 +1,27 @@
1
+
2
+ import { format, parse } from 'date-fns';
3
+ import { es, nl, de, fr, it, enGB } from 'date-fns/locale';
4
+
5
+ const locales: any = {
6
+ en: enGB,
7
+ nl,
8
+ de,
9
+ fr,
10
+ it,
11
+ es,
12
+ };
13
+
14
+ function FormatIntl(date: number, formatStr: string) : String {
15
+ return format(date, formatStr, {
16
+ locale: locales[window.__localeId__], // or global.__localeId__
17
+ });
18
+ };
19
+
20
+ function Parse_EN_US(date_string: string) {
21
+ return parse(date_string, 'yyyy-MM-dd', new Date());
22
+ }
23
+
24
+ const MONTH_FORMAT:string = 'MMMM yyyy';
25
+ const LONG_DATE_FORMAT:string = 'EEEE dd MMMM yyyy'
26
+
27
+ export { FormatIntl, Parse_EN_US, MONTH_FORMAT, LONG_DATE_FORMAT };
@@ -88,13 +88,13 @@ export const CALENDAR_QUERY = gql`
88
88
  `;
89
89
 
90
90
  export const BOOKING_PRICE_QUERY = gql`
91
- query BookingPriceQuery(
92
- $id: ID!
93
- $house_id: String!
91
+ query BookingFormQuery(
92
+ $portalCode: ID!
93
+ $objectCode: String!
94
94
  $starts_at: Date!
95
95
  $ends_at: Date!
96
96
  ) {
97
- PortalSite(id: $id) {
97
+ PortalSite(id: $portalCode) {
98
98
  id
99
99
  options
100
100
  first_name_label
@@ -122,7 +122,7 @@ export const BOOKING_PRICE_QUERY = gql`
122
122
  options
123
123
  placeholder
124
124
  }
125
- houses(house_code: $house_id) {
125
+ houses(house_code: $objectCode) {
126
126
  id
127
127
  name
128
128
  code
@@ -219,3 +219,22 @@ export const CREATE_BOOKING_MUTATION = gql`
219
219
  }
220
220
  }
221
221
  `;
222
+
223
+ export const SINGLE_HOUSE_QUERY = gql`
224
+ query PortalSiteSingleHouseQuery($portalCode: ID!, $objectCode: String!) {
225
+ PortalSite(id: $portalCode) {
226
+ id
227
+ houses(house_code: $objectCode) {
228
+ id
229
+ code
230
+ name
231
+ max_nights
232
+ last_minute_days
233
+ discounts
234
+ discounts_info
235
+ house_type
236
+ persons
237
+ }
238
+ }
239
+ }
240
+ `;
@@ -0,0 +1,132 @@
1
+ import React, { useContext, useEffect, useState } from 'react';
2
+ import Loading from './icons/loading.svg';
3
+
4
+ import 'react-date-picker/dist/DatePicker.css';
5
+ import 'react-calendar/dist/Calendar.css';
6
+
7
+ import { PORTAL_QUERY } from '../_lib/queries';
8
+
9
+ import SearchPage from './SearchPage/SearchPage';
10
+ import CalendarPage from './CalendarPage/CalendarPage';
11
+ import ReviewsPage from './ReviewsPage/ReviewsPage';
12
+ import SafeBooking from './SafeBooking';
13
+ import { ApiError } from './Error';
14
+ import ErrorBoundary from './ErrorBoundary';
15
+ import { useQuery } from '@apollo/client';
16
+ import { AppContext } from './AppContext';
17
+ import { FiltersType } from './SearchPage/filters/filter_types';
18
+
19
+ const getWidth = () =>
20
+ window.innerWidth ||
21
+ document.documentElement.clientWidth ||
22
+ document.body.clientWidth;
23
+
24
+ interface Props {
25
+ pageType?: string;
26
+ filters?: FiltersType;
27
+ locale: string;
28
+ }
29
+
30
+ function App({ pageType, locale, filters }: Props): JSX.Element {
31
+ const { portalCode, objectCode } = useContext(AppContext);
32
+
33
+ let [width, setWidth] = useState(getWidth());
34
+
35
+ // in this case useEffect will execute only once because
36
+ // it does not have any dependencies.
37
+ useEffect(() => {
38
+ const resizeListener = () => {
39
+ // change width from the state object
40
+ setWidth(getWidth());
41
+ };
42
+ // set resize listener
43
+ window.addEventListener('resize', resizeListener);
44
+
45
+ // clean up function
46
+ return () => {
47
+ // remove resize listener
48
+ window.removeEventListener('resize', resizeListener);
49
+ };
50
+ }, []);
51
+
52
+ const { loading, error, data } = useQuery(PORTAL_QUERY, {
53
+ variables: { id: portalCode }
54
+ });
55
+
56
+ if (loading) {
57
+ return <Loading />;
58
+ }
59
+
60
+ if (error) {
61
+ return <ApiError errors={{ ...error }} />;
62
+ }
63
+
64
+ const PortalSite = data.PortalSite;
65
+ let options = data.PortalSite.options;
66
+
67
+ let root = document.documentElement;
68
+
69
+ root.style.setProperty(
70
+ '--bukazu-discount',
71
+ `${options.colors ? options.colors.discount : 'orange'}`
72
+ );
73
+ root.style.setProperty(
74
+ '--bukazu-cell',
75
+ `${options.colors ? options.colors.cell : '#fff'}`
76
+ );
77
+ root.style.setProperty(
78
+ '--bukazu-arrival',
79
+ `${options.colors ? options.colors.arrival : '#6eeb83'}`
80
+ );
81
+ root.style.setProperty(
82
+ '--bukazu-booked',
83
+ `${options.colors ? options.colors.booked : '#ea2b1f'}`
84
+ );
85
+ root.style.setProperty(
86
+ '--bukazu-departure',
87
+ `${options.colors ? options.colors.departure : 'yellow'}`
88
+ );
89
+
90
+ root.style.setProperty(
91
+ '--bukazu-button',
92
+ `${options.colors ? options.colors.button : 'rgba(23, 190, 187, 0.75)'}`
93
+ );
94
+ root.style.setProperty(
95
+ '--bukazu-button_cta',
96
+ `${options.colors ? options.colors.buttonCta : '#e28413'}`
97
+ );
98
+ root.style.setProperty(
99
+ '--bukazu-background_month',
100
+ `${options.colors ? options.colors.month_background : '#e28413'}`
101
+ );
102
+
103
+ let page;
104
+
105
+ if (objectCode && objectCode !== null && pageType !== 'reviews') {
106
+ page = (
107
+ <ErrorBoundary>
108
+ <CalendarPage PortalSite={PortalSite} />
109
+ <SafeBooking />
110
+ </ErrorBoundary>
111
+ );
112
+ } else if (objectCode && objectCode !== null && pageType === 'reviews') {
113
+ page = <ReviewsPage />;
114
+ } else {
115
+ page = (
116
+ <SearchPage
117
+ PortalSite={PortalSite}
118
+ locale={locale}
119
+ options={options}
120
+ filters={filters}
121
+ />
122
+ );
123
+ }
124
+
125
+ return <div className={width < 875 ? 'bu-smaller' : ''}>{page}</div>;
126
+ }
127
+
128
+ App.defaultProps = {
129
+ filters: {}
130
+ };
131
+
132
+ export default App;
@@ -0,0 +1,14 @@
1
+ import { createContext } from 'react';
2
+ import { LocaleType } from '../types';
3
+
4
+ export const AppContext = createContext<AppContextType>({
5
+ locale: 'nl',
6
+ portalCode: '',
7
+ objectCode: ''
8
+ });
9
+
10
+ type AppContextType = {
11
+ locale: LocaleType;
12
+ portalCode: string;
13
+ objectCode: string;
14
+ };
@@ -0,0 +1,42 @@
1
+ import React, { useContext } from 'react';
2
+ import Loading from '../icons/loading.svg';
3
+ import FormCreator from './FormCreator';
4
+ import { BOOKING_PRICE_QUERY } from '../../_lib/queries';
5
+ import { useQuery } from '@apollo/client';
6
+ import { AppContext } from '../AppContext';
7
+ import { CalendarContext } from './CalendarParts/CalendarContext';
8
+
9
+
10
+ function BookingForm(): JSX.Element {
11
+ const { portalCode, objectCode } = useContext(AppContext);
12
+ const { arrivalDate, departureDate } = useContext(CalendarContext)
13
+ const { data, loading, error } = useQuery(BOOKING_PRICE_QUERY, {
14
+ variables: {
15
+ portalCode,
16
+ objectCode,
17
+ starts_at: arrivalDate.date,
18
+ ends_at: departureDate.date
19
+ }
20
+ });
21
+
22
+ if (loading)
23
+ return (
24
+ <div>
25
+ <Loading />
26
+ </div>
27
+ );
28
+ if (error) {
29
+ return <div>Error</div>;
30
+ }
31
+
32
+ const result = data.PortalSite.houses[0];
33
+
34
+ return (
35
+ <FormCreator
36
+ house={result}
37
+ PortalSite={data.PortalSite}
38
+ />
39
+ );
40
+ }
41
+
42
+ export default BookingForm;