@homefile/components-v2 2.51.0 → 2.51.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.
@@ -1 +1,2 @@
1
- export declare const PartnerWizardStepServicesSelect: () => import("react/jsx-runtime").JSX.Element;
1
+ import { PartnerWizardStepServicesSelectI } from '../../../interfaces';
2
+ export declare const PartnerWizardStepServicesSelect: ({ value, onChange, isDisabled, categoryError, serviceError, }: PartnerWizardStepServicesSelectI) => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,4 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState } from 'react';
3
2
  import { t } from 'i18next';
4
3
  import { Stack, Text } from '@chakra-ui/react';
5
4
  import { SelectInput } from '../../../components';
@@ -49,18 +48,16 @@ const getOptionLabel = (options, selectedId) => {
49
48
  return '';
50
49
  return (_b = (_a = options.find((option) => option._id === selectedId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '';
51
50
  };
52
- export const PartnerWizardStepServicesSelect = () => {
53
- const [selectedService, setSelectedService] = useState('');
54
- const [selectedCategory, setSelectedCategory] = useState('');
51
+ export const PartnerWizardStepServicesSelect = ({ value, onChange, isDisabled = false, categoryError, serviceError, }) => {
55
52
  const categoryOptions = buildOptions('category', CATEGORY_IDS);
56
53
  const serviceOptions = buildOptions('service', SERVICE_IDS);
57
- return (_jsxs(PartnerWizardStepLayout, { title: t(`${STEP_KEY}.singleTitle`), subtitle: t(`${STEP_KEY}.singleSubtitle`), contentSpacing: "3", contentFullWidth: true, children: [_jsxs(Stack, { spacing: "1", children: [_jsx(Text, { fontSize: "xs", mb: "1", textTransform: "uppercase", children: t(`${STEP_KEY}.singleCategoryLabel`) }), _jsx(SelectInput, { items: categoryOptions, initialValue: getOptionLabel(categoryOptions, selectedCategory), placeholder: t(`${STEP_KEY}.singleCategoryPlaceholder`), handleClick: (value) => {
58
- if (typeof value === 'string')
54
+ return (_jsxs(PartnerWizardStepLayout, { title: t(`${STEP_KEY}.singleTitle`), subtitle: t(`${STEP_KEY}.singleSubtitle`), contentSpacing: "3", contentFullWidth: true, children: [_jsxs(Stack, { spacing: "1", children: [_jsx(Text, { fontSize: "xs", mb: "1", textTransform: "uppercase", children: t(`${STEP_KEY}.singleCategoryLabel`) }), _jsx(SelectInput, { items: categoryOptions, initialValue: getOptionLabel(categoryOptions, value.category), placeholder: t(`${STEP_KEY}.singleCategoryPlaceholder`), isDisabled: isDisabled, handleClick: (selectedOption) => {
55
+ if (typeof selectedOption === 'string')
59
56
  return;
60
- setSelectedCategory(String(value._id));
61
- }, width: "100%" })] }), _jsxs(Stack, { spacing: "1", children: [_jsx(Text, { fontSize: "xs", mb: "1", textTransform: "uppercase", children: t(`${STEP_KEY}.singleServiceLabel`) }), _jsx(SelectInput, { items: serviceOptions, initialValue: getOptionLabel(serviceOptions, selectedService), placeholder: t(`${STEP_KEY}.singleServicePlaceholder`), handleClick: (value) => {
62
- if (typeof value === 'string')
57
+ onChange(Object.assign(Object.assign({}, value), { category: String(selectedOption._id) }));
58
+ }, width: "100%" }), categoryError && _jsx(Text, { variant: "error", children: categoryError })] }), _jsxs(Stack, { spacing: "1", children: [_jsx(Text, { fontSize: "xs", mb: "1", textTransform: "uppercase", children: t(`${STEP_KEY}.singleServiceLabel`) }), _jsx(SelectInput, { items: serviceOptions, initialValue: getOptionLabel(serviceOptions, value.service), placeholder: t(`${STEP_KEY}.singleServicePlaceholder`), isDisabled: isDisabled, handleClick: (selectedOption) => {
59
+ if (typeof selectedOption === 'string')
63
60
  return;
64
- setSelectedService(String(value._id));
65
- }, width: "100%" })] })] }));
61
+ onChange(Object.assign(Object.assign({}, value), { service: String(selectedOption._id) }));
62
+ }, width: "100%" }), serviceError && _jsx(Text, { variant: "error", children: serviceError })] })] }));
66
63
  };
@@ -0,0 +1,11 @@
1
+ export type ServicesSelectValue = {
2
+ category: string;
3
+ service: string;
4
+ };
5
+ export type PartnerWizardStepServicesSelectI = {
6
+ value: ServicesSelectValue;
7
+ onChange: (next: ServicesSelectValue) => void;
8
+ isDisabled?: boolean;
9
+ categoryError?: string;
10
+ serviceError?: string;
11
+ };
@@ -18,3 +18,4 @@ export * from './PartnerServiceTicketsWrapper.interface';
18
18
  export * from './PartnerServiceTicketsToolbar.interface';
19
19
  export * from './ShortPartnerTile.interface';
20
20
  export * from './PartnerWizardSteps.interface';
21
+ export * from './PartnerWizardStepServicesSelect.interface';
@@ -18,3 +18,4 @@ export * from './PartnerServiceTicketsWrapper.interface';
18
18
  export * from './PartnerServiceTicketsToolbar.interface';
19
19
  export * from './ShortPartnerTile.interface';
20
20
  export * from './PartnerWizardSteps.interface';
21
+ export * from './PartnerWizardStepServicesSelect.interface';
@@ -10,7 +10,16 @@ export default {
10
10
  ],
11
11
  };
12
12
  export const Services = () => _jsx(PartnerWizardStepServices, {});
13
- export const ServicesSelect = () => _jsx(PartnerWizardStepServicesSelect, {});
13
+ export const ServicesSelect = () => {
14
+ const [value, setValue] = useState({
15
+ category: '',
16
+ service: '',
17
+ });
18
+ return (_jsx(PartnerWizardStepServicesSelect, { value: value, onChange: (next) => {
19
+ setValue(next);
20
+ action('onServicesSelectChange')(next);
21
+ } }));
22
+ };
14
23
  export const ServiceZones = () => _jsx(PartnerWizardStepServiceZones, {});
15
24
  export const Cta = () => _jsx(PartnerWizardStepCta, {});
16
25
  export const Social = () => _jsx(PartnerWizardStepSocial, {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.51.0",
3
+ "version": "2.51.1",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",