Skip to content

Commit

Permalink
Merge pull request #69 from stevebrownlee/develop
Browse files Browse the repository at this point in the history
Added Radix buttons for all course management forms
  • Loading branch information
stevebrownlee authored Jun 30, 2024
2 parents e18caaa + 2138acc commit e2e181b
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 64 deletions.
38 changes: 16 additions & 22 deletions src/components/course/BookForm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useContext, useEffect, useState } from "react"
import { useHistory, useParams } from "react-router-dom"

import { Button } from "@radix-ui/themes"
import Settings from "../Settings.js"
import { fetchIt } from "../utils/Fetch.js"
import { HelpIcon } from "../../svgs/Help.js"
Expand Down Expand Up @@ -111,31 +113,23 @@ export const BookForm = () => {
/>
</div>

<Button style={{ marginTop: "2rem", marginLeft: "auto" }} color="blue"
onClick={evt => {
evt.preventDefault()

<button type="submit"
className="isometric-button blue"
onClick={
evt => {
evt.preventDefault()

if (mode === "create") {
constructNewBook()
}
else {
editBook(book).then(() => history.push(`/courses/${book.course}`))
}
if (mode === "create") {
constructNewBook()
}
}> Save </button>

<button type="submit"
style={{margin: "0 0 0 1rem"}}
className="isometric-button blue"
onClick={
evt => {
evt.preventDefault()
history.push(`/courses/${book.course}`)
else {
editBook(book).then(() => history.push(`/courses/${book.course}`))
}
}> Cancel </button>
}}>Save</Button>

<Button style={{ margin: "2rem 0 0 1rem" }} color="crimson"
onClick={evt => {
evt.preventDefault()
history.push(`/courses/${book.course}`)
}}>Cancel</Button>
</form>
</>
)
Expand Down
33 changes: 19 additions & 14 deletions src/components/course/CourseForm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useContext, useEffect, useState } from "react"
import { useHistory, useParams } from "react-router-dom"

import { Button } from "@radix-ui/themes"
import Settings from "../Settings.js"
import { fetchIt } from "../utils/Fetch.js"
import { HelpIcon } from "../../svgs/Help.js"
Expand Down Expand Up @@ -40,7 +42,7 @@ export const CourseForm = () => {
return (
<>
<form className="courseForm view">
<h2 className="courseForm__title">{mode === "edit" ? "Edit": "New"} Course</h2>
<h2 className="courseForm__title">{mode === "edit" ? "Edit" : "New"} Course</h2>
<div className="form-group">
<label htmlFor="name"> Course name </label>
<input onChange={updateState}
Expand All @@ -52,23 +54,26 @@ export const CourseForm = () => {
</div>
<div className="form-group">
<input id="active" type="checkbox" controltype="boolean" checked={course.active} onChange={updateState} />
<label htmlFor="active" style={{margin: "0 0 0 0.5rem"}}>Active</label>
<label htmlFor="active" style={{ margin: "0 0 0 0.5rem" }}>Active</label>
</div>

<button type="submit"
onClick={
evt => {
evt.preventDefault()
<Button style={{ marginTop: "2rem", marginLeft: "auto" }} color="blue"
onClick={evt => {
evt.preventDefault()

if (mode === "create") {
createCourse(course).then(() => history.push("/courses"))
}
else {
editCourse(course).then(() => history.push("/courses"))
}
if (mode === "create") {
createCourse(course).then(() => history.push("/courses"))
}
else {
editCourse(course).then(() => history.push("/courses"))
}
}
className="isometric-button blue"> Save </button>
}}>Save</Button>

<Button style={{ margin: "2rem 0 0 1rem" }} color="crimson"
onClick={evt => {
evt.preventDefault()
history.push("/courses")
}}>Cancel</Button>
</form>
</>
)
Expand Down
11 changes: 5 additions & 6 deletions src/components/course/ProjectDetails.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useContext, useEffect, useState } from "react"
import { Link, useHistory, useParams } from "react-router-dom/cjs/react-router-dom.min.js"

import { Button } from "@radix-ui/themes"
import { EditIcon } from "../../svgs/EditIcon"
import { CourseContext } from "./CourseProvider.js"
import { DeleteIcon } from "../../svgs/DeleteIcon.js"
Expand Down Expand Up @@ -36,17 +37,15 @@ export const ProjectDetails = () => {
</div>

<div className="project__footer">
<button style={{ marginTop: "2rem", marginLeft: "auto" }}
className="isometric-button yellow"
<Button style={{ marginTop: "2rem", marginLeft: "auto" }} color="orange"
onClick={() => {
history.push(`/projects/edit/${project.id}`)
}}>Edit Project</button>
}}>Edit Project</Button>

<button style={{ marginTop: "2rem" }}
className="isometric-button red"
<Button style={{ margin: "2rem 0 0 1rem" }} color="crimson"
onClick={() => {
deleteProject(project.id).then(() => history.push(`/books/${project.book.id}`))
}}>Delete Project</button>
}}>Delete Project</Button>
</div>
</article>
}
40 changes: 18 additions & 22 deletions src/components/course/ProjectForm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { useContext, useEffect, useState } from "react"
import { useHistory, useParams } from "react-router-dom"

import Settings from "../Settings.js"
import { Button } from "@radix-ui/themes"
import { fetchIt } from "../utils/Fetch.js"
import { HelpIcon } from "../../svgs/Help.js"
import { CourseContext } from "./CourseProvider.js"
Expand Down Expand Up @@ -40,7 +42,7 @@ export const ProjectForm = () => {
useEffect(() => {
if (bookId) {
getBook(bookId).then((book) => {
updateProject({...project, book: book.id, course: book.course.id})
updateProject({ ...project, book: book.id, course: book.course.id })
setTitle(`${book.course.name} > ${book.name} > New Project`)
})
setMode("create")
Expand Down Expand Up @@ -122,29 +124,23 @@ export const ProjectForm = () => {
<label htmlFor="active"> Active </label>
</div>

<button type="submit" className="isometric-button blue"
onClick={
evt => {
evt.preventDefault()

if (mode === "create") {
constructNewProject()
}
else {
editProject(project).then(() => history.push(`/books/${project.book}`))
}
<Button style={{ marginTop: "2rem", marginLeft: "auto" }} color="blue"
onClick={evt => {
evt.preventDefault()

if (mode === "create") {
constructNewProject()
}
}> Save </button>

<button type="submit"
style={{ margin: "0 0 0 1rem" }}
className="isometric-button blue"
onClick={
evt => {
evt.preventDefault()
history.push(`/books/${project.book}`)
else {
editProject(project).then(() => history.push(`/books/${project.book}`))
}
}> Cancel </button>
}}>Save</Button>

<Button style={{ margin: "2rem 0 0 1rem" }} color="crimson"
onClick={evt => {
evt.preventDefault()
history.push(`/books/${project.book}`)
}}>Cancel</Button>
</form>
</>
)
Expand Down

0 comments on commit e2e181b

Please sign in to comment.