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

35 lines
1,014 B
JavaScript
Raw Normal View History

import React, { useState } from "react"
2021-04-29 14:58:31 +00:00
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 {
value: _conditions,
appendValue: appendCondition,
removeValue: removeCondition,
spliceValue: spliceCondition,
} = useArrayState(conditions)
return (
<ContextRepositoryEditor.Provider value={{
id,
name: _name,
setName,
start: _start,
setStart,
end: _end,
setEnd,
conditions: _conditions,
appendCondition,
removeCondition,
spliceCondition,
}}>
{children}
</ContextRepositoryEditor.Provider>
)
}