diff --git a/public/404.html b/public/404.html index 730d5924..7079b8cf 100644 --- a/public/404.html +++ b/public/404.html @@ -1,4 +1,4 @@ - + @@ -24,4 +24,4 @@ - \ No newline at end of file + diff --git a/src/App.jsx b/src/App.jsx index 6e5f48f3..6a6af780 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,27 +1,25 @@ -import { Provider } from 'react-redux' -import { store } from './app/store' -import { BrowserRouter } from 'react-router-dom' -import Routers from './routes/Routers' -import { LocalizationProvider } from '@mui/x-date-pickers' -import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs' -import 'dayjs/locale/de' -import './App.css' -import 'bootstrap/dist/css/bootstrap.min.css' -import { Toaster } from 'react-hot-toast' - -function App() { - return ( - <> - - - - - - - - - - ) -} - -export default App +import { Provider } from 'react-redux' +import { store } from './app/store' +import { BrowserRouter } from 'react-router-dom' +import Routers from './routes/Routers' +import './App.css' +import 'bootstrap/dist/css/bootstrap.min.css' +import { Toaster } from 'react-hot-toast'; + + +import Books from './pages/user/Books_catalog/Books' + +function App() { + return ( + <> + + + + + + + + ) +} + +export default App diff --git a/src/common_components/IssueNoticeCards/Cards.jsx b/src/common_components/IssueNoticeCards/Cards.jsx new file mode 100644 index 00000000..1c40a437 --- /dev/null +++ b/src/common_components/IssueNoticeCards/Cards.jsx @@ -0,0 +1,51 @@ +import React from 'react'; +import Tooltip from '@mui/material/Tooltip' +import './cardsStyle.css'; + +const Cards = ({ notice, onDelete }) => { + const monthname = { + '01': 'January', + '02': 'February', + '03': 'March', + '04': 'April', + '05': 'May', + '06': 'June', + '07': 'July', + '08': 'August', + '09': 'September', + '10': 'October', + '11': 'November', + '12': 'December', + }; + + const formatDate = (dateString) => { + // Split the date string and construct a new Date object + const [day, month, year] = dateString.split('-'); + const date = new Date(`${year}-${month}-${day}`); + + // Extract day and add ordinal suffix + const dayWithSuffix = (day) => { + const suffixes = ["th", "st", "nd", "rd"]; + const mod100 = day % 100; + return day + (suffixes[(mod100 - 20) % 10] || suffixes[mod100] || suffixes[0]); + }; + + const dayFormatted = dayWithSuffix(date.getDate()); + return `Date of Issue: ${dayFormatted} ${monthname[month]}, ${year}`; + }; + + return ( +
+ +

{notice.heading}

+
+

{formatDate(notice.issue_date)}

+

Status: Active

+
+ +
+
+ ); +}; + +export default Cards; diff --git a/src/common_components/IssueNoticeCards/cardsStyle.css b/src/common_components/IssueNoticeCards/cardsStyle.css new file mode 100644 index 00000000..9d1bcdac --- /dev/null +++ b/src/common_components/IssueNoticeCards/cardsStyle.css @@ -0,0 +1,29 @@ +.box{ + margin: 1vw 0.5vw; + padding: 0vw 1vw; + /* height: 8vw; */ + width: 23vw; + border: 2px solid; + font-size: 1.1vw; + border-radius: 1vw; +} + +.subject{ + padding: 0.7vw 0vw 0.2vw; + font-size: 1.5vw; + color: #b24068; + width: 20.7vw; + overflow: hidden; +} + +.issue{ + line-height: 2; +} +.Mark{ + border: 2px solid #b24068; + width: fit-content; + color: #b24068; + margin: 1vw auto 0.5vw; + padding: 0.4vw 1.2vw; + border-radius: 0.6vw; +} \ No newline at end of file diff --git a/src/common_components/Navbar/NavbarStyles.js b/src/common_components/Navbar/NavbarStyles.js index 43b4741e..617ac9b5 100644 --- a/src/common_components/Navbar/NavbarStyles.js +++ b/src/common_components/Navbar/NavbarStyles.js @@ -1,109 +1,109 @@ -const navstyles = { - root_open: { - width: 230, - transition: 'width 0.3s', - overflowX: 'hidden', - bgcolor: '#4F0C24', - overflow: 'hidden', - color: 'white', - }, - root_closed: { - width: 80, - transition: 'width 0.3s', - overflowX: 'hidden', - bgcolor: '#4F0C24', - overflow: 'visible', - color: 'white', - }, - list: { height: '100%', display: 'flex', flexDirection: 'column' }, - titlebox: { - paddingX: 0, - paddingBottom: 4, - marginTop: 2, - marginBottom: 1, - justifyContent: 'center', - alignItems: 'center', - gap: 1, - }, - title: { - width: '100%', - display: 'flex', - justifyContent: 'center', - alignItems: 'center', - }, - icon: { - display: 'flex', - justifyContent: 'center', - width: 48, - height: 48, - }, - arrow: { justifyContent: 'right', marginBottom: 6, marginTop: 'auto' }, - option: { - display: 'flex', - flexDirection: 'column', - alignItems: 'center', - justifyContent: 'center', - paddingX: 0, - paddingY: 0, - borderBottom: '1px solid #FFFFFF', - borderTop: '1px solid #FFFFFF', - }, - pathbox: { - width: '100%', - display: 'flex', - justifyContent: 'space-between', - alignItems: 'center', - bgcolor: '#761236', - borderBottom: '1px solid #FFFFFF', - paddingRight: 0.5, - }, - pathtitle: { - bgcolor: '#761236', - color: '#FFFFFF', - textDecoration: 'none', - width: '100%', - display: 'flex', - paddingLeft: 1, - paddingY: 1, - }, - pathtitle_hover: { - bgcolor: '#761236', - color: '#999999', - textDecoration: 'none', - width: '100%', - display: 'flex', - paddingLeft: 1, - paddingY: 1, - }, - pathicon: { - display: 'flex', - marginRight: 1, - justifyContent: 'center', - alignItems: 'center', - }, - subpath: { - display: 'flex', - justifyContent: 'center', - color: '#FFFFFF', - textDecoration: 'none', - paddingY: 1.5, - '&:hover': { - color: '#999999', - }, - marginX: 'auto', - width: '90%', - }, - overlay: { - elevation: 1, - position: 'absolute', - left: '100%', - zIndex: 1, - paddingTop: 1, - paddingX: 2, - boxShadow: 3, - bgcolor: '#4F0C24', - color: 'white', - }, -} - -export default navstyles +const navstyles = { + root_open: { + width: 230, + transition: 'width 0.3s', + overflowX: 'hidden', + bgcolor: '#4F0C24', + overflow: 'hidden', + color: 'white', + }, + root_closed: { + width: 80, + transition: 'width 0.3s', + overflowX: 'hidden', + bgcolor: '#4F0C24', + overflow: 'visible', + color: 'white', + }, + list: { height: '100%', display: 'flex', flexDirection: 'column' }, + titlebox: { + paddingX: 0, + paddingBottom: 4, + marginTop: 2, + marginBottom: 1, + justifyContent: 'center', + alignItems: 'center', + gap: 1, + }, + title: { + width: '100%', + display: 'flex', + justifyContent: 'center', + alignItems: 'center', + }, + icon: { + display: 'flex', + justifyContent: 'center', + width: 48, + height: 48, + }, + arrow: { justifyContent: 'right', marginBottom: 6, marginTop: 'auto' }, + option: { + display: 'flex', + flexDirection: 'column', + alignItems: 'center', + justifyContent: 'center', + paddingX: 0, + paddingY: 0, + borderBottom: '1px solid #FFFFFF', + borderTop: '1px solid #FFFFFF', + }, + pathbox: { + width: '100%', + display: 'flex', + justifyContent: 'space-between', + alignItems: 'center', + bgcolor: '#761236', + borderBottom: '1px solid #FFFFFF', + paddingRight: 0.5, + }, + pathtitle: { + bgcolor: '#761236', + color: '#FFFFFF', + textDecoration: 'none', + width: '100%', + display: 'flex', + paddingLeft: 1, + paddingY: 1, + }, + pathtitle_hover: { + bgcolor: '#761236', + color: '#999999', + textDecoration: 'none', + width: '100%', + display: 'flex', + paddingLeft: 1, + paddingY: 1, + }, + pathicon: { + display: 'flex', + marginRight: 1, + justifyContent: 'center', + alignItems: 'center', + }, + subpath: { + display: 'flex', + justifyContent: 'center', + color: '#FFFFFF', + textDecoration: 'none', + paddingY: 1.5, + '&:hover': { + color: '#999999', + }, + marginX: 'auto', + width: '90%', + }, + overlay: { + elevation: 1, + position: 'absolute', + left: '100%', + zIndex: 0, + paddingTop: 1, + paddingX: 2, + boxShadow: 3, + bgcolor: '#4F0C24', + color: 'white', + }, +} + +export default navstyles diff --git a/src/pages/admin/IssueNotice/IssueNotice.jsx b/src/pages/admin/IssueNotice/IssueNotice.jsx new file mode 100644 index 00000000..7710c8ab --- /dev/null +++ b/src/pages/admin/IssueNotice/IssueNotice.jsx @@ -0,0 +1,71 @@ +import React, { useEffect, useState } from 'react' +import './style/IssueNotice.css' + +const IssueNotice = ({ fetchNoticesData }) => { + const apiURL = import.meta.env.VITE_APP_API_URL; + + const [header, setHeader] = useState("") + const [body, setBody] = useState("") + const [disable, setDisable] = useState(true) + + useEffect(() => { + setDisable(header === "" || body === ""); + }, [header, body]) + + const handleSubjectChange = (e) => { + setHeader(e.target.value); + } + + const handleContentChange = (e) => { + setBody(e.target.value); + } + + const publishNotice = async () => { + const data = { + heading: header, + body: body + }; + + try { + const response = await fetch(`${apiURL}/api/admin/notice/issue`, { + method: 'PUT', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(data) + }); + + if (response.ok) { + const result = await response.json(); + console.log('Details updated successfully:', result); + alert('Details updated successfully!'); + setHeader(""); + setBody(""); + fetchNoticesData(); // Refresh the notices list + } else { + console.error('Failed to update details:', response.statusText); + alert('Failed to update details!'); + } + } catch (error) { + console.error('Error:', error); + alert('Error occurred while updating details!'); + } + } + + return ( +
+

Issue a Notice

+
+ + +
+
+ + +
+ +
+ ) +} + +export default IssueNotice; diff --git a/src/pages/admin/IssueNotice/IssueNoticePage.jsx b/src/pages/admin/IssueNotice/IssueNoticePage.jsx new file mode 100644 index 00000000..97454b5b --- /dev/null +++ b/src/pages/admin/IssueNotice/IssueNoticePage.jsx @@ -0,0 +1,39 @@ +import React, { useEffect, useState } from 'react' +import IssueNotice from './IssueNotice' +import PreviousNotice from './PreviousNotice' + +const IssueNoticePage = () => { + const [notices, setNotices] = useState([]); + + const apiURL = import.meta.env.VITE_APP_API_URL; + + const fetchNoticesData = async () => { + try { + const response = await fetch(`${apiURL}/api/admin/notice/get-all-active`); + + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + + const data = await response.json(); + setNotices(data); + console.log('IssueNoticePage') + } catch (error) { + console.error('Error fetching data:', error); + setNotices([]); + } + }; + + useEffect(() => { + fetchNoticesData(); + }, []); // Ensure it only runs once after initial render + + return ( +
+ + {notices.length > 0 && } +
+ ) +} + +export default IssueNoticePage; diff --git a/src/pages/admin/IssueNotice/PreviousNotice.jsx b/src/pages/admin/IssueNotice/PreviousNotice.jsx new file mode 100644 index 00000000..5a4834e1 --- /dev/null +++ b/src/pages/admin/IssueNotice/PreviousNotice.jsx @@ -0,0 +1,42 @@ +import React, { useEffect, useState } from 'react'; +import './style/PreviousNotice.css'; +import Cards from '../../../common_components/IssueNoticeCards/Cards'; + +const PreviousNotice = ({ notices, fetchNoticesData }) => { + const apiURL = import.meta.env.VITE_APP_API_URL; + + const handleDeleteNotice = async (noticeId) => { + console.log(noticeId) + try { + const response = await fetch(`${apiURL}/api/admin/notice/mark-obsolete/noticeid/${noticeId}`, { + method: 'DELETE', + }); + + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + + const result = await response.json(); + console.log('Notice deleted successfully:', result); + alert('Notice deleted successfully!'); + + fetchNoticesData(); // Refresh the notices list + } catch (error) { + console.error('Error deleting notice:', error); + alert('Error occurred while deleting notice!'); + } + }; + + return ( +
+

Previous Notices

+
+ {notices.map((notice) => ( + + ))} +
+
+ ); +}; + +export default PreviousNotice; diff --git a/src/pages/admin/IssueNotice/style/IssueNotice.css b/src/pages/admin/IssueNotice/style/IssueNotice.css new file mode 100644 index 00000000..80787537 --- /dev/null +++ b/src/pages/admin/IssueNotice/style/IssueNotice.css @@ -0,0 +1,41 @@ +.content{ + width:60%; + /* background-color:#fbdbdb */ +} +.custom-heading{ + font-size: 2.5vw; + color: #4F0C24; + margin-bottom: 0.5vw; +} + +.Subject{ + margin: 1vw 0vw; + display: flex; + flex-direction: column; + color: #b24068; +} + +.custom-mark{ + font-size: 1.2vw; +} + +.subjectArea{ + margin: 0.5vw 0vw; + width: 98%; + font-size: 2vw; + font-weight: 300; + background-color: #f1e5e9; + color: black; + /* line-height: 1.6vw; */ + border: 2px solid #4F0C24; + border-radius: 0.5vw; + padding: 1vw; +} + +.Publish{ + width: 98%; + background-color: #4F0C24; + color: white; + padding: 1vw; + border-radius: 2vw; +} \ No newline at end of file diff --git a/src/pages/admin/IssueNotice/style/PreviousNotice.css b/src/pages/admin/IssueNotice/style/PreviousNotice.css new file mode 100644 index 00000000..b6460fbe --- /dev/null +++ b/src/pages/admin/IssueNotice/style/PreviousNotice.css @@ -0,0 +1,10 @@ +.custom-heading1{ + font-size: 2vw; + color: #4F0C24; + margin-bottom: 0.5vw; +} + +.Allcards{ + height: 80vh; + overflow: scroll; +} diff --git a/src/pages/admin/addbook/AddBook.css b/src/pages/admin/addbook/AddBook.css deleted file mode 100644 index bf9efcfc..00000000 --- a/src/pages/admin/addbook/AddBook.css +++ /dev/null @@ -1,61 +0,0 @@ -.input-form { - @apply flex gap-10 ml-10 mt-2 pb-4; -} - -.upload-container { - @apply w-3/4 max-w-96 flex flex-col h-full items-center; -} - -.inputfield { - @apply flex flex-col gap-2 pr-4 h-fit; -} - -.form-button { - @apply w-80 bg-red-500 text-white text-4xl rounded-md mt-10 py-2; -} - -.form-button.active { - @apply !bg-red-300; -} - -.form-grid { - @apply w-full grid grid-cols-1 lg:grid-cols-2 gap-10 h-fit; -} - -.form-container { - @apply flex flex-col lg:flex-row gap-10 w-fit; -} - -.image-upload { - @apply flex flex-col align-middle justify-between w-[95%] h-[60vh]; -} - -.image-upload .placeholder { - @apply flex justify-center items-center w-full h-full bg-gray-300 cursor-pointer; -} - -.image-upload .image-preview { - @apply w-full h-full object-cover cursor-pointer; -} - -.image-upload .upload-button { - @apply flex justify-center bg-blue-500 text-white py-1 px-2 rounded-md cursor-pointer mt-10; -} - -.image-upload .upload-button:hover { - background-color: #0056b3; -} - -.loading-overlay { - position: fixed; - top: 0; - left: 0; - right: 0; - bottom: 0; - background-color: rgba(0, 0, 0, 0.5); - display: flex; - justify-content: center; - align-items: center; - z-index: 2; -} - diff --git a/src/pages/admin/addbook/AddBook.jsx b/src/pages/admin/addbook/AddBook.jsx deleted file mode 100644 index 8907317d..00000000 --- a/src/pages/admin/addbook/AddBook.jsx +++ /dev/null @@ -1,226 +0,0 @@ -import { useState, useEffect } from 'react' -import { CircularProgress } from '@mui/material' -import { DatePicker } from '@mui/x-date-pickers' - -import CopyCounter from './CopyCounter' -import BookImageUpload from './BookImageUpload' -import InputTextField from './InputTextField' -import DescriptionField from './DescriptionField' -import DropdownSearch from './DropdownSearch' - -import addBook from '/src/services/addBook' -import fileUpload from '/src/services/fileUpload' - -import toast from 'react-hot-toast' -import dayjs from 'dayjs' -import { subjects, shelves, authors } from './searchdata' -import './AddBook.css' - -export const AddBook = () => { - const [bookTitle, setBookTitle] = useState('') - const [bookAuthor, setBookAuthor] = useState('') - const [bookSubject, setBookSubject] = useState('') - const [bookDescription, setBookDescription] = useState('') - const [bookISBN, setBookISBN] = useState('') - const [bookPublicationDate, setBookPublicationDate] = useState(null) - const [bookCopies, setBookCopies] = useState(1) - const [bookImage, setBookImage] = useState(null) - const [shelvingNumber, setShelvingNumber] = useState('') - const [bookEdition, setBookEdition] = useState(1) - const [loading, setLoading] = useState(false) - const [formValidity, setFormValidity] = useState(false) - - const inputFields = [ - { - type: 'text', - title: 'Title', - value: bookTitle, - setValue: setBookTitle, - maxWidth: '40vw', - pattern: /[\s\S]+/, - required: true, - }, - { - type: 'search', - title: 'Author', - suggestions: authors, - value: bookAuthor, - setValue: setBookAuthor, - maxWidth: '40vw', - required: true, - }, - { - type: 'text', - title: 'ISBN', - value: bookISBN, - setValue: setBookISBN, - maxWidth: '40vw', - pattern: /^[0-9]+(-[0-9]+)+$/, - required: true, - }, - { - type: 'text', - title: 'Edition', - value: bookEdition, - setValue: setBookEdition, - maxWidth: '200px', - pattern: /[\s\S]+/, - required: true, - }, - { - type: 'search', - title: 'Subject', - suggestions: subjects, - value: bookSubject, - setValue: setBookSubject, - maxWidth: '40vw', - required: true, - }, - { - type: 'search', - title: 'Shelving No.', - suggestions: shelves, - value: shelvingNumber, - setValue: setShelvingNumber, - maxWidth: '40vw', - required: false, - }, - ] - - useEffect(() => { - if ( - bookImage && - bookTitle && - bookAuthor && - bookSubject && - bookISBN && - bookEdition && - bookPublicationDate - ) { - setFormValidity(true) - } else { - setFormValidity(false) - } - }, [ - bookImage, - bookTitle, - bookAuthor, - bookSubject, - bookISBN, - bookEdition, - bookPublicationDate, - ]) - - useEffect(() => { - if (loading) { - inputFields.map((field) => { - field.setValue('') - }) - setBookPublicationDate(null) - setBookCopies(1) - setBookImage(null) - setBookDescription('') - } - }, [loading]) - - const handleSubmit = async (e) => { - e.preventDefault() - - // Checking for missing fields - inputFields.map((field) => { - if (!field.value) return - }) - if (!bookImage) return - - setLoading(true) - try { - const url = await fileUpload({ file: bookImage }) - - const req = { - shelving_no: shelvingNumber.title, - isbn: bookISBN, - date_of_publication: dayjs(bookPublicationDate).format('DD-MM-YYYY'), - edition: parseInt(bookEdition), - no_of_copies: bookCopies, - title: bookTitle, - cover_img: url, - author_name: bookAuthor.title, - sub_name: bookSubject.title, - description: bookDescription, - } - - console.log(req) - addBook(req) - .then((res) => { - console.log(res) - setLoading(false) - toast.success('Book added successfully') - }) - .catch((err) => { - console.log(err) - toast.error(err.message) - }) - } catch (error) { - console.log(error) - } - } - - return ( -
- {loading && ( -
- {' '} - {' '} -
- )} -
- - -
-
- {inputFields.map((field, index) => ( -
- {field.type === 'text' && } - {field.type === 'search' && } -
- ))} -
- -
-
-
-
-

{`Publication Date`}

-

*

-
- { - setBookPublicationDate(date) - }} - /> -
-
-

{`Number of Copies`}

- -
-
-
-
- ) -} diff --git a/src/pages/admin/addbook/BookImageUpload.jsx b/src/pages/admin/addbook/BookImageUpload.jsx deleted file mode 100644 index a12b7af6..00000000 --- a/src/pages/admin/addbook/BookImageUpload.jsx +++ /dev/null @@ -1,49 +0,0 @@ -import { useState, useEffect } from 'react' -import './AddBook.css' - -const BookImageUpload = ({ setImage, loading }) => { - const [imagePreview, setImagePreview] = useState(null) - - useEffect(() => { - if (loading) { - setImagePreview(null) - } - }, [loading]) - - const handleImageChange = (event) => { - const file = event.target.files[0] - if (file) { - const reader = new FileReader() - reader.onloadend = () => { - setImagePreview(reader.result) - setImage(file) - } - reader.readAsDataURL(file) - } - } - - const handleTriggerInput = () => { - document.getElementById('upload-button').click() - } - - return ( -
- {imagePreview ? ( - Book Cover - ) : ( -
- Select an image -
- )} - -
- ) -} - -export default BookImageUpload diff --git a/src/pages/admin/addbook/CopyCounter.jsx b/src/pages/admin/addbook/CopyCounter.jsx deleted file mode 100644 index 10ef9b48..00000000 --- a/src/pages/admin/addbook/CopyCounter.jsx +++ /dev/null @@ -1,29 +0,0 @@ -const CopyCounter = ({ bookCopies, setBookCopies }) => { - return ( -
- -

{bookCopies}

- -
- ) -} - -export default CopyCounter diff --git a/src/pages/admin/addbook/DescriptionField.jsx b/src/pages/admin/addbook/DescriptionField.jsx deleted file mode 100644 index 3ac160ad..00000000 --- a/src/pages/admin/addbook/DescriptionField.jsx +++ /dev/null @@ -1,20 +0,0 @@ -import { TextField } from '@mui/material' - -const DescriptionField = ({ bookDescription, setBookDescription }) => { - return ( - <> -

Description

- setBookDescription(e.target.value)} - sx={{ width: '50%', minWidth: '35vw' }} - multiline - /> - - ) -} - -export default DescriptionField diff --git a/src/pages/admin/addbook/DropdownSearch.jsx b/src/pages/admin/addbook/DropdownSearch.jsx deleted file mode 100644 index 983ce1cd..00000000 --- a/src/pages/admin/addbook/DropdownSearch.jsx +++ /dev/null @@ -1,89 +0,0 @@ -import * as React from 'react' -import TextField from '@mui/material/TextField' -import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete' - -const filter = createFilterOptions() - -export default function DropdownSearch({ - title, - suggestions, - value, - setValue, - maxWidth, - required, -}) { - return ( - <> - -

{title}

-

{required ? '*' : ''}

-
- { - if (typeof newValue === 'string') { - setValue({ - title: newValue, - }) - } else if (newValue && newValue.inputValue) { - // Create a new value from the user input - setValue({ - title: newValue.inputValue, - }) - } else { - setValue(newValue) - } - }} - filterOptions={(options, params) => { - const filtered = filter(options, params) - - const { inputValue } = params - // Suggest the creation of a new value - const isExisting = options.some( - (option) => inputValue === option.title - ) - if (inputValue !== '' && !isExisting) { - filtered.push({ - inputValue, - title: `Add "${inputValue}"`, - }) - } - - return filtered - }} - selectOnFocus - clearOnBlur - handleHomeEndKeys - options={suggestions} - getOptionLabel={(option) => { - // Value selected with enter, right from the input - if (typeof option === 'string') { - return option - } - // Add "xxx" option created dynamically - if (option.inputValue) { - return option.inputValue - } - // Regular option - return option.title - }} - renderOption={(props, option) => { - const { key, ...optionProps } = props - return ( -
  • - {option.title} -
  • - ) - }} - sx={{ width: '90%', maxWidth: maxWidth }} - freeSolo - renderInput={(params) => } - ListboxProps={{ - style: { - maxHeight: '200px', - }, - }} - /> - - ) -} diff --git a/src/pages/admin/addbook/InputTextField.jsx b/src/pages/admin/addbook/InputTextField.jsx deleted file mode 100644 index 024defbf..00000000 --- a/src/pages/admin/addbook/InputTextField.jsx +++ /dev/null @@ -1,47 +0,0 @@ -import { TextField } from '@mui/material' -import { useState } from 'react' - -const InputTextField = ({ - title, - value, - setValue, - maxWidth, - pattern, - required, -}) => { - const [valid, setValid] = useState(true) - - const handleChange = (e) => { - e.preventDefault() - - if (e.target.value === '' || !pattern.test(e.target.value)) { - setValid(false) - } else { - setValid(true) - } - - setValue(e.target.value) - } - - return ( - <> - -

    {title}

    -

    {required ? '*' : ''}

    -
    - - - ) -} - -export default InputTextField diff --git a/src/pages/admin/addbook/searchdata.js b/src/pages/admin/addbook/searchdata.js deleted file mode 100644 index ffab0c61..00000000 --- a/src/pages/admin/addbook/searchdata.js +++ /dev/null @@ -1,43 +0,0 @@ -export const subjects = [ - { title: "Mathematics" }, - { title: "Science" }, - { title: "History" }, - { title: "English" }, - { title: "Art" }, - { title: "Music" }, - { title: "Physical Education" }, - { title: "Computer Science" }, - { title: "Geography" }, - { title: "Economics" }, - { title: "Business" }, - { title: "Psychology" }, -] - -export const shelves = [ - { title: "sh-0-6" }, - { title: "sh-7-12" }, - { title: "sh-13-18" }, - { title: "sh-19-24" }, - { title: "sh-25-30" }, - { title: "sh-31-36" }, - { title: "sh-37-42" }, - { title: "sh-43-48" }, - { title: "sh-49-54" }, -] - -export const authors = [ - { title: "J.K. Rowling" }, - { title: "Stephen Hawking" }, - { title: "Richard Feynman" }, - { title: "Albert Einstein" }, - { title: "Isaac Newton" }, - { title: "Galileo Galilei" }, - { title: "Aristotle" }, - { title: "Plato" }, - { title: "Socrates" }, - { title: "Confucius" }, - { title: "Laozi" }, - { title: "Sun Tzu" }, - { title: "Niccolò Machiavelli" }, - { title: "Thomas Hobbes" }, -] diff --git a/src/pages/admin/index.js b/src/pages/admin/index.js index b6e8ffcc..80d483c8 100644 --- a/src/pages/admin/index.js +++ b/src/pages/admin/index.js @@ -1,7 +1,8 @@ -import { AdminHome } from './adminhome/AdminHome'; -import { Transaction } from './transactions/Transaction'; -import { Settings } from './Settings'; -import { AddBook } from './addbook/AddBook'; -import AdminBook from './Books_catalog/AdminBook' - -export { AdminHome, Transaction, Settings, AddBook, AdminBook }; +import { AdminHome } from './adminhome/AdminHome'; +import { Transaction } from './transactions/Transaction'; +import { Settings } from './Settings'; +import AdminBook from './Books_catalog/AdminBook' + +import IssueNoticePage from './IssueNotice/IssueNoticePage' + +export { AdminHome, Transaction, Settings,AdminBook,IssueNoticePage }; diff --git a/src/routes/NavigationPaths.js b/src/routes/NavigationPaths.js index 519fcede..8c9c1c4b 100644 --- a/src/routes/NavigationPaths.js +++ b/src/routes/NavigationPaths.js @@ -1,108 +1,108 @@ -export const adminNavItems = [ - /*{ - navPath: '/admin/', - navTitle: 'Home', - navIcon: '/src/assets/icons/home-linear.png', - navIconHover: '/src/assets/icons/home-bulk.png', - subpath: [] - },*/ - { - navPath: '/admin/book', - navTitle: 'Books', - navIcon: '/src/assets/icons/book-white.png', - navIconHover: '/src/assets/icons/book-white.png', - subPaths: [ - { - subPath: '/admin/book/add', - subTitle: 'Add/Edit a Book', - }, - { - subPath: '/admin/book/search', - subTitle: 'Search a Book', - }, - ] - }, - { - navPath: '/admin/transaction', - navTitle: 'Transactions', - navIcon: '/src/assets/icons/transaction-white.png', - navIconHover: '/src/assets/icons/transaction-white.png', - subPaths: [ - { - subPath: '/admin/transaction/issue', - subTitle: 'Issue a Book', - }, - { - subPath: '/admin/transaction/return', - subTitle: 'Return a book', - }, - { - subPath: '/admin/transaction/history', - subTitle: 'Transaction History', - }, - ] - }, - { - navPath: '/admin/issue_notice', - navTitle: 'Issue Notice', - navIcon: '/src/assets/icons/notice-white.png', - navIconHover: '/src/assets/icons/notice-white.png', - subPaths: [], - }, - { - navPath: '/admin/settings', - navTitle: 'Settings', - navIcon: '/src/assets/icons/setting-white.png', - navIconHover: '/src/assets/icons/setting-white.png', - subPaths: [ - { - subPath: '/admin/settings/library', - subTitle: 'Library Settings', - }, - { - subPath: '/admin/settings/profile', - subTitle: 'Admin Profile Settings', - } - ] - }, -] - -export const userNavItems = [ - { - navPath: '/user/', - navTitle: 'Home', - navIcon: '/src/assets/icons/home-linear.png', - navIconHover: '/src/assets/icons/home-bulk.png', - subPaths: [], - }, - { - navPath: '/user/book', - navTitle: 'Books', - navIcon: '/src/assets/icons/book-linear.png', - navIconHover: '/src/assets/icons/book-bulk.png', - subPaths: [], - }, - { - navPath: '/user/my_books', - navTitle: 'My Books', - navIcon: '/src/assets/icons/book2-linear.png', - navIconHover: '/src/assets/icons/book2-bulk.png', - subPaths: [], - }, - { - navPath: '/user/profile', - navTitle: 'Profile', - navIcon: '/src/assets/icons/profile2-linear.png', - navIconHover: '/src/assets/icons/profile2-bulk.png', - subPaths: [], - }, - { - navPath: '/user/help', - navTitle: 'Help', - navIcon: '/src/assets/icons/help-bulk.png', - navIconHover: '/src/assets/icons/help-bulk.png', - subPaths: [], - }, -] - - +export const adminNavItems = [ + /*{ + navPath: '/admin/', + navTitle: 'Home', + navIcon: '/src/assets/icons/home-linear.png', + navIconHover: '/src/assets/icons/home-bulk.png', + subpath: [] + },*/ + { + navPath: '/admin/books', + navTitle: 'Books', + navIcon: '/src/assets/icons/book-white.png', + navIconHover: '/src/assets/icons/book-white.png', + subPaths: [ + { + subPath: '/admin/books/add', + subTitle: 'Add/Edit a Book', + }, + { + subPath: '/admin/books/search', + subTitle: 'Search a Book', + }, + ] + }, + { + navPath: '/admin/transaction', + navTitle: 'Transactions', + navIcon: '/src/assets/icons/transaction-white.png', + navIconHover: '/src/assets/icons/transaction-white.png', + subPaths: [ + { + subPath: '/admin/transaction/issue', + subTitle: 'Issue a Book', + }, + { + subPath: '/admin/transaction/return', + subTitle: 'Return a book', + }, + { + subPath: '/admin/transaction/history', + subTitle: 'Transaction History', + }, + ] + }, + { + navPath: '/admin/issue_notice', + navTitle: 'Issue Notice', + navIcon: '/src/assets/icons/notice-white.png', + navIconHover: '/src/assets/icons/notice-white.png', + subPaths: [], + }, + { + navPath: '/admin/settings', + navTitle: 'Settings', + navIcon: '/src/assets/icons/setting-white.png', + navIconHover: '/src/assets/icons/setting-white.png', + subPaths: [ + { + subPath: '/admin/settings/library', + subTitle: 'Library Settings', + }, + { + subPath: '/admin/settings/profile', + subTitle: 'Admin Profile Settings', + } + ] + }, +] + +export const userNavItems = [ + { + navPath: '/user/', + navTitle: 'Home', + navIcon: '/src/assets/icons/home-linear.png', + navIconHover: '/src/assets/icons/home-bulk.png', + subPaths: [], + }, + { + navPath: '/user/books', + navTitle: 'Books', + navIcon: '/src/assets/icons/book-linear.png', + navIconHover: '/src/assets/icons/book-bulk.png', + subPaths: [], + }, + { + navPath: '/user/my_books', + navTitle: 'My Books', + navIcon: '/src/assets/icons/book2-linear.png', + navIconHover: '/src/assets/icons/book2-bulk.png', + subPaths: [], + }, + { + navPath: '/user/profile', + navTitle: 'Profile', + navIcon: '/src/assets/icons/profile2-linear.png', + navIconHover: '/src/assets/icons/profile2-bulk.png', + subPaths: [], + }, + { + navPath: '/user/help', + navTitle: 'Help', + navIcon: '/src/assets/icons/help-bulk.png', + navIconHover: '/src/assets/icons/help-bulk.png', + subPaths: [], + }, +] + + diff --git a/src/routes/Routers.jsx b/src/routes/Routers.jsx index b4963f7b..f7b9ce66 100644 --- a/src/routes/Routers.jsx +++ b/src/routes/Routers.jsx @@ -1,51 +1,35 @@ -import { Route, Routes } from 'react-router-dom' - -import { Help, Profile, UserHome, LandingPage, Books } from '../pages/user' -import { AdminHome, Transaction, Settings, AddBook, AdminBook } from '../pages/admin' -import ShowBookDetails from '../common_components/ViewBookDetails/ShowBookDetails' -import { userNavItems, adminNavItems } from './NavigationPaths' -import Layout from './Layout' - -const Routers = () => { - return ( - - - Library Management System } /> - } - > - } /> - } /> - - } /> - } - /> - - } /> - } /> - - } - > - } /> - } /> - } /> - - } /> - } - /> - } /> - - - - - ) -} - -export default Routers +import { Route, Routes } from 'react-router-dom' +import { Help, Profile, UserHome, LandingPage, Books } from '../pages/user'; +import { AdminHome, Transaction, Settings, AdminBook, IssueNoticePage} from '../pages/admin'; +import Layout from './Layout'; +import { userNavItems, adminNavItems } from './NavigationPaths'; +import ShowBookDetails from '../common_components/ViewBookDetails/ShowBookDetails' +import Footer from '../common_components/footer/Footer'; +const Routers = () => { + return ( + + + Library Management System } /> + }> + } /> + } /> + } /> + } /> + } /> + } /> + + }> + } /> + } /> + } /> + } /> + } /> + } /> + + + + + ) +} + +export default Routers \ No newline at end of file diff --git a/src/services/addBook.js b/src/services/addBook.js deleted file mode 100644 index 0485933f..00000000 --- a/src/services/addBook.js +++ /dev/null @@ -1,18 +0,0 @@ -const addBook = async (req) => { - const API_URL = import.meta.env.VITE_APP_API_URL; - const ADMIN_PATH = import.meta.env.VITE_APP_ADMIN_PATH; - - const res = await fetch(`${API_URL}/${ADMIN_PATH}/book/add`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify(req), - }); - - const data = await res.json(); - - return data; -} - -export default addBook; diff --git a/src/services/fileUpload.js b/src/services/fileUpload.js deleted file mode 100644 index 7e3d82bd..00000000 --- a/src/services/fileUpload.js +++ /dev/null @@ -1,26 +0,0 @@ -import { Client, Storage } from 'appwrite' - -const fileUpload = async ({ file }) => { - const projectID = '6680176400125336f7f9' - const bucketID = '668017b400180c09e0b9' - const endpoint = 'https://cloud.appwrite.io/v1' - - const client = new Client().setEndpoint(endpoint).setProject(projectID) - - const storage = new Storage(client) - - //const uploadPromise = storage.createFile(bucketID, 'unique()', file) - - return storage.createFile(bucketID, 'unique()', file).then( - (response) => { - const url = `${endpoint}/storage/buckets/${bucketID}/files/${response.$id}/view?project=${projectID}` - console.log(url); - return url - }, - (error) => { - console.log(error) - } - ) -} - -export default fileUpload