Fix code style
This commit is contained in:
@@ -14,7 +14,7 @@ import {
|
|||||||
findProjectByValue,
|
findProjectByValue,
|
||||||
findProjectByIdentifier,
|
findProjectByIdentifier,
|
||||||
findTask,
|
findTask,
|
||||||
formatDate
|
formatDate,
|
||||||
} from "utils"
|
} from "utils"
|
||||||
import InvalidConfigurationError from "components/Errors/InvalidConfigurationError"
|
import InvalidConfigurationError from "components/Errors/InvalidConfigurationError"
|
||||||
import UpgradeRequiredError from "components/Errors/UpgradeRequiredError"
|
import UpgradeRequiredError from "components/Errors/UpgradeRequiredError"
|
||||||
@@ -34,7 +34,7 @@ class App extends Component {
|
|||||||
name: PropTypes.string,
|
name: PropTypes.string,
|
||||||
description: PropTypes.string,
|
description: PropTypes.string,
|
||||||
projectId: PropTypes.string,
|
projectId: PropTypes.string,
|
||||||
taskId: PropTypes.string
|
taskId: PropTypes.string,
|
||||||
}),
|
}),
|
||||||
subdomain: PropTypes.string,
|
subdomain: PropTypes.string,
|
||||||
activities: PropTypes.array,
|
activities: PropTypes.array,
|
||||||
@@ -46,18 +46,18 @@ class App extends Component {
|
|||||||
fromDate: PropTypes.string,
|
fromDate: PropTypes.string,
|
||||||
toDate: PropTypes.string,
|
toDate: PropTypes.string,
|
||||||
errorType: PropTypes.string,
|
errorType: PropTypes.string,
|
||||||
errorMessage: PropTypes.string
|
errorMessage: PropTypes.string,
|
||||||
};
|
}
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
activities: [],
|
activities: [],
|
||||||
schedules: [],
|
schedules: [],
|
||||||
projects: [],
|
projects: [],
|
||||||
roundTimeEntries: false
|
roundTimeEntries: false,
|
||||||
};
|
}
|
||||||
|
|
||||||
@observable changeset = {};
|
@observable changeset = {}
|
||||||
@observable formErrors = {};
|
@observable formErrors = {}
|
||||||
|
|
||||||
@computed get changesetWithDefaults() {
|
@computed get changesetWithDefaults() {
|
||||||
const { service, projects, lastProjectId, lastTaskId } = this.props
|
const { service, projects, lastProjectId, lastTaskId } = this.props
|
||||||
@@ -69,9 +69,8 @@ class App extends Component {
|
|||||||
head(projects)
|
head(projects)
|
||||||
|
|
||||||
const task =
|
const task =
|
||||||
findTask(this.changeset.task_id || service?.taskId || lastTaskId)(
|
findTask(this.changeset.task_id || service?.taskId || lastTaskId)(project) ||
|
||||||
project
|
head(project?.tasks)
|
||||||
) || head(project?.tasks)
|
|
||||||
|
|
||||||
const billable = /\(.+\)/.test(this.changeset.hours) === true ? false : !!task?.billable
|
const billable = /\(.+\)/.test(this.changeset.hours) === true ? false : !!task?.billable
|
||||||
|
|
||||||
@@ -84,11 +83,9 @@ class App extends Component {
|
|||||||
task_id: task?.value,
|
task_id: task?.value,
|
||||||
billable,
|
billable,
|
||||||
hours: "",
|
hours: "",
|
||||||
seconds:
|
seconds: this.changeset.hours && new TimeInputParser(this.changeset.hours).parseSeconds(),
|
||||||
this.changeset.hours &&
|
|
||||||
new TimeInputParser(this.changeset.hours).parseSeconds(),
|
|
||||||
description: service?.description,
|
description: service?.description,
|
||||||
tag: ""
|
tag: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
return { ...defaults, ...this.changeset }
|
return { ...defaults, ...this.changeset }
|
||||||
@@ -107,7 +104,7 @@ class App extends Component {
|
|||||||
handleChange = event => {
|
handleChange = event => {
|
||||||
const { projects } = this.props
|
const { projects } = this.props
|
||||||
const {
|
const {
|
||||||
target: { name, value }
|
target: { name, value },
|
||||||
} = event
|
} = event
|
||||||
|
|
||||||
this.changeset[name] = value
|
this.changeset[name] = value
|
||||||
@@ -116,11 +113,11 @@ class App extends Component {
|
|||||||
const project = findProjectByValue(value)(projects)
|
const project = findProjectByValue(value)(projects)
|
||||||
this.changeset.task_id = head(project?.tasks)?.value
|
this.changeset.task_id = head(project?.tasks)?.value
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
handleSelectDate = date => {
|
handleSelectDate = date => {
|
||||||
this.changeset.date = formatDate(date)
|
this.changeset.date = formatDate(date)
|
||||||
};
|
}
|
||||||
|
|
||||||
handleSubmit = event => {
|
handleSubmit = event => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
@@ -130,23 +127,23 @@ class App extends Component {
|
|||||||
type: "createActivity",
|
type: "createActivity",
|
||||||
payload: {
|
payload: {
|
||||||
activity: extractAndSetTag(this.changesetWithDefaults),
|
activity: extractAndSetTag(this.changesetWithDefaults),
|
||||||
service
|
service,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
handleKeyDown = event => {
|
handleKeyDown = event => {
|
||||||
if (event.keyCode === 27) {
|
if (event.keyCode === 27) {
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
chrome.runtime.sendMessage({ type: "closePopup" })
|
chrome.runtime.sendMessage({ type: "closePopup" })
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
handleSetFormErrors = ({ type, payload }) => {
|
handleSetFormErrors = ({ type, payload }) => {
|
||||||
if (type === "setFormErrors") {
|
if (type === "setFormErrors") {
|
||||||
this.formErrors = payload
|
this.formErrors = payload
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
@@ -158,7 +155,7 @@ class App extends Component {
|
|||||||
fromDate,
|
fromDate,
|
||||||
toDate,
|
toDate,
|
||||||
errorType,
|
errorType,
|
||||||
errorMessage
|
errorMessage,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
@@ -178,12 +175,7 @@ class App extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Spring
|
<Spring native from={{ opacity: 0 }} to={{ opacity: 1 }} config={config.stiff}>
|
||||||
native
|
|
||||||
from={{ opacity: 0 }}
|
|
||||||
to={{ opacity: 1 }}
|
|
||||||
config={config.stiff}
|
|
||||||
>
|
|
||||||
{props => (
|
{props => (
|
||||||
<animated.div className="moco-bx-app-container" style={props}>
|
<animated.div className="moco-bx-app-container" style={props}>
|
||||||
<Header subdomain={subdomain} />
|
<Header subdomain={subdomain} />
|
||||||
|
|||||||
Reference in New Issue
Block a user