Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pages updated,added. #34

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
namespace LibraryTrackingApp.Domain.Entities.Library;


//bunlar bir sonraki güncellemede veritabanına migrate edilcektir. raf ve kitap bölmesi dataları
public class Shelf : BaseEntity<Guid>, IAuditable<Guid>
{
public Guid Id { get; set; }
Expand Down
118 changes: 118 additions & 0 deletions LibraryTrackingApp/src/frontend/components/AudioBookForm.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import { useState } from "react";
import {
Box,
FormControl,
FormLabel,
Input,
Table,
TableCaption,
Tbody,
Textarea,
Th,
Thead,
Tr,
} from "@chakra-ui/react";
import UploadForm from "./UploadForm";

const AudioBookForm = ({ onUpload }) => {
const [title, setTitle] = useState("");
const [author, setAuthor] = useState("");
const [narrator, setNarrator] = useState("");
const [description, setDescription] = useState("");
const [audioFile, setAudioFile] = useState(null);
const [audioFiles, setAudioFiles] = useState([]);

const handleUpload = (file) => {
// ayarlanacak..
};
const handleDelete = (id) => {
setAudioFiles(eBooks.filter((audioFile) => audioFile.id !== id));
};
return (
<>
<FormControl>
<FormLabel htmlFor="title">Başlık</FormLabel>
<Input
type="text"
id="title"
value={title}
onChange={(e) => setTitle(e.target.value)}
/>
</FormControl>
<FormControl mt={4}>
<FormLabel htmlFor="author">Yazar</FormLabel>
<Input
type="text"
id="author"
value={author}
onChange={(e) => setAuthor(e.target.value)}
/>
</FormControl>
<FormControl mt={4}>
<FormLabel htmlFor="narrator">Anlatan</FormLabel>
<Input
type="text"
id="narrator"
value={narrator}
onChange={(e) => setNarrator(e.target.value)}
/>
</FormControl>
<FormControl mt={4}>
<FormLabel htmlFor="description">Açıklama</FormLabel>
<Textarea
id="description"
value={description}
onChange={(e) => setDescription(e.target.value)}
/>
</FormControl>

<UploadForm
onUpload={handleUpload}
//accept=".mp3, .wav"
labelName={"Ses Dosyasını buraya bırakınız."}
/>

<Table variant="striped" colorScheme="blue" mt={8}>
<TableCaption>{`${audioFiles.length} sesli kitap bulundu.`}</TableCaption>
<Thead>
<Tr>
<Th>Ad</Th>
<Th>Dosya Tipi</Th>
<Th>Boyut (KB)</Th>
<Th>İşlemler</Th>
</Tr>
</Thead>
<Tbody>
{audioFiles.map((file) => (
<Tr key={file.id}>
<Td>{file.title}</Td>
<Td>{file.author}</Td>
<Td>{(file.size / 1024).toFixed(2)}</Td>
<Td>{file.author}</Td>

<Td>
<Button
colorScheme="teal"
size="sm"
mr={2}
onClick={() => window.open(`/app/e-books/${file.id}`)}
>
Görüntüle
</Button>
<Button
colorScheme="red"
size="sm"
onClick={() => handleDelete(file.id)}
>
Sil
</Button>
</Td>
</Tr>
))}
</Tbody>
</Table>
</>
);
};

export default AudioBookForm;
52 changes: 52 additions & 0 deletions LibraryTrackingApp/src/frontend/components/GenreEditModal .jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// GenreEditModal.jsx
import { useState } from 'react';
import {
Box,
Button,
FormControl,
FormLabel,
Input,
Modal,
ModalOverlay,
ModalContent,
ModalHeader,
ModalCloseButton,
ModalBody,
ModalFooter,
} from '@chakra-ui/react';

const GenreEditModal = ({ isOpen, onClose, genre, onUpdate }) => {
const [name, setName] = useState(genre ? genre.name : '');

const handleSubmit = () => {
onUpdate({ ...genre, name });
onClose();
};

return (
<Modal isOpen={isOpen} onClose={onClose}>
<ModalOverlay />
<ModalContent>
<ModalHeader>Tür Düzenle</ModalHeader>
<ModalCloseButton />
<ModalBody>
<FormControl>
<FormLabel htmlFor="name">Ad</FormLabel>
<Input
type="text"
id="name"
value={name}
onChange={(e) => setName(e.target.value)}
/>
</FormControl>
</ModalBody>
<ModalFooter>
<Button colorScheme="blue" mr={3} onClick={handleSubmit}>Kaydet</Button>
<Button variant="ghost" onClick={onClose}>İptal</Button>
</ModalFooter>
</ModalContent>
</Modal>
);
};

export default GenreEditModal;
18 changes: 10 additions & 8 deletions LibraryTrackingApp/src/frontend/components/LanguageSwitcher.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { Box, Button, Select, useColorModeValue } from "@chakra-ui/react";
import {
Box,
Button,
Select,
useColorMode,
useColorModeValue,
} from "@chakra-ui/react";
import { useRouter } from "next/router";
import React, { useEffect, useState } from "react";
import locales, { EN_LOCALE, TR_LOCALE } from "../lib/locales";
Expand Down Expand Up @@ -27,7 +33,6 @@ function LangSwitcher() {
broadcastChannel.addEventListener("message", (message) => {
changeLanguage(message.data);
});

}, []);

const changeLanguage = (newLocale) => {
Expand All @@ -38,7 +43,7 @@ function LangSwitcher() {
} else {
router.push(router.pathname, undefined, {
locale: newLocale,
shallow: true
shallow: true,
});
}
};
Expand All @@ -50,22 +55,19 @@ function LangSwitcher() {
changeLanguage(newLocale);
broadcastChannel.postMessage(newLocale);
};

const { colorMode } = useColorMode();
return (
<>
<Button
id="lang-switcher"
_hover={{ color: colorMode === "light" ? "teal.500" : "teal.300" }}
color={useColorModeValue("text.200", "textD.200")}
bg="transparent"
p={2}
fontSize="lg"
onClick={toggleLanguage}
mr={2}
variant={"link"}
_hover={{
textDecoration: "none",
color: "primary.100",
}}
cursor={"pointer"}
>
{currentLocale === EN_LOCALE.hl ? "TR" : "EN"}
Expand Down
125 changes: 125 additions & 0 deletions LibraryTrackingApp/src/frontend/components/MagazineEditForm.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import { useState } from "react";
import {
Box,
Button,
FormControl,
FormLabel,
Input,
Textarea,
Modal,
ModalOverlay,
ModalContent,
ModalHeader,
ModalCloseButton,
ModalBody,
ModalFooter,
Text,
} from "@chakra-ui/react";

const MagazineEditForm = ({ magazine, isOpen, onClose, onSubmit }) => {
const [name, setName] = useState(magazine ? magazine.name : "");
const [publicationDate, setPublicationDate] = useState(
magazine ? magazine.publicationDate : ""
);
const [coverImage, setCoverImage] = useState(
magazine ? magazine.coverImage : ""
);

const [coverImageURL, setCoverImageURL] = useState(
magazine ? magazine.coverImage : ""
);


const handleSubmit = () => {
onSubmit({ name, publicationDate, coverImage });
};

const handleImageChange = (e) => {
const selectedFile = e.target.files[0];
if (selectedFile) {
setFile(selectedFile);
setError("");
setCoverImageURL(URL.createObjectURL(selectedFile));

setMagazine((prevMagazine) => ({
...prevMagazine,
coverImage: URL.createObjectURL(selectedFile),
}));
} else {
setFile(null);
setError("Lütfen bir dosya seçin.");
setCoverImageURL("");

setMagazine((prevMagazine) => ({
...prevMagazine,
coverImage: "",
}));
}
};


return (
<Modal isOpen={isOpen} onClose={onClose}>
<ModalOverlay />
<ModalContent>
<ModalHeader>Dergi Düzenle</ModalHeader>
<ModalCloseButton />
<ModalBody>
<FormControl>
<FormLabel htmlFor="name">Dergi Adı</FormLabel>
<Input
type="text"
id="name"
value={name}
onChange={(e) => setName(e.target.value)}
/>
</FormControl>
<FormControl mt={4}>
<FormLabel htmlFor="publicationDate">Yayın Tarihi</FormLabel>
<Input
type="text"
id="publicationDate"
value={publicationDate}
onChange={(e) => setPublicationDate(e.target.value)}
/>
</FormControl>
<FormControl mt={4}>
<FormLabel htmlFor="coverImage">Kapak Resmi</FormLabel>
<Input
type="file"
id="coverImage"
accept="image/*"
onChange={handleImageChange}
/>
<Text mt={2} fontSize="sm" color="gray.500">
Veya kapak resmi URL'sini girin:
</Text>
<Input
type="text"
id="coverImageURL"
value={coverImageURL}
onChange={(e) => setCoverImageURL(e.target.value)}
/>
{coverImage && (
<img
src={coverImage}
alt="Kapak Resmi"
style={{ marginTop: "10px", maxWidth: "100%" }}
/>
)}
</FormControl>
</ModalBody>
<ModalFooter>
<Button colorScheme="teal" mr={3} onClick={handleSubmit}>
Kaydet
</Button>
<Button variant="ghost" onClick={onClose}>
İptal
</Button>
</ModalFooter>
</ModalContent>
</Modal>
);
};

export default MagazineEditForm;
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function ThemeSwitcher() {
<>
<IconButton
id={"theme-switcher"}
_hover={{ color: colorMode === "light" ? "teal.500" : "teal.300" }}
aria-label="Color Switcher"
variant={"ghost"}
onClick={handleToggleColorMode}
Expand Down
Loading
Loading