Revert "Merge branch 'transform-currency-support' into 'master'"
This reverts merge request !14
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useState } from 'react';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Button, Collapsible, CollapsibleItem, Select, TextInput } from 'react-materialize';
|
||||
import axios from 'axios';
|
||||
import { errorToast } from "../common/errorHelpers";
|
||||
@@ -8,11 +8,31 @@ const NewHomieForm = (props) => {
|
||||
const [homieName, setHomieName] = useState("");
|
||||
const [aboutHomie, setAboutHomie] = useState("");
|
||||
const [homieImportance, setHomieImportance] = useState("");
|
||||
const [homieDefaultChip, setHomieDefaultChip] = useState("");
|
||||
const [chips, setChips] = useState([]);
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
try {
|
||||
const response = await axios.get('/api/chips');
|
||||
if (response.status === 200 && response.data) {
|
||||
setChips(response.data);
|
||||
}else {
|
||||
errorToast();
|
||||
}
|
||||
}catch (e) {
|
||||
errorToast();
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
|
||||
const chipOptions = chips.map((chip, index) => <option key={index} value={chip.id}>{ chip.name }</option>);
|
||||
|
||||
const disableAddButton = () => {
|
||||
return homieName.length === 0 ||
|
||||
homieImportance === "" ||
|
||||
homieDefaultChip === "" ||
|
||||
busy;
|
||||
}
|
||||
|
||||
@@ -20,6 +40,7 @@ const NewHomieForm = (props) => {
|
||||
setHomieName("");
|
||||
setAboutHomie("");
|
||||
setHomieImportance("");
|
||||
setHomieDefaultChip("");
|
||||
|
||||
const collapsible = document.getElementById('new-homie-form-container');
|
||||
const collapsibleInstance = M.Collapsible.getInstance(collapsible);
|
||||
@@ -33,7 +54,8 @@ const NewHomieForm = (props) => {
|
||||
homie: {
|
||||
name: homieName,
|
||||
about: aboutHomie,
|
||||
importance: parseInt(homieImportance)
|
||||
importance: parseInt(homieImportance),
|
||||
chip_id: parseInt(homieDefaultChip)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +103,12 @@ const NewHomieForm = (props) => {
|
||||
<option value={0}>Guy from the hood</option>
|
||||
</Select>
|
||||
|
||||
<label className="required">Homie default chip: </label>
|
||||
<Select value={homieDefaultChip} onChange={(e) => setHomieDefaultChip(e.target.value)} name="defaultChip">
|
||||
<option disabled value="">Set default chip</option>
|
||||
{ chipOptions }
|
||||
</Select>
|
||||
|
||||
<br/>
|
||||
|
||||
<Button disabled={disableAddButton()} onClick={addNewHomie}>Add to the hood</Button>
|
||||
|
||||
Reference in New Issue
Block a user