Compare commits

..

No commits in common. "6d0a62ec21acec8eebfeb1d88c4a0a9328f702e8" and "8cc266209232409dac41a64d3a4fbfc9876a7304" have entirely different histories.

6 changed files with 23 additions and 99 deletions

3
.gitignore vendored
View file

@ -1,3 +0,0 @@
.env
n39env
.vscode

View file

@ -1,55 +0,0 @@
import os
import json
import argparse
from git import Repo
from pyforgejo import AuthenticatedClient
from dotenv import load_dotenv
from pyforgejo.api.issue import issue_list_issues
from pyforgejo.api.repository import repo_create_branch, repo_create_pull_request
from pyforgejo.models import CreateBranchRepoOption, CreatePullRequestOption
load_dotenv()
parser = argparse.ArgumentParser(description="")
parser.add_argument("-i", "--issue")
args = parser.parse_args()
FORJEGO_ACCESS_TOKEN = os.getenv("FORJEGO_ACCESS_TOKEN")
OWNER = os.getenv("OWNER")
USER = os.getenv("USER")
REPO = os.getenv("REPO")
client = AuthenticatedClient(
base_url="https://git.n39.eu/api/v1/", token=FORJEGO_ACCESS_TOKEN
)
issues = json.loads(issue_list_issues.sync_detailed(OWNER, REPO, client=client).content)
def filterIssues(issue):
return args.issue in issue["title"]
issues = list(filter(filterIssues, issues))
branchName = issues[0]["title"].replace(" ", "-")
if len(issues) > 1:
raise ValueError("found more than one ticket")
if len(issues) == 0:
raise ValueError("found more than one ticket")
else:
repo_create_branch.sync_detailed(
OWNER, REPO, body=CreateBranchRepoOption(branchName, "main"), client=client
)
res = json.loads(
repo_create_pull_request.sync_detailed(
OWNER,
REPO,
body=CreatePullRequestOption(
base="main", head=branchName, title="merge-" + branchName
),
client=client,
).content
)
print(res)

1
frontend/.gitignore vendored
View file

@ -1 +0,0 @@
node_modules

View file

@ -29,20 +29,7 @@ export const BookModal = ({
}, [book, reset]);
const { scannerError, setScannerRef } = useScanner({
onDetected: async (result) => {
const googleBooks = await (
await fetch(
"https://www.googleapis.com/books/v1/volumes?q=isbn:" + result
)
).json();
if ("items" in googleBooks) {
console.log(googleBooks);
setValue(
"published",
googleBooks.items[0].volumeInfo.publishedDate.substring(0, 4)
);
setValue("title", googleBooks.items[0].volumeInfo.title);
}
onDetected: (result) => {
setValue("isbn", result);
setShowScanner(false);
},
@ -51,7 +38,6 @@ export const BookModal = ({
const values = useWatch({ control });
const [submitError, setSubmitError] = useState<string | undefined>();
const onSubmit = useCallback(
async (data: Partial<BookForm>) => {
setSubmitError(undefined);
@ -103,7 +89,7 @@ export const BookModal = ({
<ModalHeader
onClose={onClose}
title={`${!!book ? "Edit" : "Add new"} Book`}
icon={<ImBook size={50} className='ml-0 mr-auto' />}
icon={<ImBook size={50} className="ml-0 mr-auto" />}
/>
<Modal.Body
style={{
@ -114,18 +100,18 @@ export const BookModal = ({
>
{!showScanner && (
<Form
className='mb-2'
className="mb-2"
onSubmit={(ev) => {
ev.preventDefault();
onSubmit(values);
}}
>
<Form.Group as={Row} className='mb-2'>
<Col sm='2'>
<Form.Group as={Row} className="mb-2">
<Col sm="2">
<Form.Label>ISBN</Form.Label>
</Col>
<Col className='d-flex flex-column'>
<div className='d-flex'>
<Col className="d-flex flex-column">
<div className="d-flex">
<Form.Control
{...register("isbn", { required: true, maxLength: 360 })}
isInvalid={!!formState.errors.isbn}
@ -140,7 +126,7 @@ export const BookModal = ({
color: "black",
border: "2px solid black",
}}
className='mr-2 pt-0'
className="mr-2 pt-0"
disabled={showScanner}
onClick={() => setShowScanner(true)}
>
@ -149,7 +135,7 @@ export const BookModal = ({
</div>
<Form.Control.Feedback
style={{ display: !formState.errors.isbn ? "none" : "block" }}
type='invalid'
type="invalid"
>
{!formState.errors.isbn
? "ISBN is required"
@ -157,8 +143,8 @@ export const BookModal = ({
</Form.Control.Feedback>
</Col>
</Form.Group>
<Form.Group as={Row} className='mb-2'>
<Col sm='2'>
<Form.Group as={Row} className="mb-2">
<Col sm="2">
<Form.Label>Title</Form.Label>
</Col>
<Col>
@ -167,15 +153,15 @@ export const BookModal = ({
isInvalid={!!formState.errors.title}
/>
<Form.Control.Feedback type='invalid'>
<Form.Control.Feedback type="invalid">
{!values.title
? "Title is required"
: formState.errors.title?.message}
</Form.Control.Feedback>
</Col>
</Form.Group>
<Form.Group as={Row} className='mb-2'>
<Col sm='2'>
<Form.Group as={Row} className="mb-2">
<Col sm="2">
<Form.Label>Year published</Form.Label>
</Col>
<Col>
@ -201,15 +187,15 @@ export const BookModal = ({
isInvalid={!!formState.errors.published}
/>
<Form.Control.Feedback type='invalid'>
<Form.Control.Feedback type="invalid">
{!values.published
? "Year published is required"
: formState.errors.published?.message}
</Form.Control.Feedback>
</Col>
</Form.Group>
<Form.Group as={Row} className='mb-2'>
<Col sm='2'>
<Form.Group as={Row} className="mb-2">
<Col sm="2">
<Form.Label>Shelf</Form.Label>
</Col>
<Col>
@ -219,21 +205,21 @@ export const BookModal = ({
>
{Object.keys(bookShelfs).map((key) => (
<option
key='key'
key="key"
value={bookShelfs[key as keyof typeof bookShelfs]}
>
{key}
</option>
))}
</Form.Select>
<Form.Control.Feedback type='invalid'>
<Form.Control.Feedback type="invalid">
{!values.shelf
? "Shelf is required"
: formState.errors.shelf?.message}
</Form.Control.Feedback>
</Col>
</Form.Group>
<div className='d-flex mx-auto mb-auto mt-2 w-100'>
<div className="d-flex mx-auto mb-auto mt-2 w-100">
<Button
style={{
borderRadius: "5px",
@ -252,12 +238,12 @@ export const BookModal = ({
)}
{showScanner && (
<div
className='w-100 overflow-hidden'
className="w-100 overflow-hidden"
ref={(ref) => setScannerRef(ref)}
style={{ position: "relative", height: "25vh" }}
>
<canvas
className='drawingBuffer w-100 position-absolute'
className="drawingBuffer w-100 position-absolute"
style={{
height: "100%",
border: "2px solid black",
@ -272,7 +258,7 @@ export const BookModal = ({
</p>
) : null}
{!!submitError && (
<Form.Control.Feedback style={{ display: "block" }} type='invalid'>
<Form.Control.Feedback style={{ display: "block" }} type="invalid">
{submitError}
</Form.Control.Feedback>
)}

1
issues

File diff suppressed because one or more lines are too long

View file

@ -1,2 +0,0 @@
dist
node_modules