2021-04-29 02:28:33 +00:00
|
|
|
import React, { useState } from "react"
|
|
|
|
import ContextRepositoryEditor from "../contexts/ContextRepositoryEditor"
|
|
|
|
import useArrayState from "../hooks/useArrayState"
|
|
|
|
|
|
|
|
|
|
|
|
export default function RepositoryEditor({ children, id, name, start, end, conditions }) {
|
|
|
|
const [_name, setName] = useState(name)
|
|
|
|
const [_start, setStart] = useState(start)
|
|
|
|
const [_end, setEnd] = useState(end)
|
2021-04-29 03:03:58 +00:00
|
|
|
const {
|
|
|
|
value: _conditions,
|
|
|
|
appendValue: appendCondition,
|
|
|
|
removeValue: removeCondition,
|
|
|
|
spliceValue: spliceCondition,
|
|
|
|
} = useArrayState(conditions)
|
2021-04-29 02:28:33 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<ContextRepositoryEditor.Provider value={{
|
|
|
|
id,
|
|
|
|
name: _name,
|
|
|
|
setName,
|
|
|
|
start: _start,
|
|
|
|
setStart,
|
|
|
|
end: _end,
|
|
|
|
setEnd,
|
|
|
|
conditions: _conditions,
|
|
|
|
appendCondition,
|
|
|
|
removeCondition,
|
2021-04-29 03:03:58 +00:00
|
|
|
spliceCondition,
|
2021-04-29 02:28:33 +00:00
|
|
|
}}>
|
|
|
|
{children}
|
|
|
|
</ContextRepositoryEditor.Provider>
|
|
|
|
)
|
|
|
|
}
|