feat: add edit element button

This commit is contained in:
swve 2022-11-11 21:09:14 +01:00
parent 6f2cc5bdc6
commit c9de9b4ff6
6 changed files with 34 additions and 29 deletions

View file

@ -35,7 +35,7 @@ function Chapter(props: any) {
{(provided) => (
<ElementsList {...provided.droppableProps} ref={provided.innerRef}>
{props.info.list.elements.map((element: any, index: any) => (
<Element key={element.id} element={element} index={index}></Element>
<Element orgslug={props.orgslug} courseid={props.courseid} key={element.id} element={element} index={index}></Element>
))}
{provided.placeholder}
</ElementsList>

View file

@ -1,13 +1,18 @@
import Link from "next/link";
import React from "react";
import { Draggable } from "react-beautiful-dnd";
import styled from "styled-components";
function Element(props: any) {
return (
<Draggable key={props.element.id} draggableId={props.element.id} index={props.index}>
{(provided) => (
<ElementWrapper key={props.element.id} {...provided.draggableProps} {...provided.dragHandleProps} ref={provided.innerRef}>
<p>{props.element.name} </p>
<Link href={`/org/${props.orgslug}/course/${props.courseid}/element/${props.element.id.replace("element_", "")}/edit`}>
<a target="_blank" rel="noopener noreferrer">Edit</a>
</Link>
</ElementWrapper>
)}
</Draggable>