1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-26 15:04:18 +00:00
pds-2021-g2-nest/code/frontend/src/components/RepositoryEditor.js

29 lines
877 B
JavaScript
Raw Normal View History

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)
const {_conditions, appendCondition, removeCondition} = useArrayState(conditions)
return (
<ContextRepositoryEditor.Provider value={{
id,
name: _name,
setName,
start: _start,
setStart,
end: _end,
setEnd,
conditions: _conditions,
appendCondition,
removeCondition,
}}>
{children}
</ContextRepositoryEditor.Provider>
)
}