Skip to content

Commit 740e865

Browse files
authored
fix(users): set preferred notification frequency on signup (#1630)
* fix(local-auth-helpers): set user notification frequency from request body
1 parent 0af2c75 commit 740e865

File tree

2 files changed

+14
-34
lines changed

2 files changed

+14
-34
lines changed

src/containers/UserEdit/index.jsx

+12-33
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ import Dialog from "@material-ui/core/Dialog";
44
import DialogActions from "@material-ui/core/DialogActions";
55
import DialogContent from "@material-ui/core/DialogContent";
66
import DialogTitle from "@material-ui/core/DialogTitle";
7-
import InputLabel from "@material-ui/core/InputLabel";
8-
import MenuItem from "@material-ui/core/MenuItem";
9-
import Select from "@material-ui/core/Select";
107
import { css, StyleSheet } from "aphrodite";
118
import PropTypes from "prop-types";
129
import queryString from "query-string";
@@ -170,15 +167,6 @@ class UserEdit extends React.Component {
170167
this.setState({ changePasswordDialog: false, successDialog: false });
171168
};
172169

173-
handleNotificationFrequencyChange = (event) => {
174-
const newFrequency = event.target.value;
175-
const user = {
176-
...this.state.user,
177-
notificationFrequency: newFrequency
178-
};
179-
this.setState({ user });
180-
};
181-
182170
openSuccessDialog = () => this.setState({ successDialog: true });
183171

184172
buildFormSchema = (authType) => {
@@ -297,27 +285,18 @@ class UserEdit extends React.Component {
297285
name="cell"
298286
{...dataTest("cell")}
299287
/>
300-
<div style={{ marginTop: 20 }}>
301-
<InputLabel
302-
style={{ marginBottom: 15 }}
303-
id="notification-frequency-label"
304-
>
305-
Notification Frequency
306-
</InputLabel>
307-
<Select
308-
id="notification-frequency"
309-
labelId="notification-frequency-label"
310-
name="notificationFrequency"
311-
value={user.notificationFrequency}
312-
onChange={this.handleNotificationFrequencyChange}
313-
>
314-
{Object.values(NotificationFrequencyType).map((option) => (
315-
<MenuItem key={option} value={option}>
316-
{titleCase(option)}
317-
</MenuItem>
318-
))}
319-
</Select>
320-
</div>
288+
<SpokeFormField
289+
label="Notification Frequency"
290+
name="notificationFrequency"
291+
{...dataTest("notificationFrequency")}
292+
type="select"
293+
choices={Object.values(NotificationFrequencyType).map(
294+
(option) => ({
295+
value: option,
296+
label: titleCase(option)
297+
})
298+
)}
299+
/>
321300
</span>
322301
)}
323302
{(authType === UserEditMode.Login ||

src/server/local-auth-helpers.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ const signup: AuthHelper = async (options) => {
161161
first_name: capitalizeWord(reqBody.firstName),
162162
last_name: capitalizeWord(reqBody.lastName),
163163
cell: reqBody.cell,
164-
is_superadmin: false
164+
is_superadmin: false,
165+
notification_frequency: reqBody.notificationFrequency
165166
})
166167
.returning("*");
167168
resolve(user);

0 commit comments

Comments
 (0)