Fixing form submission
All checks were successful
Music Collection CI Workflow / test (./backend) (push) Successful in 22s
Music Collection CI Workflow / test (./frontend) (push) Successful in 19s
Music Collection CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/msuic-collection-backend, ./backend) (push) Successful in 48s
Music Collection CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/music-collection-frontend, ./frontend) (push) Successful in 1m15s
Music Collection CI Workflow / deploy (push) Successful in 23s
All checks were successful
Music Collection CI Workflow / test (./backend) (push) Successful in 22s
Music Collection CI Workflow / test (./frontend) (push) Successful in 19s
Music Collection CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/msuic-collection-backend, ./backend) (push) Successful in 48s
Music Collection CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/music-collection-frontend, ./frontend) (push) Successful in 1m15s
Music Collection CI Workflow / deploy (push) Successful in 23s
This commit is contained in:
parent
544072790f
commit
42c3bb7ec7
@ -1,22 +1,18 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { FormEvent, useState, useEffect } from 'react';
|
import { FormEvent, useState, useEffect } from 'react';
|
||||||
import { usePathname } from "next/navigation";
|
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { Album } from '@/entities/album.entity';
|
import { Album } from '@/entities/album.entity';
|
||||||
import { createAlbum } from '@/app/actions';
|
import { createAlbum } from '@/app/actions';
|
||||||
// import CreateAlbumModal from "@/app/components/modals/create-album";
|
// import CreateAlbumModal from "@/app/components/modals/create-album";
|
||||||
import Button from 'react-bootstrap/Button';
|
import Button from 'react-bootstrap/Button';
|
||||||
import Modal from 'react-bootstrap/Modal';
|
import Modal from 'react-bootstrap/Modal';
|
||||||
import { useRouter } from 'next/navigation';
|
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
const [albums, setAlbums] = useState<Album[]>([]);
|
const [albums, setAlbums] = useState<Album[]>([]);
|
||||||
const [show, setShow] = useState(false);
|
const [show, setShow] = useState(false);
|
||||||
const handleClose = () => setShow(false);
|
const handleClose = () => setShow(false);
|
||||||
const handleShow = () => setShow(true);
|
const handleShow = () => setShow(true);
|
||||||
const pathname = usePathname();
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchAlbums() {
|
async function fetchAlbums() {
|
||||||
@ -27,14 +23,14 @@ export default function Page() {
|
|||||||
fetchAlbums();
|
fetchAlbums();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
async function onSubmit(event: FormEvent<HTMLFormElement>) {
|
const handleSubmit = async (event: FormEvent<HTMLFormElement>) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
const formData = new FormData(event.currentTarget);
|
const formData = new FormData(event.currentTarget);
|
||||||
const response = await createAlbum(formData);
|
const response = await createAlbum(formData);
|
||||||
|
|
||||||
await response.json();
|
await response.json();
|
||||||
router.refresh();
|
handleClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!albums) return <div>Loading...</div>
|
if (!albums) return <div>Loading...</div>
|
||||||
@ -89,7 +85,7 @@ export default function Page() {
|
|||||||
</Modal.Header>
|
</Modal.Header>
|
||||||
<Modal.Body>
|
<Modal.Body>
|
||||||
<div>
|
<div>
|
||||||
<form onSubmit={onSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="six columns">
|
<div className="six columns">
|
||||||
<label htmlFor="album-title">Album Title</label><input type="text" name="title" id="album-title" />
|
<label htmlFor="album-title">Album Title</label><input type="text" name="title" id="album-title" />
|
||||||
@ -108,17 +104,14 @@ export default function Page() {
|
|||||||
<button type="submit">Create</button>
|
<button type="submit">Create</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<Button variant="primary" type="submit">Create</Button>
|
||||||
</form>
|
</form>
|
||||||
<Link href={pathname}>
|
|
||||||
<button type="button" className="bg-red-500 text-white p-2">Close Modal</button>
|
|
||||||
</Link>
|
|
||||||
</div>
|
</div>
|
||||||
</Modal.Body>
|
</Modal.Body>
|
||||||
<Modal.Footer>
|
<Modal.Footer>
|
||||||
<Button variant="secondary" onClick={handleClose}>
|
<Button variant="secondary" onClick={handleClose}>
|
||||||
Close
|
Close
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="primary">Create</Button>
|
|
||||||
</Modal.Footer>
|
</Modal.Footer>
|
||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
|
@ -1079,4 +1079,5 @@ there.
|
|||||||
|
|
||||||
.has-docked-nav .navbar > .container {
|
.has-docked-nav .navbar > .container {
|
||||||
width: 80%;
|
width: 80%;
|
||||||
|
max-height: 55px;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user