mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
handle prop change
This commit is contained in:
parent
558c2568fd
commit
931d9ecee0
@ -7,55 +7,62 @@ import UploadButton from "@components/UploadButton"
|
||||
import "./index.less"
|
||||
|
||||
const CoverEditor = (props) => {
|
||||
const { value, onChange, defaultUrl } = props
|
||||
const { value, onChange, defaultUrl } = props
|
||||
|
||||
const [init, setInit] = React.useState(true)
|
||||
const [url, setUrl] = React.useState(value)
|
||||
const [init, setInit] = React.useState(true)
|
||||
const [url, setUrl] = React.useState(value)
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!init) {
|
||||
onChange(url)
|
||||
}
|
||||
}, [url])
|
||||
React.useEffect(() => {
|
||||
if (!init) {
|
||||
onChange(url)
|
||||
}
|
||||
}, [url])
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!value) {
|
||||
setUrl(defaultUrl)
|
||||
} else {
|
||||
setUrl(value)
|
||||
}
|
||||
React.useEffect(() => {
|
||||
if (!value) {
|
||||
setUrl(defaultUrl)
|
||||
} else {
|
||||
setUrl(value)
|
||||
}
|
||||
|
||||
setInit(false)
|
||||
}, [])
|
||||
setInit(false)
|
||||
}, [])
|
||||
|
||||
return <div className="cover-editor">
|
||||
<div className="cover-editor-preview">
|
||||
<Image
|
||||
src={url}
|
||||
/>
|
||||
</div>
|
||||
// Handle when value prop change
|
||||
React.useEffect(() => {
|
||||
if (!value) {
|
||||
setUrl(defaultUrl)
|
||||
} else {
|
||||
setUrl(value)
|
||||
}
|
||||
}, [value])
|
||||
|
||||
<div className="cover-editor-actions">
|
||||
<UploadButton
|
||||
onSuccess={(uid, response) => {
|
||||
setUrl(response.url)
|
||||
}}
|
||||
/>
|
||||
return (
|
||||
<div className="cover-editor">
|
||||
<div className="cover-editor-preview">
|
||||
<Image src={url} />
|
||||
</div>
|
||||
|
||||
<antd.Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
setUrl(defaultUrl)
|
||||
}}
|
||||
>
|
||||
Reset
|
||||
</antd.Button>
|
||||
<div className="cover-editor-actions">
|
||||
<UploadButton
|
||||
onSuccess={(uid, response) => {
|
||||
setUrl(response.url)
|
||||
}}
|
||||
/>
|
||||
|
||||
{
|
||||
props.extraActions
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<antd.Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
setUrl(defaultUrl)
|
||||
}}
|
||||
>
|
||||
Reset
|
||||
</antd.Button>
|
||||
|
||||
{props.extraActions}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default CoverEditor
|
||||
|
@ -10,13 +10,13 @@ export default async ({ username, password, hash }, user) => {
|
||||
user = await User.findOne(query).select("+email").select("+password")
|
||||
}
|
||||
|
||||
if (!user) {
|
||||
throw new OperationError(401, "User not found")
|
||||
}
|
||||
if (!user) {
|
||||
throw new OperationError(401, "User not found")
|
||||
}
|
||||
|
||||
if (user.disabled == true) {
|
||||
throw new OperationError(401, "User is disabled")
|
||||
}
|
||||
if (user.disabled == true) {
|
||||
throw new OperationError(401, "User is disabled")
|
||||
}
|
||||
|
||||
if (typeof hash !== "undefined") {
|
||||
if (user.password !== hash) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user