@homefile/components-v2 2.51.2 → 2.51.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.
@@ -786,7 +786,11 @@
786
786
  "logoTitle": "Upload your company logo",
787
787
  "logoHelper": "Upload your logo as a high-resolution .eps file for best quality. If that's not available, .png will work as well, but not preferred.",
788
788
  "uploadMessage": "Drag & Drop your Files or",
789
- "uploadMessageAction": "Choose Files to Upload."
789
+ "uploadMessageAction": "Choose Files to Upload.",
790
+ "uploadMessagePreparing": "Preparing upload...",
791
+ "uploadMessageUploading": "Uploading logo...",
792
+ "uploadMessageFinalizing": "Finalizing logo...",
793
+ "logoPreviewAlt": "Brand logo preview"
790
794
  },
791
795
  "services": {
792
796
  "title": "2. Add Your Services",
@@ -16,5 +16,15 @@
16
16
  "signupBt": "Criar conta",
17
17
  "signin": "Já possui uma conta Homefile?",
18
18
  "signinBt": "Log in"
19
+ },
20
+ "partner": {
21
+ "wizardSteps": {
22
+ "brand": {
23
+ "uploadMessagePreparing": "Preparando upload...",
24
+ "uploadMessageUploading": "Enviando logo...",
25
+ "uploadMessageFinalizing": "Finalizando logo...",
26
+ "logoPreviewAlt": "Prévia da logo da marca"
27
+ }
28
+ }
19
29
  }
20
30
  }
@@ -1,6 +1,2 @@
1
- interface PartnerWizardStepBrandI {
2
- logoUploading?: boolean;
3
- onLogoUpload?: (file: File) => void;
4
- }
5
- export declare const PartnerWizardStepBrand: ({ logoUploading, onLogoUpload, }: PartnerWizardStepBrandI) => import("react/jsx-runtime").JSX.Element;
6
- export {};
1
+ import { PartnerWizardStepBrandI } from '../../../interfaces';
2
+ export declare const PartnerWizardStepBrand: ({ value, onChange, errors, disabled, readOnly, logoUploading, logoUploadState, logoAccept, logoMaxFiles, onLogoUpload, }: PartnerWizardStepBrandI) => import("react/jsx-runtime").JSX.Element;
@@ -1,26 +1,55 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState } from 'react';
2
+ import { useMemo, useState } from 'react';
3
3
  import { t } from 'i18next';
4
4
  import { useDropzone } from 'react-dropzone';
5
5
  import { Box, Flex, Stack, Text } from '@chakra-ui/react';
6
6
  import { DragDropArea, TextInput } from '../../../components';
7
7
  import { PartnerWizardStepLayout } from './PartnerWizardStepLayout';
8
- export const PartnerWizardStepBrand = ({ logoUploading = false, onLogoUpload, }) => {
9
- const [tagline, setTagline] = useState('');
10
- const [websiteUrl, setWebsiteUrl] = useState('');
8
+ const buildDefaultValue = () => ({
9
+ marketingTagline: '',
10
+ websiteUrl: '',
11
+ logoUrl: '',
12
+ });
13
+ export const PartnerWizardStepBrand = ({ value, onChange, errors, disabled = false, readOnly = false, logoUploading = false, logoUploadState, logoAccept = {
14
+ 'image/gif': ['.gif'],
15
+ 'image/jpeg': ['.jpeg', '.jpg'],
16
+ 'image/png': ['.png'],
17
+ 'image/webp': ['.webp'],
18
+ }, logoMaxFiles = 1, onLogoUpload, }) => {
19
+ const [internalValue, setInternalValue] = useState(buildDefaultValue);
20
+ const currentValue = value !== null && value !== void 0 ? value : internalValue;
21
+ const isDisabled = disabled || readOnly;
22
+ const isLogoUploading = logoUploading ||
23
+ logoUploadState === 'requesting_signed_url' ||
24
+ logoUploadState === 'uploading_to_storage' ||
25
+ logoUploadState === 'finalizing';
26
+ const handleValueChange = (next) => {
27
+ var _a;
28
+ if (!value)
29
+ setInternalValue(Object.assign(Object.assign({}, next), { logoUrl: (_a = next.logoUrl) !== null && _a !== void 0 ? _a : '' }));
30
+ onChange === null || onChange === void 0 ? void 0 : onChange(next);
31
+ };
11
32
  const { getInputProps, getRootProps } = useDropzone({
12
- accept: {
13
- 'application/postscript': ['.eps'],
14
- 'image/jpeg': ['.jpeg', '.jpg'],
15
- 'image/png': ['.png'],
16
- },
17
- disabled: logoUploading,
18
- maxFiles: 1,
33
+ accept: logoAccept,
34
+ disabled: isLogoUploading || isDisabled,
35
+ maxFiles: logoMaxFiles,
19
36
  multiple: false,
20
37
  onDrop: (acceptedFiles) => {
21
38
  const selectedFile = acceptedFiles[0];
22
39
  selectedFile && (onLogoUpload === null || onLogoUpload === void 0 ? void 0 : onLogoUpload(selectedFile));
23
40
  },
24
41
  });
25
- return (_jsxs(PartnerWizardStepLayout, { title: t('partner.wizardSteps.brand.title'), subtitle: t('partner.wizardSteps.brand.subtitle'), children: [_jsxs(Flex, { gap: "base", direction: { base: 'column', md: 'row' }, children: [_jsx(Box, { flex: "7", children: _jsx(TextInput, { id: "partnerWizardTagline", placeholder: t('partner.wizardSteps.brand.taglinePlaceholder'), value: tagline, handleChange: (event) => setTagline(event.target.value), hint: t('partner.wizardSteps.brand.taglineHelper') }) }), _jsx(Box, { flex: "5", children: _jsx(TextInput, { id: "partnerWizardWebsite", placeholder: t('partner.wizardSteps.brand.websitePlaceholder'), value: websiteUrl, handleChange: (event) => setWebsiteUrl(event.target.value), hint: t('partner.wizardSteps.brand.websiteHelper') }) })] }), _jsx(Box, { bg: "lightBlue.12", p: "base", borderRadius: "sm", children: _jsxs(Stack, { spacing: "base", children: [_jsx(Text, { children: t('partner.wizardSteps.brand.logoTitle') }), _jsx(Text, { fontFamily: "secondary", fontSize: "sm", children: t('partner.wizardSteps.brand.logoHelper') }), _jsx(DragDropArea, { height: "130px", getInputProps: getInputProps, getRootProps: getRootProps, message: t('partner.wizardSteps.brand.uploadMessage'), message2: t('partner.wizardSteps.brand.uploadMessageAction'), disabled: logoUploading, bg: "transparent" })] }) })] }));
42
+ const uploadMessage = useMemo(() => {
43
+ if (logoUploadState === 'requesting_signed_url') {
44
+ return t('partner.wizardSteps.brand.uploadMessagePreparing');
45
+ }
46
+ if (logoUploadState === 'uploading_to_storage') {
47
+ return t('partner.wizardSteps.brand.uploadMessageUploading');
48
+ }
49
+ if (logoUploadState === 'finalizing') {
50
+ return t('partner.wizardSteps.brand.uploadMessageFinalizing');
51
+ }
52
+ return t('partner.wizardSteps.brand.uploadMessage');
53
+ }, [logoUploadState]);
54
+ return (_jsxs(PartnerWizardStepLayout, { title: t('partner.wizardSteps.brand.title'), subtitle: t('partner.wizardSteps.brand.subtitle'), children: [_jsxs(Flex, { gap: "base", direction: { base: 'column', md: 'row' }, children: [_jsx(Box, { flex: "7", children: _jsx(TextInput, { id: "partnerWizardTagline", placeholder: t('partner.wizardSteps.brand.taglinePlaceholder'), value: currentValue.marketingTagline, handleChange: (event) => handleValueChange(Object.assign(Object.assign({}, currentValue), { marketingTagline: event.target.value })), hint: (errors === null || errors === void 0 ? void 0 : errors.marketingTagline) || t('partner.wizardSteps.brand.taglineHelper'), isDisabled: isDisabled }) }), _jsx(Box, { flex: "5", children: _jsx(TextInput, { id: "partnerWizardWebsite", placeholder: t('partner.wizardSteps.brand.websitePlaceholder'), value: currentValue.websiteUrl, handleChange: (event) => handleValueChange(Object.assign(Object.assign({}, currentValue), { websiteUrl: event.target.value })), hint: (errors === null || errors === void 0 ? void 0 : errors.websiteUrl) || t('partner.wizardSteps.brand.websiteHelper'), isDisabled: isDisabled }) })] }), _jsx(Box, { bg: "lightBlue.12", p: "base", borderRadius: "sm", children: _jsxs(Stack, { spacing: "base", children: [_jsx(Text, { children: t('partner.wizardSteps.brand.logoTitle') }), _jsx(Text, { fontFamily: "secondary", fontSize: "sm", children: (errors === null || errors === void 0 ? void 0 : errors.logo) || t('partner.wizardSteps.brand.logoHelper') }), _jsx(DragDropArea, { height: "130px", getInputProps: getInputProps, getRootProps: getRootProps, message: uploadMessage, message2: t('partner.wizardSteps.brand.uploadMessageAction'), disabled: isLogoUploading || isDisabled, bg: "transparent" }), currentValue.logoUrl ? (_jsx(Box, { children: _jsx("img", { src: currentValue.logoUrl, alt: t('partner.wizardSteps.brand.logoPreviewAlt'), style: { maxHeight: '64px' } }) })) : null] }) })] }));
26
55
  };
@@ -0,0 +1,24 @@
1
+ export type PartnerWizardStepBrandValue = {
2
+ websiteUrl: string;
3
+ marketingTagline: string;
4
+ logoUrl?: string;
5
+ };
6
+ export type PartnerWizardStepBrandErrors = {
7
+ websiteUrl?: string;
8
+ marketingTagline?: string;
9
+ logo?: string;
10
+ };
11
+ export type PartnerWizardStepBrandLogoUploadState = 'idle' | 'requesting_signed_url' | 'uploading_to_storage' | 'finalizing' | 'done' | 'error';
12
+ export type PartnerWizardStepBrandI = {
13
+ value?: PartnerWizardStepBrandValue;
14
+ onChange?: (next: PartnerWizardStepBrandValue) => void;
15
+ errors?: PartnerWizardStepBrandErrors;
16
+ disabled?: boolean;
17
+ readOnly?: boolean;
18
+ logoUploading?: boolean;
19
+ logoUploadState?: PartnerWizardStepBrandLogoUploadState;
20
+ logoAccept?: Record<string, string[]>;
21
+ logoMaxFiles?: number;
22
+ onLogoUpload?: (file: File) => void | Promise<void>;
23
+ onLogoRemove?: () => void;
24
+ };
@@ -19,3 +19,4 @@ export * from './PartnerServiceTicketsToolbar.interface';
19
19
  export * from './ShortPartnerTile.interface';
20
20
  export * from './PartnerWizardSteps.interface';
21
21
  export * from './PartnerWizardStepServicesSelect.interface';
22
+ export * from './PartnerWizardStepBrand.interface';
@@ -19,3 +19,4 @@ export * from './PartnerServiceTicketsToolbar.interface';
19
19
  export * from './ShortPartnerTile.interface';
20
20
  export * from './PartnerWizardSteps.interface';
21
21
  export * from './PartnerWizardStepServicesSelect.interface';
22
+ export * from './PartnerWizardStepBrand.interface';
@@ -4,4 +4,14 @@ export default _default;
4
4
  export declare const Brand: (args: {
5
5
  logoUploading?: boolean;
6
6
  onLogoUpload?: (file: File) => void;
7
+ value?: {
8
+ websiteUrl: string;
9
+ marketingTagline: string;
10
+ logoUrl?: string;
11
+ };
12
+ onChange?: (next: {
13
+ websiteUrl: string;
14
+ marketingTagline: string;
15
+ logoUrl?: string;
16
+ }) => void;
7
17
  }) => import("react/jsx-runtime").JSX.Element;
@@ -8,6 +8,12 @@ export default {
8
8
  args: {
9
9
  logoUploading: false,
10
10
  onLogoUpload: action('onLogoUpload'),
11
+ value: {
12
+ websiteUrl: 'https://poolie.com',
13
+ marketingTagline: 'Pool Experts',
14
+ logoUrl: '',
15
+ },
16
+ onChange: action('onChange'),
11
17
  },
12
18
  decorators: [
13
19
  (Story) => (_jsx(Box, { maxW: "960px", mx: "auto", p: "base", children: _jsx(Story, {}) })),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.51.2",
3
+ "version": "2.51.3",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",