@wayke-se/components-react 3.0.0-beta.11 → 3.0.0-beta.12

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 (274) hide show
  1. package/package.json +4 -2
  2. package/.editorconfig +0 -10
  3. package/.eslintrc.js +0 -62
  4. package/.github/workflows/release-to-production.yaml +0 -40
  5. package/.github/workflows/release-to-test.yaml +0 -40
  6. package/.prettierrc +0 -12
  7. package/assets/ajax-loader.gif +0 -0
  8. package/assets/default.css +0 -1
  9. package/assets/fonts/slick.eot +0 -0
  10. package/assets/fonts/slick.svg +0 -14
  11. package/assets/fonts/slick.ttf +0 -0
  12. package/assets/fonts/slick.woff +0 -0
  13. package/codegen.yml +0 -19
  14. package/esbuild/build.js +0 -39
  15. package/esbuild/common.js +0 -15
  16. package/esbuild/start.js +0 -21
  17. package/esbuild/www/index.html +0 -32
  18. package/example/src/@types/global.d.ts +0 -7
  19. package/example/src/@types/react-panellum.d.ts +0 -1
  20. package/example/src/App.tsx +0 -77
  21. package/example/src/assets/style/ecom.css +0 -63
  22. package/example/src/assets/style/theme.css +0 -83
  23. package/example/src/index.html +0 -26
  24. package/example/src/index.tsx +0 -11
  25. package/example/src/routes/HashRoute/index.tsx +0 -30
  26. package/example/src/routes/Home/index.tsx +0 -33
  27. package/example/src/routes/NotFound/index.tsx +0 -5
  28. package/example/src/routes/PathRoute/index.tsx +0 -35
  29. package/example/src/routes/Search/index.tsx +0 -28
  30. package/example/src/routes/SearchItem/index.tsx +0 -28
  31. package/example/src/routes/index.tsx +0 -25
  32. package/src/@types/action.ts +0 -3
  33. package/src/@types/codegen/types.ts +0 -366
  34. package/src/@types/filter.ts +0 -18
  35. package/src/@types/queryFilter.ts +0 -5
  36. package/src/@types/react-panellum.d.ts +0 -1
  37. package/src/@types/search.ts +0 -118
  38. package/src/@types/theme.d.ts +0 -5
  39. package/src/@types/vehicle-properties.ts +0 -33
  40. package/src/State/CentralStorage/CentralStorageContext.ts +0 -10
  41. package/src/State/CentralStorage/CentralStorageProvider.tsx +0 -21
  42. package/src/State/CentralStorage/useCentralStorage.ts +0 -37
  43. package/src/State/Path/PathContext.ts +0 -11
  44. package/src/State/Path/PathProvider.tsx +0 -66
  45. package/src/State/Path/reducer.ts +0 -30
  46. package/src/State/Path/usePath.ts +0 -13
  47. package/src/State/RelatedSearch/RelatedSearchContext.ts +0 -18
  48. package/src/State/RelatedSearch/RelatedSearchProvider.tsx +0 -55
  49. package/src/State/RelatedSearch/useRelatedSearch.ts +0 -20
  50. package/src/State/Search/SearchContext.ts +0 -27
  51. package/src/State/Search/SearchProvider.tsx +0 -243
  52. package/src/State/Search/useSearch.ts +0 -6
  53. package/src/State/Settings/SettingsContext.ts +0 -15
  54. package/src/State/Settings/SettingsProvider.tsx +0 -23
  55. package/src/State/Settings/useSettings.ts +0 -7
  56. package/src/components/Accordion/index.tsx +0 -57
  57. package/src/components/Accordion/wrapper.tsx +0 -107
  58. package/src/components/ActionList/index.tsx +0 -48
  59. package/src/components/ActionList/toggle-item.tsx +0 -59
  60. package/src/components/Avatar/index.tsx +0 -12
  61. package/src/components/Avatar/wrapper.tsx +0 -21
  62. package/src/components/Badge/index.tsx +0 -12
  63. package/src/components/Badge/wrapper.tsx +0 -32
  64. package/src/components/Blockquote/index.tsx +0 -32
  65. package/src/components/Blockquote/wrapper.tsx +0 -52
  66. package/src/components/Button/index.tsx +0 -226
  67. package/src/components/CheckMarkList/index.tsx +0 -21
  68. package/src/components/CheckMarkList/wrapper.tsx +0 -31
  69. package/src/components/Checklist/index.tsx +0 -51
  70. package/src/components/Checklist/wrapper.tsx +0 -65
  71. package/src/components/ColorSelect/index.tsx +0 -63
  72. package/src/components/ColorSelect/wrapper.tsx +0 -82
  73. package/src/components/ColumnRow/index.tsx +0 -20
  74. package/src/components/Container/index.tsx +0 -11
  75. package/src/components/Container/wrapper.tsx +0 -14
  76. package/src/components/Content/index.tsx +0 -15
  77. package/src/components/Content/wrapper.tsx +0 -61
  78. package/src/components/ContentLogo/index.tsx +0 -27
  79. package/src/components/DataList/index.tsx +0 -25
  80. package/src/components/DataList/wrapper.tsx +0 -29
  81. package/src/components/DetailBox/index.tsx +0 -34
  82. package/src/components/DetailBox/wrapper.tsx +0 -34
  83. package/src/components/ExtendContent/index.tsx +0 -43
  84. package/src/components/ExtendContent/wrapper.tsx +0 -41
  85. package/src/components/ExtendInfo/index.tsx +0 -32
  86. package/src/components/ExtendInfo/wrapper.tsx +0 -63
  87. package/src/components/Filter/index.tsx +0 -108
  88. package/src/components/Filter/wrapper.tsx +0 -79
  89. package/src/components/FilterPanel/checkListFacet.tsx +0 -46
  90. package/src/components/FilterPanel/colorFacet.tsx +0 -47
  91. package/src/components/FilterPanel/faceSelector.tsx +0 -53
  92. package/src/components/FilterPanel/index.tsx +0 -79
  93. package/src/components/FilterPanel/rangeFacet.tsx +0 -128
  94. package/src/components/FinancialOptions/LoanModal.tsx +0 -223
  95. package/src/components/FinancialOptions/index.tsx +0 -29
  96. package/src/components/FinancialOptions/leasing.tsx +0 -77
  97. package/src/components/FinancialOptions/loan.tsx +0 -87
  98. package/src/components/Gallery/MediaButton.tsx +0 -19
  99. package/src/components/Gallery/index.tsx +0 -227
  100. package/src/components/Gallery/wrapper.tsx +0 -323
  101. package/src/components/Grid/index.tsx +0 -87
  102. package/src/components/Grid/wrapper.tsx +0 -30
  103. package/src/components/Heading/index.tsx +0 -72
  104. package/src/components/Icon/index.tsx +0 -87
  105. package/src/components/InputCheckbox/index.tsx +0 -30
  106. package/src/components/InputCheckbox/wrapper.tsx +0 -87
  107. package/src/components/InputGroup/index.tsx +0 -24
  108. package/src/components/InputLabel/index.tsx +0 -14
  109. package/src/components/InputLabel/wrapper.tsx +0 -10
  110. package/src/components/InputSearch/index.tsx +0 -51
  111. package/src/components/InputSearch/wrapper.tsx +0 -97
  112. package/src/components/InputSelect/index.tsx +0 -35
  113. package/src/components/InputSelect/wrapper.tsx +0 -59
  114. package/src/components/InputText/index.tsx +0 -27
  115. package/src/components/InputText/wrapper.tsx +0 -57
  116. package/src/components/InsuranceOptions/Insurance.tsx +0 -60
  117. package/src/components/InsuranceOptions/InsuranceFree.tsx +0 -59
  118. package/src/components/InsuranceOptions/InsuranceFreeModal.tsx +0 -49
  119. package/src/components/InsuranceOptions/InsuranceModal.tsx +0 -253
  120. package/src/components/InsuranceOptions/index.tsx +0 -27
  121. package/src/components/Lightbox/index.tsx +0 -51
  122. package/src/components/Lightbox/wrapper.tsx +0 -97
  123. package/src/components/Loader/index.tsx +0 -18
  124. package/src/components/Loader/wrapper.tsx +0 -50
  125. package/src/components/LogoBox/index.tsx +0 -22
  126. package/src/components/LogoBox/wrapper.tsx +0 -19
  127. package/src/components/Map/index.tsx +0 -62
  128. package/src/components/Map/wrapper.tsx +0 -29
  129. package/src/components/Modal/index.tsx +0 -51
  130. package/src/components/Modal/wrapper.tsx +0 -127
  131. package/src/components/OpeningHours/index.tsx +0 -145
  132. package/src/components/OptionBox/index.tsx +0 -23
  133. package/src/components/OptionBox/wrapper.tsx +0 -56
  134. package/src/components/OverflowBox/index.tsx +0 -11
  135. package/src/components/OverflowBox/wrapper.tsx +0 -7
  136. package/src/components/OverflowGrid/index.tsx +0 -70
  137. package/src/components/Page/index.tsx +0 -46
  138. package/src/components/Panel/index.tsx +0 -50
  139. package/src/components/Panel/wrapper.tsx +0 -155
  140. package/src/components/Pdf/index.tsx +0 -46
  141. package/src/components/Pdf/wrapper.tsx +0 -61
  142. package/src/components/PhoneNumber/index.tsx +0 -33
  143. package/src/components/Portal/index.ts +0 -5
  144. package/src/components/Portal/portal-element.tsx +0 -9
  145. package/src/components/Portal/portal-namespace.ts +0 -1
  146. package/src/components/Portal/portal.tsx +0 -36
  147. package/src/components/Price/index.tsx +0 -12
  148. package/src/components/PriceTable/index.tsx +0 -34
  149. package/src/components/PriceTable/wrapper.tsx +0 -27
  150. package/src/components/ProductCard/index.tsx +0 -133
  151. package/src/components/ProductCard/wrapper.tsx +0 -147
  152. package/src/components/ProductPage/index.tsx +0 -99
  153. package/src/components/ProgressBar/index.tsx +0 -31
  154. package/src/components/ProgressBar/wrapper.tsx +0 -29
  155. package/src/components/RangeSlider/RangeSliderSimple.tsx +0 -90
  156. package/src/components/RangeSlider/SliderWithLabel.tsx +0 -62
  157. package/src/components/RangeSlider/handle.tsx +0 -26
  158. package/src/components/RangeSlider/index.tsx +0 -132
  159. package/src/components/RangeSlider/track.tsx +0 -19
  160. package/src/components/RangeSlider/wrapper.tsx +0 -93
  161. package/src/components/RangeSliderLabel/index.tsx +0 -18
  162. package/src/components/RangeSliderLabel/wrapper.tsx +0 -33
  163. package/src/components/Repeat/index.tsx +0 -21
  164. package/src/components/Result/index.tsx +0 -91
  165. package/src/components/Result/wrapper.tsx +0 -39
  166. package/src/components/Root/index.tsx +0 -24
  167. package/src/components/SearchBar/index.tsx +0 -48
  168. package/src/components/SearchFilter/index.tsx +0 -31
  169. package/src/components/SearchTerm/index.tsx +0 -23
  170. package/src/components/SearchTerm/wrapper.tsx +0 -71
  171. package/src/components/SectionHeader/index.tsx +0 -25
  172. package/src/components/SectionHeader/wrapper.tsx +0 -17
  173. package/src/components/Snackbar/index.tsx +0 -35
  174. package/src/components/Snackbar/wrapper.tsx +0 -65
  175. package/src/components/SortSelect/index.tsx +0 -35
  176. package/src/components/SortSelect/wrapper.tsx +0 -54
  177. package/src/components/Sphere/Sphere.tsx +0 -49
  178. package/src/components/Sphere/SphereLightbox.tsx +0 -10
  179. package/src/components/Sphere/SphereViewer.tsx +0 -81
  180. package/src/components/Sphere/wrapper.tsx +0 -253
  181. package/src/components/SrOnly/index.tsx +0 -14
  182. package/src/components/SwitchBar/index.tsx +0 -55
  183. package/src/components/SwitchBar/wrapper.tsx +0 -80
  184. package/src/components/TableColumn/index.tsx +0 -18
  185. package/src/components/TableList/index.tsx +0 -39
  186. package/src/components/Tabs/index.tsx +0 -34
  187. package/src/components/Tabs/wrapper.tsx +0 -82
  188. package/src/components/ThreeSixty/Rotation.tsx +0 -136
  189. package/src/components/ThreeSixty/ThreeSixtLightbox.tsx +0 -34
  190. package/src/components/ThreeSixty/ThreeSixty.tsx +0 -53
  191. package/src/components/UspList/index.tsx +0 -47
  192. package/src/components/UspList/wrapper.tsx +0 -92
  193. package/src/components/Utility/index.tsx +0 -17
  194. package/src/components/Video/CustomPlayer.tsx +0 -28
  195. package/src/components/Video/EmbeddedVideoLightbox.tsx +0 -31
  196. package/src/components/Video/EmbededVideo.tsx +0 -72
  197. package/src/components/Video/QuickNavEmbeded.tsx +0 -35
  198. package/src/components/Video/QuickNavVideo.tsx +0 -14
  199. package/src/components/Video/Video.tsx +0 -18
  200. package/src/components/Video/VimeoPlayer.tsx +0 -21
  201. package/src/components/Video/YoutubePlayer.tsx +0 -21
  202. package/src/components/Video/useThumbnail.ts +0 -28
  203. package/src/components/Video/utils.ts +0 -47
  204. package/src/components/Video/wrapper.tsx +0 -29
  205. package/src/hooks/useFetch.ts +0 -88
  206. package/src/hooks/useHasBeenVisible.ts +0 -17
  207. package/src/hooks/useHashGuid.ts +0 -33
  208. package/src/hooks/useInsurance.ts +0 -22
  209. package/src/hooks/useLoan.ts +0 -21
  210. package/src/hooks/useOnScreen.ts +0 -20
  211. package/src/hooks/useOutsideClick.ts +0 -19
  212. package/src/hooks/usePrevious.ts +0 -11
  213. package/src/hooks/useSearchItem.ts +0 -11
  214. package/src/hooks/useSearchItemBranch.ts +0 -14
  215. package/src/hooks/useSessionStorage.ts +0 -32
  216. package/src/hooks/useVimeoThumbnail.ts +0 -31
  217. package/src/images/map/marker.png +0 -0
  218. package/src/images/placeholders/staticmap.jpg +0 -0
  219. package/src/index-dev.tsx +0 -42
  220. package/src/index-esbuild.ts +0 -74
  221. package/src/index.ts +0 -72
  222. package/src/layout/helpers.tsx +0 -6
  223. package/src/layout/keyframes.tsx +0 -23
  224. package/src/layout/theme.ts +0 -60
  225. package/src/layouts/WaykeComposite.tsx +0 -64
  226. package/src/layouts/WaykeCompositeWithProvider.tsx +0 -17
  227. package/src/layouts/search/index.tsx +0 -124
  228. package/src/layouts/searchItem/Branch.tsx +0 -97
  229. package/src/layouts/searchItem/BranchModal.tsx +0 -67
  230. package/src/layouts/searchItem/CheckList.tsx +0 -146
  231. package/src/layouts/searchItem/ManufacturerPackagesOption.tsx +0 -54
  232. package/src/layouts/searchItem/MetadataItem.tsx +0 -74
  233. package/src/layouts/searchItem/PackageOptionModal.tsx +0 -54
  234. package/src/layouts/searchItem/PackageOptions.tsx +0 -58
  235. package/src/layouts/searchItem/Page404.tsx +0 -17
  236. package/src/layouts/searchItem/PageLoading.tsx +0 -17
  237. package/src/layouts/searchItem/Property.tsx +0 -134
  238. package/src/layouts/searchItem/Related.tsx +0 -120
  239. package/src/layouts/searchItem/index.tsx +0 -342
  240. package/src/providers/WaykeItemProvidet.tsx +0 -63
  241. package/src/providers/WaykeProvider.tsx +0 -75
  242. package/src/providers/graphqlProvider.tsx +0 -9
  243. package/src/providers/themeProvider.tsx +0 -15
  244. package/src/queries/INSURANCE_CALCULATION.ts +0 -43
  245. package/src/queries/LOAN_CALCULATION.ts +0 -39
  246. package/src/queries/SEARCH_ITEM_BRANCH_QUERY.ts +0 -120
  247. package/src/queries/SEARCH_ITEM_QUERY.ts +0 -237
  248. package/src/utils/constants.ts +0 -34
  249. package/src/utils/converters.ts +0 -45
  250. package/src/utils/deep-copy.ts +0 -6
  251. package/src/utils/formats.ts +0 -83
  252. package/src/utils/metadata.min.ts +0 -87
  253. package/src/utils/phonenumbers.ts +0 -17
  254. package/src/utils/pubsub/Actions.ts +0 -20
  255. package/src/utils/pubsub/Events.ts +0 -79
  256. package/src/utils/pubsub/pubsub.ts +0 -151
  257. package/src/utils/regex.ts +0 -13
  258. package/src/utils/sortOptions.ts +0 -36
  259. package/src/utils/specification.ts +0 -581
  260. package/src/utils/ssn.ts +0 -1
  261. package/src/utils/url.ts +0 -1
  262. package/src/utils/vehicle-properties/compare-basic-properties.ts +0 -63
  263. package/src/utils/vehicle-properties/compare-categories.ts +0 -45
  264. package/src/utils/vehicle-properties/compare-properties.ts +0 -5
  265. package/src/utils/vehicle-properties/custom-property-adder.ts +0 -163
  266. package/src/utils/vehicle-properties/property-hint-enricher.ts +0 -230
  267. package/src/utils/vehicle-properties/property-remover.ts +0 -28
  268. package/src/utils/vehicle-properties/property-tree-creator.ts +0 -171
  269. package/src/utils/vehicle-properties/property-tree-sorter.ts +0 -20
  270. package/tsconfig.build.json +0 -10
  271. package/tsconfig.eslint.json +0 -11
  272. package/tsconfig.json +0 -18
  273. package/webpack.analyze.js +0 -10
  274. package/webpack.config.js +0 -95
@@ -1,223 +0,0 @@
1
- import React, { useState, useCallback, useEffect } from 'react';
2
-
3
- import useLoanCalculation from '../../hooks/useLoan';
4
- import Modal from '../Modal/index';
5
- import { ModalFoldout, ModalFoldoutBody } from '../Modal/wrapper';
6
- import Content from '../Content/index';
7
- import LogoBox from '../LogoBox/index';
8
- import { Repeat, RepeatSmall, RepeatTiny } from '../Repeat/index';
9
- import { numberSeparator } from '../../utils/formats';
10
- import { ButtonClear, ButtonContent } from '../Button/index';
11
- import { ContentLogo, ContentLogoText, ContentLogoMedia } from '../ContentLogo/index';
12
- import DataList from '../DataList/index';
13
- import { FinancialOption, Query } from '../../@types/codegen/types';
14
- import PubSub from '../../utils/pubsub/pubsub';
15
- import SliderWithLabel from '../RangeSlider/SliderWithLabel';
16
-
17
- const stepGenerator = (
18
- step: number,
19
- max: number,
20
- steps: number[] = [],
21
- current?: number
22
- ): number[] => {
23
- if (step === 0 && current === undefined) return steps;
24
-
25
- if (current !== undefined && current >= max && step !== 0) {
26
- return steps;
27
- }
28
-
29
- const nextCurrent = current ? step + current : step;
30
- steps.push(nextCurrent);
31
- return stepGenerator(step, max, steps, nextCurrent);
32
- };
33
-
34
- interface LoanModalProps {
35
- id: string;
36
- financialOption: FinancialOption;
37
- onClose: () => void;
38
- }
39
-
40
- const LoanModal = ({ id, financialOption, onClose }: LoanModalProps) => {
41
- const [tmp, setTmp] = useState<Query>();
42
- const [extend, setExtend] = React.useState(false);
43
- const onToggleExtend = React.useCallback(() => {
44
- if (!extend) {
45
- PubSub.publish('FinanceInterest');
46
- }
47
- setExtend(!extend);
48
- }, [extend]);
49
-
50
- const [variables, setVariables] = useState({
51
- duration: financialOption.duration?.current,
52
- downPayment: financialOption.downPayment?.current,
53
- residual: financialOption.residual?.current,
54
- });
55
-
56
- const { duration, downPayment, residual } = variables;
57
- const { loading, data } = useLoanCalculation(id, duration, downPayment, residual);
58
- useEffect(() => {
59
- if (data) {
60
- setTmp(data);
61
- setVariables({
62
- duration: data?.loan?.duration?.current || 0,
63
- downPayment: data?.loan?.downPayment?.current || 0,
64
- residual: data?.loan?.residual?.current || 0,
65
- });
66
- }
67
- }, [data]);
68
-
69
- const loan = data?.loan || tmp?.loan;
70
-
71
- const downPaymentCurrent = loan?.downPayment?.current || 0;
72
- const downPaymentMin = loan?.downPayment?.min || 0;
73
- const downPaymentMax = loan?.downPayment?.max || 0;
74
- const downPaymentStep = loan?.downPayment?.step || 0;
75
- const downPaymentSteps = stepGenerator(downPaymentStep, downPaymentMax);
76
- const onDownPaymentChange = useCallback(
77
- (values: readonly number[]) => {
78
- PubSub.publish('FinanceInterest');
79
- setVariables({ ...variables, downPayment: values[0] });
80
- },
81
- [variables]
82
- );
83
-
84
- const durationCurrent = loan?.duration?.current || 0;
85
- const durationMin = loan?.duration?.min || 0;
86
- const durationMax = loan?.duration?.max || 0;
87
- const durationStep = loan?.duration?.step || 0;
88
- const durationSteps = stepGenerator(durationStep, durationMax);
89
- const onDurationChange = useCallback(
90
- (values: readonly number[]) => {
91
- PubSub.publish('FinanceInterest');
92
- setVariables({ ...variables, duration: values[0] });
93
- },
94
- [variables]
95
- );
96
-
97
- const residualCurrent = (loan?.residual?.current || 0) * 100 || 0;
98
- const residualMin = (loan?.residual?.min || 0) * 100 || 0;
99
- const residualMax = (loan?.residual?.max || 0) * 100 || 0;
100
- const residualStep = (loan?.residual?.step || 0) * 100 || 0;
101
- const residualSteps = stepGenerator(residualStep, residualMax);
102
- const onResidualChange = useCallback(
103
- (values: readonly number[]) => {
104
- PubSub.publish('FinanceInterest');
105
- setVariables({ ...variables, residual: values[0] / 100 });
106
- },
107
- [variables]
108
- );
109
-
110
- const interestText = ((loan?.interest || 0) * 100).toFixed(2);
111
- const effectiveInterestText = ((loan?.effectiveInterest || 0) * 100).toFixed(2);
112
-
113
- return (
114
- <Modal title="Lånealternativ" onClose={onClose}>
115
- <Repeat>
116
- <ContentLogo>
117
- {financialOption?.description && (
118
- <ContentLogoText>
119
- <Content>
120
- <p>{financialOption.description}</p>
121
- </Content>
122
- </ContentLogoText>
123
- )}
124
- {financialOption?.image && (
125
- <ContentLogoMedia>
126
- <LogoBox logo={financialOption.image} alt={financialOption.name || 'Logotyp'} wide />
127
- </ContentLogoMedia>
128
- )}
129
- </ContentLogo>
130
- </Repeat>
131
- <Repeat>
132
- <RepeatSmall>
133
- <SliderWithLabel
134
- label="Kontantinsatts"
135
- values={[downPaymentCurrent]}
136
- domain={[downPaymentMin, downPaymentMax]}
137
- steps={downPaymentSteps}
138
- unit="kr"
139
- formatValues
140
- loading={loading}
141
- onChange={onDownPaymentChange}
142
- />
143
- </RepeatSmall>
144
- <RepeatSmall>
145
- <SliderWithLabel
146
- label="Avbetalning"
147
- values={[durationCurrent]}
148
- domain={[durationMin, durationMax]}
149
- steps={durationSteps}
150
- unit="mån"
151
- loading={loading}
152
- onChange={onDurationChange}
153
- />
154
- </RepeatSmall>
155
- {residual !== undefined && residualMax !== 0 && (
156
- <RepeatSmall>
157
- <SliderWithLabel
158
- label="Restskuld"
159
- values={[residualCurrent]}
160
- domain={[residualMin, residualMax]}
161
- steps={residualSteps}
162
- unit="%"
163
- loading={loading}
164
- onChange={onResidualChange}
165
- />
166
- </RepeatSmall>
167
- )}
168
- <RepeatSmall>
169
- <RepeatTiny>
170
- <Content small>
171
- <p>{`*Beräknat på ${interestText} % ränta (effektivt ${effectiveInterestText} %)${
172
- loan?.mileage !== null ? `och en årlig körsträcka om ${loan?.mileage} mil.` : ''
173
- }`}</p>
174
- </Content>
175
- </RepeatTiny>
176
- </RepeatSmall>
177
-
178
- <RepeatSmall>
179
- <ButtonClear
180
- onClick={onToggleExtend}
181
- title={extend ? 'Visa mindre information' : 'Visa mer information'}
182
- >
183
- <ButtonContent>{extend ? 'Mindre information' : 'Mer information'}</ButtonContent>
184
- </ButtonClear>
185
- </RepeatSmall>
186
- <>
187
- {extend && (
188
- <ModalFoldout>
189
- <ModalFoldoutBody>
190
- <DataList
191
- items={[
192
- {
193
- label: 'Ränta',
194
- value: `${interestText} %`,
195
- },
196
- {
197
- label: 'Effektiv ränta',
198
- value: `${effectiveInterestText} %`,
199
- },
200
- {
201
- label: 'Uppläggningskostnad',
202
- value: `${numberSeparator(financialOption?.setupFee || 0)} kr`,
203
- },
204
- {
205
- label: 'Administrativa avgifter',
206
- value: `${numberSeparator(financialOption?.administrationFee || 0)} kr/mån`,
207
- },
208
- {
209
- label: 'Total kreditkostnad',
210
- value: `${numberSeparator(loan?.totalCreditCost || 0)} kr`,
211
- },
212
- ]}
213
- />
214
- </ModalFoldoutBody>
215
- </ModalFoldout>
216
- )}
217
- </>
218
- </Repeat>
219
- </Modal>
220
- );
221
- };
222
-
223
- export default LoanModal;
@@ -1,29 +0,0 @@
1
- import React, { Fragment } from 'react';
2
- import { Repeat, RepeatTiny } from '../Repeat/index';
3
- import { VisualHeading } from '../Heading/index';
4
- import Leasing from './leasing';
5
- import Loan from './loan';
6
- import { FinancialOption } from '../../@types/codegen/types';
7
-
8
- interface FinancialOptionsProps {
9
- id: string;
10
- financialOptions: FinancialOption[];
11
- }
12
-
13
- const FinancialOptions = ({ id, financialOptions }: FinancialOptionsProps) => (
14
- <Repeat>
15
- <RepeatTiny>
16
- <VisualHeading>Andra finansieringsalternativ</VisualHeading>
17
- </RepeatTiny>
18
- <RepeatTiny>
19
- {financialOptions.map((financialOption, index) => (
20
- <Fragment key={index}>
21
- {financialOption.type === 'leasing' && <Leasing financialOption={financialOption} />}
22
- {financialOption.type === 'loan' && <Loan id={id} financialOption={financialOption} />}
23
- </Fragment>
24
- ))}
25
- </RepeatTiny>
26
- </Repeat>
27
- );
28
-
29
- export default FinancialOptions;
@@ -1,77 +0,0 @@
1
- import React, { useState, useCallback } from 'react';
2
-
3
- import OptionBox from '../OptionBox/index';
4
- import { OptionBoxHeading, OptionBoxContent } from '../OptionBox/wrapper';
5
- import { UtilityTextPrimary } from '../Utility/index';
6
- import { ButtonInline } from '../Button/index';
7
- import { numberSeparator } from '../../utils/formats';
8
- import Modal from '../Modal/index';
9
- import { Image, ModalFoldout, ModalFoldoutBody } from '../Modal/wrapper';
10
- import Content from '../Content/index';
11
- import DataList from '../DataList/index';
12
- import { FinancialOption } from '../../@types/codegen/types';
13
-
14
- interface LeasingProps {
15
- financialOption: FinancialOption;
16
- }
17
-
18
- const Leasing = ({ financialOption }: LeasingProps) => {
19
- const [modal, setModal] = useState(false);
20
- const toggleModal = useCallback(() => setModal(!modal), [modal]);
21
-
22
- const { image, description, monthlyCost, duration, mileage } = financialOption;
23
-
24
- return (
25
- <>
26
- {modal && (
27
- <Modal title="Privatleasing" onClose={toggleModal}>
28
- {image && <Image src={image} alt="Privatleasing" />}
29
- {description && <Content dangerouslySetInnerHTML={{ __html: description }} />}
30
- <ModalFoldout>
31
- <ModalFoldoutBody>
32
- <DataList
33
- items={[
34
- {
35
- label: 'Månadskostnad',
36
- value: `${numberSeparator(monthlyCost || 0)} kr/mån`,
37
- },
38
- {
39
- label: 'Bindningstid',
40
- value: `${duration?.current} månader`,
41
- },
42
- {
43
- label: 'Årlig körsträcka',
44
- value: `${numberSeparator(mileage?.current || 0)} mil/år`,
45
- },
46
- ]}
47
- />
48
- </ModalFoldoutBody>
49
- </ModalFoldout>
50
- </Modal>
51
- )}
52
- <OptionBox>
53
- <>
54
- {monthlyCost !== null && monthlyCost !== undefined && (
55
- <OptionBoxHeading>{`ca ${numberSeparator(monthlyCost)} kr/mån`}</OptionBoxHeading>
56
- )}
57
- </>
58
- <OptionBoxContent>
59
- <p>
60
- Privatleasing{' '}
61
- {mileage?.current && duration?.current && (
62
- <>
63
- <UtilityTextPrimary>{numberSeparator(mileage?.current)} mil/år</UtilityTextPrimary>{' '}
64
- i <UtilityTextPrimary>{duration?.current} mån</UtilityTextPrimary>.{' '}
65
- </>
66
- )}
67
- </p>
68
- <p>
69
- <ButtonInline onClick={toggleModal}>Läs mer</ButtonInline>
70
- </p>
71
- </OptionBoxContent>
72
- </OptionBox>
73
- </>
74
- );
75
- };
76
-
77
- export default Leasing;
@@ -1,87 +0,0 @@
1
- import React, { useState, useCallback } from 'react';
2
-
3
- import OptionBox from '../OptionBox/index';
4
- import { OptionBoxHeading, OptionBoxContent } from '../OptionBox/wrapper';
5
- import { UtilityTextPrimary } from '../Utility/index';
6
- import { ButtonInline } from '../Button/index';
7
- import { numberSeparator } from '../../utils/formats';
8
- import useLoanCalculation from '../../hooks/useLoan';
9
- import { FinancialOption } from '../../@types/codegen/types';
10
- import LoanModal from './LoanModal';
11
-
12
- interface LoanProps {
13
- id: string;
14
- financialOption: FinancialOption;
15
- }
16
-
17
- const Loan = ({ id, financialOption }: LoanProps) => {
18
- const [modal, setModal] = useState(false);
19
- const toggleModal = useCallback(() => setModal(!modal), [modal]);
20
-
21
- const { data } = useLoanCalculation(
22
- id,
23
- financialOption.duration?.current,
24
- financialOption.downPayment?.current,
25
- financialOption.residual?.current
26
- );
27
-
28
- const interest = data?.loan?.interest;
29
- const duration = data?.loan?.duration?.current;
30
- const monthlyCost = data?.loan?.monthlyCost;
31
-
32
- const logo = financialOption?.logotype || 'https://placehold.it/67x10';
33
-
34
- // Skeleton?
35
- if (
36
- financialOption.loanAmount === undefined ||
37
- financialOption.loanAmount === null ||
38
- interest === undefined ||
39
- duration === undefined ||
40
- monthlyCost === undefined ||
41
- interest === null ||
42
- duration === null ||
43
- monthlyCost === null
44
- ) {
45
- return (
46
- <OptionBox logo={logo} logoAlt="Logotyp">
47
- <OptionBoxHeading>Laddar...</OptionBoxHeading>
48
-
49
- <OptionBoxContent>
50
- <p>Laddar...</p>
51
- </OptionBoxContent>
52
- </OptionBox>
53
- );
54
- }
55
-
56
- return (
57
- <>
58
- {modal && <LoanModal id={id} financialOption={financialOption} onClose={toggleModal} />}
59
- <OptionBox logo={logo} logoAlt="Logotyp">
60
- <>
61
- <OptionBoxHeading>{`${numberSeparator(monthlyCost)} kr/mån*`}</OptionBoxHeading>
62
-
63
- <OptionBoxContent>
64
- <p>
65
- Delbetala{' '}
66
- {financialOption.loanAmount && duration && (
67
- <>
68
- <UtilityTextPrimary>
69
- {numberSeparator(financialOption.loanAmount)} kr
70
- </UtilityTextPrimary>{' '}
71
- i <UtilityTextPrimary>{duration} mån</UtilityTextPrimary>.
72
- </>
73
- )}
74
- </p>
75
-
76
- <p>
77
- {`*Beräknat på ${(interest * 100).toFixed(2)}% ränta. `}
78
- <ButtonInline onClick={toggleModal}>Läs mer</ButtonInline>
79
- </p>
80
- </OptionBoxContent>
81
- </>
82
- </OptionBox>
83
- </>
84
- );
85
- };
86
-
87
- export default Loan;
@@ -1,19 +0,0 @@
1
- import React from 'react';
2
-
3
- import { MediaButtonWrapper } from './wrapper';
4
- import { ButtonSecondary, ButtonContent } from '../Button/index';
5
-
6
- interface MediaButtonProps {
7
- text: string;
8
- onClick: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
9
- }
10
-
11
- const MediaButton = ({ text, onClick }: MediaButtonProps) => (
12
- <MediaButtonWrapper>
13
- <ButtonSecondary onClick={onClick} title={text}>
14
- <ButtonContent>{text}</ButtonContent>
15
- </ButtonSecondary>
16
- </MediaButtonWrapper>
17
- );
18
-
19
- export default MediaButton;
@@ -1,227 +0,0 @@
1
- import React, { useState, useCallback, useRef, useMemo } from 'react';
2
- import Slider from 'react-slick';
3
- import scrollIntoView from 'scroll-into-view-if-needed';
4
-
5
- import {
6
- Wrapper,
7
- SliderWrapper,
8
- Item,
9
- Image,
10
- ArrowLeft,
11
- ArrowRight,
12
- Main,
13
- Alt,
14
- QuickNav,
15
- QuickNavItem,
16
- QuickNavBtn,
17
- QuickNavImg,
18
- EnableNavigationButton,
19
- } from './wrapper';
20
- import { IconChevronLeft, IconChevronRight } from '../Icon/index';
21
- import { ButtonSecondary, ButtonContent } from '../Button/index';
22
- import Lightbox from '../Lightbox/index';
23
- import EmbededVideo from '../Video/EmbededVideo';
24
- import QuickNavEmbeded from '../Video/QuickNavEmbeded';
25
- import Sphere from '../Sphere/Sphere';
26
- import { notEmpty } from '../../utils/formats';
27
- import ThreeSixty from '../ThreeSixty/ThreeSixty';
28
- import { Media } from '../../@types/codegen/types';
29
- import PubSub from '../../utils/pubsub/pubsub';
30
- import { DEFAULT_PLACEHOLDER_IMAGE } from '../../utils/constants';
31
-
32
- interface GalleryProps {
33
- media?: Media[];
34
- placeholderImage?: string;
35
- }
36
-
37
- const sliderSettings = {
38
- dots: false,
39
- arrows: false,
40
- infinite: true,
41
- speed: 300,
42
- slidesToShow: 1,
43
- slidesToScroll: 1,
44
- };
45
-
46
- const Gallery = ({ media, placeholderImage }: GalleryProps) => {
47
- const slider = useRef<Slider>(null);
48
- const quickNavRef = useRef<HTMLUListElement>(null);
49
- const isDragging = useRef(false);
50
- const [index, setIndex] = useState(0);
51
- const [lightbox, setLightbox] = useState(false);
52
- const [navigationDisabled, setNavigationDisabled] = useState(false);
53
-
54
- const beforeChange = useCallback((_: number, newIndex: number) => {
55
- const element = quickNavRef.current?.querySelectorAll('li')?.[newIndex];
56
- if (element) {
57
- scrollIntoView(element, { scrollMode: 'if-needed', block: 'nearest', inline: 'nearest' });
58
- }
59
- setIndex(newIndex);
60
- }, []);
61
-
62
- const onMouseDown = useCallback(() => {
63
- if (isDragging.current) {
64
- isDragging.current = false;
65
- }
66
- }, []);
67
- const onMouseMove = useCallback(() => {
68
- if (!isDragging.current) {
69
- isDragging.current = true;
70
- }
71
- }, []);
72
-
73
- const onClick = useCallback(() => {
74
- PubSub.publish('ImagesClick');
75
- if (!isDragging.current && !lightbox && !!media?.length) {
76
- setLightbox(true);
77
- }
78
- }, [lightbox, media]);
79
-
80
- const nextImage = useCallback((): void => {
81
- if (!slider || !slider.current) {
82
- return;
83
- }
84
- slider.current.slickNext();
85
- }, [slider]);
86
-
87
- const prevImage = useCallback((): void => {
88
- if (!slider || !slider.current) {
89
- return;
90
- }
91
- slider.current.slickPrev();
92
- }, [slider]);
93
-
94
- const goTo = (target: number) => {
95
- if (!slider || !slider.current) {
96
- return;
97
- }
98
- if (slider.current) {
99
- setIndex(target);
100
- slider.current.slickGoTo(target);
101
- }
102
- };
103
-
104
- const onDisableNavigation = () => {
105
- if (!isDragging.current) setNavigationDisabled(true);
106
- };
107
- const onEnableNavigation = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
108
- e.stopPropagation();
109
- isDragging.current = false;
110
- setNavigationDisabled(false);
111
- };
112
-
113
- const onToggleLightbox = useCallback(() => setLightbox(!lightbox), [lightbox]);
114
-
115
- const mediaLength = media?.length || 0;
116
- const placeholder = useMemo(
117
- () => placeholderImage || DEFAULT_PLACEHOLDER_IMAGE,
118
- [placeholderImage]
119
- );
120
-
121
- return (
122
- <>
123
- <Wrapper>
124
- <Main>
125
- <SliderWrapper onMouseDown={onMouseDown} onMouseMove={onMouseMove} onClick={onClick}>
126
- <Slider
127
- {...sliderSettings}
128
- swipe={!navigationDisabled}
129
- touchMove={!navigationDisabled}
130
- swipeToSlide={!navigationDisabled}
131
- ref={slider}
132
- beforeChange={beforeChange}
133
- >
134
- {!!media?.length ? (
135
- media.map((m, i) => (
136
- <Item key={m.files[0].url || i}>
137
- {m.type === 'image' && (
138
- <Image
139
- src={
140
- m.files[0].formats.filter(notEmpty).find((x) => x.format === '1170x')?.url
141
- }
142
- alt={`Bild ${i + 1}`}
143
- />
144
- )}
145
- {m.type === 'threesixty' && (
146
- <ThreeSixty
147
- urls={m.files.map((x) => x.url)}
148
- visible={i === index}
149
- onDisableNavigation={onDisableNavigation}
150
- navigationDisabled={navigationDisabled}
151
- />
152
- )}
153
- {m.type === 'embedded' && <EmbededVideo src={m.files[0].url} index={i + 1} />}
154
- {m.type === 'sphere' && (
155
- <Sphere
156
- visible={i === index}
157
- url={m.files[0].url}
158
- preview={m.files[0].url}
159
- onDisableNavigation={onDisableNavigation}
160
- navigationDisabled={navigationDisabled}
161
- />
162
- )}
163
- </Item>
164
- ))
165
- ) : (
166
- <Item key={placeholder}>
167
- <Image src={placeholder} alt={`Bild 1`} />
168
- </Item>
169
- )}
170
- </Slider>
171
- {navigationDisabled && mediaLength > 1 && (
172
- <EnableNavigationButton>
173
- <ButtonSecondary onClick={onEnableNavigation} title="Stäng">
174
- <ButtonContent>Stäng</ButtonContent>
175
- </ButtonSecondary>
176
- </EnableNavigationButton>
177
- )}
178
- </SliderWrapper>
179
- {!navigationDisabled && mediaLength > 1 && (
180
- <>
181
- <ArrowLeft onClick={prevImage} title="Föregående bild">
182
- <IconChevronLeft block />
183
- </ArrowLeft>
184
- <ArrowRight onClick={nextImage} title="Nästa bild">
185
- <IconChevronRight block />
186
- </ArrowRight>
187
- </>
188
- )}
189
- </Main>
190
- <Alt>
191
- <QuickNav ref={quickNavRef}>
192
- {!!media?.length ? (
193
- media.map((m, i) => {
194
- const src =
195
- m.files[0].formats.filter(notEmpty).find((x) => x.format === '225x150')?.url ||
196
- m.files[0].url;
197
- return (
198
- <QuickNavItem key={src || i} active={index === i}>
199
- <QuickNavBtn onClick={() => goTo(i)} title={`Gå till bild ${i + 1}`}>
200
- {m.type === 'image' && <QuickNavImg src={src} alt={`Bild ${i + 1}`} />}
201
- {m.type === 'threesixty' && <QuickNavImg src={src} alt={`Bild ${i + 1}`} />}
202
- {m.type === 'embedded' && <QuickNavEmbeded src={src} index={i} />}
203
- {m.type === 'sphere' && (
204
- <QuickNavImg src={m.files[0].url} alt={`Bild ${i + 1}`} />
205
- )}
206
- </QuickNavBtn>
207
- </QuickNavItem>
208
- );
209
- })
210
- ) : (
211
- <QuickNavItem key={placeholder} active>
212
- <QuickNavBtn onClick={() => goTo(0)} title={`Gå till bild 0`}>
213
- <QuickNavImg src={placeholder} alt={`Bild 1`} />
214
- </QuickNavBtn>
215
- </QuickNavItem>
216
- )}
217
- </QuickNav>
218
- </Alt>
219
- </Wrapper>
220
- {lightbox && !!media?.length && (
221
- <Lightbox media={media} index={index} onClose={onToggleLightbox} />
222
- )}
223
- </>
224
- );
225
- };
226
-
227
- export default Gallery;