@selfcommunity/react-ui 0.11.0-mui7.26 → 0.11.0-mui7.27
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.
- package/lib/cjs/components/EventLocationWidget/EventLocationWidget.js +4 -9
- package/lib/cjs/components/EventLocationWidget/EventMap.d.ts +8 -0
- package/lib/cjs/components/EventLocationWidget/EventMap.js +22 -0
- package/lib/cjs/components/LocationAutocomplete/LocationAutocomplete.js +10 -9
- package/lib/cjs/components/UserProfileEdit/Section/PublicInfo.js +3 -15
- package/lib/esm/components/EventLocationWidget/EventLocationWidget.js +5 -10
- package/lib/esm/components/EventLocationWidget/EventMap.d.ts +8 -0
- package/lib/esm/components/EventLocationWidget/EventMap.js +19 -0
- package/lib/esm/components/LocationAutocomplete/LocationAutocomplete.js +2 -1
- package/lib/esm/components/UserProfileEdit/Section/PublicInfo.js +6 -18
- package/lib/umd/484.js +1 -1
- package/lib/umd/react-ui.js +1 -1
- package/package.json +11 -11
|
@@ -14,6 +14,7 @@ const string_1 = require("../../utils/string");
|
|
|
14
14
|
const Widget_1 = tslib_1.__importDefault(require("../Widget"));
|
|
15
15
|
const constants_1 = require("./constants");
|
|
16
16
|
const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
|
|
17
|
+
const EventMap_1 = tslib_1.__importDefault(require("./EventMap"));
|
|
17
18
|
const classes = {
|
|
18
19
|
root: `${constants_1.PREFIX}-root`,
|
|
19
20
|
title: `${constants_1.PREFIX}-title`,
|
|
@@ -66,25 +67,19 @@ function EventLocationWidget(inProps) {
|
|
|
66
67
|
// STATE
|
|
67
68
|
const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
|
|
68
69
|
// HOOKS
|
|
69
|
-
const {
|
|
70
|
+
const { geocodingApiKey, libraries } = (0, react_core_1.useSCGoogleApiLoader)();
|
|
70
71
|
if (!geocodingApiKey || (scEvent === null || scEvent === void 0 ? void 0 : scEvent.location) === types_1.SCEventLocationType.ONLINE) {
|
|
71
72
|
return (0, jsx_runtime_1.jsx)(HiddenPlaceholder_1.default, {});
|
|
72
73
|
}
|
|
73
74
|
/**
|
|
74
75
|
* Loading event
|
|
75
76
|
*/
|
|
76
|
-
if (!
|
|
77
|
+
if (!scEvent) {
|
|
77
78
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
78
79
|
}
|
|
79
80
|
/**
|
|
80
81
|
* Renders root object
|
|
81
82
|
*/
|
|
82
|
-
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h4", className: classes.title, gutterBottom: true }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventLocationWidget.title", defaultMessage: "ui.eventLocationWidget.title" }) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.map }, { children: (0, jsx_runtime_1.jsx)(react_google_maps_1.APIProvider, Object.assign({ apiKey: geocodingApiKey, libraries: libraries }, { children: (0, jsx_runtime_1.jsx)(
|
|
83
|
-
lat: scEvent.geolocation_lat,
|
|
84
|
-
lng: scEvent.geolocation_lng
|
|
85
|
-
}, zoom: 15, fullscreenControl: false, mapTypeControl: false, streetViewControl: false, zoomControl: false }, { children: (0, jsx_runtime_1.jsx)(react_google_maps_1.Marker, { position: {
|
|
86
|
-
lat: scEvent.geolocation_lat,
|
|
87
|
-
lng: scEvent.geolocation_lng
|
|
88
|
-
} }) })) })) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h4", className: classes.locationTitle }, { children: (0, string_1.formatEventLocationGeolocation)(scEvent.geolocation, true) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1", className: classes.address }, { children: (0, string_1.formatEventLocationGeolocation)(scEvent.geolocation) }))] }) })));
|
|
83
|
+
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h4", className: classes.title, gutterBottom: true }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventLocationWidget.title", defaultMessage: "ui.eventLocationWidget.title" }) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.map }, { children: (0, jsx_runtime_1.jsx)(react_google_maps_1.APIProvider, Object.assign({ apiKey: geocodingApiKey, libraries: libraries }, { children: (0, jsx_runtime_1.jsx)(EventMap_1.default, { event: scEvent, className: classes.map }) })) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h4", className: classes.locationTitle }, { children: (0, string_1.formatEventLocationGeolocation)(scEvent.geolocation, true) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1", className: classes.address }, { children: (0, string_1.formatEventLocationGeolocation)(scEvent.geolocation) }))] }) })));
|
|
89
84
|
}
|
|
90
85
|
exports.default = EventLocationWidget;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SCEventType } from '@selfcommunity/types';
|
|
2
|
+
import { HTMLAttributes } from 'react';
|
|
3
|
+
interface EventMapProps {
|
|
4
|
+
event: SCEventType;
|
|
5
|
+
className?: HTMLAttributes<HTMLDivElement>['className'];
|
|
6
|
+
}
|
|
7
|
+
export default function EventMap(props: EventMapProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const react_core_1 = require("@selfcommunity/react-core");
|
|
5
|
+
const react_google_maps_1 = require("@vis.gl/react-google-maps");
|
|
6
|
+
function EventMap(props) {
|
|
7
|
+
// PROPS
|
|
8
|
+
const { event, className } = props;
|
|
9
|
+
// HOOKS
|
|
10
|
+
const { isLoaded } = (0, react_core_1.useSCGoogleApiLoader)();
|
|
11
|
+
if (!isLoaded) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)(react_google_maps_1.Map, Object.assign({ className: className, center: {
|
|
15
|
+
lat: event.geolocation_lat,
|
|
16
|
+
lng: event.geolocation_lng
|
|
17
|
+
}, zoom: 15, fullscreenControl: false, mapTypeControl: false, streetViewControl: false, zoomControl: false }, { children: (0, jsx_runtime_1.jsx)(react_google_maps_1.Marker, { position: {
|
|
18
|
+
lat: event.geolocation_lat,
|
|
19
|
+
lng: event.geolocation_lng
|
|
20
|
+
} }) })));
|
|
21
|
+
}
|
|
22
|
+
exports.default = EventMap;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
4
|
const react_1 = require("react");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_2 = require("react");
|
|
6
7
|
const react_intl_1 = require("react-intl");
|
|
7
8
|
const material_1 = require("@mui/material");
|
|
8
9
|
const api_services_1 = require("@selfcommunity/api-services");
|
|
@@ -53,10 +54,10 @@ function LocationAutocomplete(inProps) {
|
|
|
53
54
|
label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.locationAutocomplete.label", defaultMessage: "ui.composer.locations.label" })
|
|
54
55
|
} } = props, rest = tslib_1.__rest(props, ["defaultValue", "disabled", "onChange", "TextFieldProps"]);
|
|
55
56
|
// State
|
|
56
|
-
const [isLoading, setIsLoading] = (0,
|
|
57
|
-
const [locations, setLocations] = (0,
|
|
58
|
-
const [value, setValue] = (0,
|
|
59
|
-
const [search, setSearch] = (0,
|
|
57
|
+
const [isLoading, setIsLoading] = (0, react_2.useState)(false);
|
|
58
|
+
const [locations, setLocations] = (0, react_2.useState)([]);
|
|
59
|
+
const [value, setValue] = (0, react_2.useState)(defaultValue);
|
|
60
|
+
const [search, setSearch] = (0, react_2.useState)('');
|
|
60
61
|
const load = (offset = 0, limit = 20) => {
|
|
61
62
|
api_services_1.http
|
|
62
63
|
.request({
|
|
@@ -74,12 +75,12 @@ function LocationAutocomplete(inProps) {
|
|
|
74
75
|
.then(() => setIsLoading(false));
|
|
75
76
|
};
|
|
76
77
|
// Component update
|
|
77
|
-
(0,
|
|
78
|
+
(0, react_2.useEffect)(() => {
|
|
78
79
|
if (!isLoading && search.trim().length > 0) {
|
|
79
80
|
load();
|
|
80
81
|
}
|
|
81
82
|
}, [search]);
|
|
82
|
-
(0,
|
|
83
|
+
(0, react_2.useEffect)(() => {
|
|
83
84
|
if (value) {
|
|
84
85
|
onChange && onChange(value);
|
|
85
86
|
}
|
|
@@ -93,7 +94,7 @@ function LocationAutocomplete(inProps) {
|
|
|
93
94
|
setSearch(_search);
|
|
94
95
|
};
|
|
95
96
|
// Render
|
|
96
|
-
const options = (0,
|
|
97
|
+
const options = (0, react_2.useMemo)(() => {
|
|
97
98
|
if (!value || typeof value === 'string' || locations.find((loc) => value.lat === loc.lat && value.lng === loc.lng)) {
|
|
98
99
|
return locations;
|
|
99
100
|
}
|
|
@@ -106,7 +107,7 @@ function LocationAutocomplete(inProps) {
|
|
|
106
107
|
}, renderOption: (props, option, { inputValue }) => {
|
|
107
108
|
const matches = (0, match_1.default)(option.full_address, inputValue);
|
|
108
109
|
const parts = (0, parse_1.default)(option.full_address, matches);
|
|
109
|
-
return ((0,
|
|
110
|
+
return ((0, react_1.createElement)("li", Object.assign({}, props, { key: `${option.lat}_${option.lng}`, style: { whiteSpace: 'break-spaces' } }), parts.map((part, index) => part.highlight ? ((0, jsx_runtime_1.jsx)("span", Object.assign({ style: { fontWeight: 700 } }, { children: part.text }), index)) : (part.text))));
|
|
110
111
|
} }, rest)));
|
|
111
112
|
}
|
|
112
113
|
exports.default = LocationAutocomplete;
|
|
@@ -69,8 +69,6 @@ function PublicInfo(props) {
|
|
|
69
69
|
return null;
|
|
70
70
|
}, [scPreferences.preferences]);
|
|
71
71
|
// STATE
|
|
72
|
-
const theme = (0, material_1.useTheme)();
|
|
73
|
-
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
|
|
74
72
|
const [user, setUser] = (0, react_1.useState)(null);
|
|
75
73
|
const [error, setError] = (0, react_1.useState)({});
|
|
76
74
|
const [editing, setEditing] = (0, react_1.useState)([]);
|
|
@@ -161,7 +159,7 @@ function PublicInfo(props) {
|
|
|
161
159
|
return ((0, jsx_runtime_1.jsx)(x_date_pickers_1.LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns_1.AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? it_1.it : en_US_1.enUS }, { children: (0, jsx_runtime_1.jsx)(x_date_pickers_1.DatePicker, { label: intl.formatMessage({
|
|
162
160
|
id: `ui.userInfo.${(0, utils_1.camelCase)(field)}`,
|
|
163
161
|
defaultMessage: `ui.userInfo.${field}`
|
|
164
|
-
}), defaultValue: user[field] ?
|
|
162
|
+
}), defaultValue: user[field] ? new Date(user[field]) : null, minDate: DATEPICKER_MINDATE, onChange: (newValue) => {
|
|
165
163
|
const u = user;
|
|
166
164
|
const field = types_1.SCUserProfileFields.DATE_OF_BIRTH;
|
|
167
165
|
const camelField = (0, utils_1.camelCase)(field);
|
|
@@ -184,12 +182,7 @@ function PublicInfo(props) {
|
|
|
184
182
|
setUser(u);
|
|
185
183
|
setEditing([...editing, field]);
|
|
186
184
|
}, disableFuture: true, disabled: isSaving, enableAccessibleFieldDOMStructure: false, slots: {
|
|
187
|
-
|
|
188
|
-
var _a, _b, _c;
|
|
189
|
-
return ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { slotProps: {
|
|
190
|
-
input: Object.assign(Object.assign({}, (_a = params.slotProps) === null || _a === void 0 ? void 0 : _a.input), { endAdornment: ((0, jsx_runtime_1.jsxs)(material_1.InputAdornment, Object.assign({ position: "end" }, { children: [(_c = (_b = params.slotProps) === null || _b === void 0 ? void 0 : _b.input) === null || _c === void 0 ? void 0 : _c.endAdornment, isSaving && (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 10 })] }))) })
|
|
191
|
-
} })));
|
|
192
|
-
}
|
|
185
|
+
openPickerButton: (params) => ((0, jsx_runtime_1.jsxs)(material_1.IconButton, Object.assign({}, params, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "CalendarIcon" }), isSaving && (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 10 })] })))
|
|
193
186
|
},
|
|
194
187
|
// onAccept={isMobile ? handleSave(SCUserProfileFields.DATE_OF_BIRTH) : null}
|
|
195
188
|
slotProps: {
|
|
@@ -197,12 +190,7 @@ function PublicInfo(props) {
|
|
|
197
190
|
className: classes.field,
|
|
198
191
|
fullWidth: true,
|
|
199
192
|
variant: 'outlined',
|
|
200
|
-
helperText: _error || null
|
|
201
|
-
slotProps: {
|
|
202
|
-
input: {
|
|
203
|
-
endAdornment: isMobile && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ disabled: !isEditing }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "CalendarIcon" }) })), isSaving && (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 10 })] }))
|
|
204
|
-
}
|
|
205
|
-
}
|
|
193
|
+
helperText: _error || null
|
|
206
194
|
}
|
|
207
195
|
} }) }), field));
|
|
208
196
|
case types_1.SCUserProfileFields.BIO:
|
|
@@ -2,7 +2,7 @@ import { __rest } from "tslib";
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Box, CardContent, Typography, styled } from '@mui/material';
|
|
4
4
|
import { useThemeProps } from '@mui/system';
|
|
5
|
-
import { APIProvider
|
|
5
|
+
import { APIProvider } from '@vis.gl/react-google-maps';
|
|
6
6
|
import { useSCGoogleApiLoader, useSCFetchEvent } from '@selfcommunity/react-core';
|
|
7
7
|
import { SCEventLocationType } from '@selfcommunity/types';
|
|
8
8
|
import classNames from 'classnames';
|
|
@@ -12,6 +12,7 @@ import { formatEventLocationGeolocation } from '../../utils/string';
|
|
|
12
12
|
import Widget from '../Widget';
|
|
13
13
|
import { PREFIX } from './constants';
|
|
14
14
|
import EventLocationWidgetSkeleton from './Skeleton';
|
|
15
|
+
import EventMap from './EventMap';
|
|
15
16
|
const classes = {
|
|
16
17
|
root: `${PREFIX}-root`,
|
|
17
18
|
title: `${PREFIX}-title`,
|
|
@@ -64,24 +65,18 @@ export default function EventLocationWidget(inProps) {
|
|
|
64
65
|
// STATE
|
|
65
66
|
const { scEvent } = useSCFetchEvent({ id: eventId, event });
|
|
66
67
|
// HOOKS
|
|
67
|
-
const {
|
|
68
|
+
const { geocodingApiKey, libraries } = useSCGoogleApiLoader();
|
|
68
69
|
if (!geocodingApiKey || (scEvent === null || scEvent === void 0 ? void 0 : scEvent.location) === SCEventLocationType.ONLINE) {
|
|
69
70
|
return _jsx(HiddenPlaceholder, {});
|
|
70
71
|
}
|
|
71
72
|
/**
|
|
72
73
|
* Loading event
|
|
73
74
|
*/
|
|
74
|
-
if (!
|
|
75
|
+
if (!scEvent) {
|
|
75
76
|
return _jsx(EventLocationWidgetSkeleton, {});
|
|
76
77
|
}
|
|
77
78
|
/**
|
|
78
79
|
* Renders root object
|
|
79
80
|
*/
|
|
80
|
-
return (_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: _jsxs(CardContent, { children: [_jsx(Typography, Object.assign({ variant: "h4", className: classes.title, gutterBottom: true }, { children: _jsx(FormattedMessage, { id: "ui.eventLocationWidget.title", defaultMessage: "ui.eventLocationWidget.title" }) })), _jsx(Box, Object.assign({ className: classes.map }, { children: _jsx(APIProvider, Object.assign({ apiKey: geocodingApiKey, libraries: libraries }, { children: _jsx(
|
|
81
|
-
lat: scEvent.geolocation_lat,
|
|
82
|
-
lng: scEvent.geolocation_lng
|
|
83
|
-
}, zoom: 15, fullscreenControl: false, mapTypeControl: false, streetViewControl: false, zoomControl: false }, { children: _jsx(Marker, { position: {
|
|
84
|
-
lat: scEvent.geolocation_lat,
|
|
85
|
-
lng: scEvent.geolocation_lng
|
|
86
|
-
} }) })) })) })), _jsx(Typography, Object.assign({ variant: "h4", className: classes.locationTitle }, { children: formatEventLocationGeolocation(scEvent.geolocation, true) })), _jsx(Typography, Object.assign({ variant: "body1", className: classes.address }, { children: formatEventLocationGeolocation(scEvent.geolocation) }))] }) })));
|
|
81
|
+
return (_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: _jsxs(CardContent, { children: [_jsx(Typography, Object.assign({ variant: "h4", className: classes.title, gutterBottom: true }, { children: _jsx(FormattedMessage, { id: "ui.eventLocationWidget.title", defaultMessage: "ui.eventLocationWidget.title" }) })), _jsx(Box, Object.assign({ className: classes.map }, { children: _jsx(APIProvider, Object.assign({ apiKey: geocodingApiKey, libraries: libraries }, { children: _jsx(EventMap, { event: scEvent, className: classes.map }) })) })), _jsx(Typography, Object.assign({ variant: "h4", className: classes.locationTitle }, { children: formatEventLocationGeolocation(scEvent.geolocation, true) })), _jsx(Typography, Object.assign({ variant: "body1", className: classes.address }, { children: formatEventLocationGeolocation(scEvent.geolocation) }))] }) })));
|
|
87
82
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SCEventType } from '@selfcommunity/types';
|
|
2
|
+
import { HTMLAttributes } from 'react';
|
|
3
|
+
interface EventMapProps {
|
|
4
|
+
event: SCEventType;
|
|
5
|
+
className?: HTMLAttributes<HTMLDivElement>['className'];
|
|
6
|
+
}
|
|
7
|
+
export default function EventMap(props: EventMapProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useSCGoogleApiLoader } from '@selfcommunity/react-core';
|
|
3
|
+
import { Map, Marker } from '@vis.gl/react-google-maps';
|
|
4
|
+
export default function EventMap(props) {
|
|
5
|
+
// PROPS
|
|
6
|
+
const { event, className } = props;
|
|
7
|
+
// HOOKS
|
|
8
|
+
const { isLoaded } = useSCGoogleApiLoader();
|
|
9
|
+
if (!isLoaded) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return (_jsx(Map, Object.assign({ className: className, center: {
|
|
13
|
+
lat: event.geolocation_lat,
|
|
14
|
+
lng: event.geolocation_lng
|
|
15
|
+
}, zoom: 15, fullscreenControl: false, mapTypeControl: false, streetViewControl: false, zoomControl: false }, { children: _jsx(Marker, { position: {
|
|
16
|
+
lat: event.geolocation_lat,
|
|
17
|
+
lng: event.geolocation_lng
|
|
18
|
+
} }) })));
|
|
19
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
+
import { createElement as _createElement } from "react";
|
|
2
3
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
4
|
import { useEffect, useMemo, useState } from 'react';
|
|
4
5
|
import { FormattedMessage } from 'react-intl';
|
|
@@ -104,6 +105,6 @@ export default function LocationAutocomplete(inProps) {
|
|
|
104
105
|
}, renderOption: (props, option, { inputValue }) => {
|
|
105
106
|
const matches = match(option.full_address, inputValue);
|
|
106
107
|
const parts = parse(option.full_address, matches);
|
|
107
|
-
return (
|
|
108
|
+
return (_createElement("li", Object.assign({}, props, { key: `${option.lat}_${option.lng}`, style: { whiteSpace: 'break-spaces' } }), parts.map((part, index) => part.highlight ? (_jsx("span", Object.assign({ style: { fontWeight: 700 } }, { children: part.text }), index)) : (part.text))));
|
|
108
109
|
} }, rest)));
|
|
109
110
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useMemo, useState } from 'react';
|
|
4
|
-
import { Box, CircularProgress, IconButton, InputAdornment, MenuItem, TextField,
|
|
4
|
+
import { Box, CircularProgress, IconButton, InputAdornment, MenuItem, TextField, Icon, styled, Button } from '@mui/material';
|
|
5
5
|
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|
6
6
|
import { Endpoints, formatHttpErrorCode, http } from '@selfcommunity/api-services';
|
|
7
7
|
import { camelCase, Logger } from '@selfcommunity/utils';
|
|
@@ -15,7 +15,7 @@ import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect';
|
|
|
15
15
|
import { SCUserProfileFields } from '../../../types';
|
|
16
16
|
import MetadataField from '../../../shared/MetadataField';
|
|
17
17
|
import { SCOPE_SC_UI } from '../../../constants/Errors';
|
|
18
|
-
import { format, isBefore, isValid,
|
|
18
|
+
import { format, isBefore, isValid, startOfHour } from 'date-fns';
|
|
19
19
|
import { it } from 'date-fns/locale/it';
|
|
20
20
|
import { enUS } from 'date-fns/locale/en-US';
|
|
21
21
|
import { useSnackbar } from 'notistack';
|
|
@@ -67,8 +67,6 @@ export default function PublicInfo(props) {
|
|
|
67
67
|
return null;
|
|
68
68
|
}, [scPreferences.preferences]);
|
|
69
69
|
// STATE
|
|
70
|
-
const theme = useTheme();
|
|
71
|
-
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
72
70
|
const [user, setUser] = useState(null);
|
|
73
71
|
const [error, setError] = useState({});
|
|
74
72
|
const [editing, setEditing] = useState([]);
|
|
@@ -159,7 +157,7 @@ export default function PublicInfo(props) {
|
|
|
159
157
|
return (_jsx(LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? it : enUS }, { children: _jsx(DatePicker, { label: intl.formatMessage({
|
|
160
158
|
id: `ui.userInfo.${camelCase(field)}`,
|
|
161
159
|
defaultMessage: `ui.userInfo.${field}`
|
|
162
|
-
}), defaultValue: user[field] ?
|
|
160
|
+
}), defaultValue: user[field] ? new Date(user[field]) : null, minDate: DATEPICKER_MINDATE, onChange: (newValue) => {
|
|
163
161
|
const u = user;
|
|
164
162
|
const field = SCUserProfileFields.DATE_OF_BIRTH;
|
|
165
163
|
const camelField = camelCase(field);
|
|
@@ -182,12 +180,7 @@ export default function PublicInfo(props) {
|
|
|
182
180
|
setUser(u);
|
|
183
181
|
setEditing([...editing, field]);
|
|
184
182
|
}, disableFuture: true, disabled: isSaving, enableAccessibleFieldDOMStructure: false, slots: {
|
|
185
|
-
|
|
186
|
-
var _a, _b, _c;
|
|
187
|
-
return (_jsx(TextField, Object.assign({}, params, { slotProps: {
|
|
188
|
-
input: Object.assign(Object.assign({}, (_a = params.slotProps) === null || _a === void 0 ? void 0 : _a.input), { endAdornment: (_jsxs(InputAdornment, Object.assign({ position: "end" }, { children: [(_c = (_b = params.slotProps) === null || _b === void 0 ? void 0 : _b.input) === null || _c === void 0 ? void 0 : _c.endAdornment, isSaving && _jsx(CircularProgress, { size: 10 })] }))) })
|
|
189
|
-
} })));
|
|
190
|
-
}
|
|
183
|
+
openPickerButton: (params) => (_jsxs(IconButton, Object.assign({}, params, { children: [_jsx(Icon, { children: "CalendarIcon" }), isSaving && _jsx(CircularProgress, { size: 10 })] })))
|
|
191
184
|
},
|
|
192
185
|
// onAccept={isMobile ? handleSave(SCUserProfileFields.DATE_OF_BIRTH) : null}
|
|
193
186
|
slotProps: {
|
|
@@ -195,12 +188,7 @@ export default function PublicInfo(props) {
|
|
|
195
188
|
className: classes.field,
|
|
196
189
|
fullWidth: true,
|
|
197
190
|
variant: 'outlined',
|
|
198
|
-
helperText: _error || null
|
|
199
|
-
slotProps: {
|
|
200
|
-
input: {
|
|
201
|
-
endAdornment: isMobile && (_jsxs(_Fragment, { children: [_jsx(IconButton, Object.assign({ disabled: !isEditing }, { children: _jsx(Icon, { children: "CalendarIcon" }) })), isSaving && _jsx(CircularProgress, { size: 10 })] }))
|
|
202
|
-
}
|
|
203
|
-
}
|
|
191
|
+
helperText: _error || null
|
|
204
192
|
}
|
|
205
193
|
} }) }), field));
|
|
206
194
|
case SCUserProfileFields.BIO:
|