Compare commits

...

3 Commits

Author SHA1 Message Date
Kailasdevdas dc3228a07a feat: email on inquiry 2026-04-16 14:03:50 +05:30
Kailasdevdas c21ab02c2a feat: add doctor image in the response 2026-04-16 11:17:42 +05:30
Kailasdevdas c282b1825e feat: add Bytescale image uploads 2026-04-14 17:33:21 +05:30
17 changed files with 539 additions and 207 deletions
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Doctor" ADD COLUMN "image" TEXT;
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Department" ADD COLUMN "image" TEXT;
@@ -0,0 +1,12 @@
-- CreateTable
CREATE TABLE "NewsImage" (
"id" SERIAL NOT NULL,
"url" TEXT NOT NULL,
"newsMediaId" INTEGER NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "NewsImage_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "NewsImage" ADD CONSTRAINT "NewsImage_newsMediaId_fkey" FOREIGN KEY ("newsMediaId") REFERENCES "NewsMedia"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+13 -2
View File
@@ -21,6 +21,7 @@ model Doctor {
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
doctorId String @unique doctorId String @unique
name String name String
image String?
designation String? designation String?
workingStatus String? workingStatus String?
qualification String? qualification String?
@@ -36,6 +37,8 @@ model Department {
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
departmentId String @unique departmentId String @unique
name String name String
image String?
para1 String? para1 String?
para2 String? para2 String?
@@ -189,16 +192,24 @@ model EmailConfig {
model NewsMedia { model NewsMedia {
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
headline String headline String
content String? content String?
firstPara String? firstPara String?
secondPara String? secondPara String?
author String? author String?
date DateTime? date DateTime?
images NewsImage[]
isActive Boolean @default(true) isActive Boolean @default(true)
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
} }
model NewsImage {
id Int @id @default(autoincrement())
url String
newsMediaId Int
newsMedia NewsMedia @relation(fields: [newsMediaId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
}
@@ -9,6 +9,7 @@ export const getAllDepartments = async (req, res) => {
const response = departments.map((dep) => ({ const response = departments.map((dep) => ({
departmentId: dep.departmentId, departmentId: dep.departmentId,
name: dep.name, name: dep.name,
image: dep.image ?? "",
para1: dep.para1 ?? "", para1: dep.para1 ?? "",
para2: dep.para2 ?? "", para2: dep.para2 ?? "",
para3: dep.para3 ?? "", para3: dep.para3 ?? "",
@@ -56,6 +57,7 @@ export const getDepartmentByName = async (req, res) => {
const response = { const response = {
departmentId: department.departmentId, departmentId: department.departmentId,
name: department.name, name: department.name,
image: department.image ?? "",
para1: department.para1 ?? "", para1: department.para1 ?? "",
para2: department.para2 ?? "", para2: department.para2 ?? "",
para3: department.para3 ?? "", para3: department.para3 ?? "",
@@ -78,8 +80,16 @@ export const getDepartmentByName = async (req, res) => {
export async function createDepartment(req, res) { export async function createDepartment(req, res) {
try { try {
const {departmentId, name, para1, para2, para3, facilities, services} = const {
req.body; departmentId,
name,
image,
para1,
para2,
para3,
facilities,
services,
} = req.body;
if (!departmentId || !name) { if (!departmentId || !name) {
return res return res
@@ -91,6 +101,7 @@ export async function createDepartment(req, res) {
data: { data: {
departmentId, departmentId,
name, name,
image,
para1, para1,
para2, para2,
para3, para3,
@@ -116,12 +127,13 @@ export const updateDepartment = async (req, res) => {
try { try {
const {departmentId} = req.params; const {departmentId} = req.params;
const {name, para1, para2, para3, facilities, services} = req.body; const {name, image, para1, para2, para3, facilities, services} = req.body;
const department = await prisma.department.update({ const department = await prisma.department.update({
where: {departmentId}, where: {departmentId},
data: { data: {
name, name,
image,
para1, para1,
para2, para2,
para3, para3,
+14 -3
View File
@@ -20,6 +20,7 @@ export const getAllDoctors = async (req, res) => {
SL_NO: String(index + 1), SL_NO: String(index + 1),
doctorId: doc.doctorId, doctorId: doc.doctorId,
name: doc.name, name: doc.name,
image: doc.image ?? "",
designation: doc.designation, designation: doc.designation,
workingStatus: doc.workingStatus, workingStatus: doc.workingStatus,
qualification: doc.qualification, qualification: doc.qualification,
@@ -87,6 +88,7 @@ export const getDoctorByDoctorId = async (req, res) => {
const response = { const response = {
doctorId: doctor.doctorId, doctorId: doctor.doctorId,
name: doctor.name, name: doctor.name,
image: doctor.image ?? "",
designation: doctor.designation, designation: doctor.designation,
workingStatus: doctor.workingStatus, workingStatus: doctor.workingStatus,
qualification: doctor.qualification, qualification: doctor.qualification,
@@ -143,6 +145,7 @@ export const getDoctorsByDepartmentId = async (req, res) => {
const result = doctors.map((d) => ({ const result = doctors.map((d) => ({
GG_ID: d.doctor.doctorId, GG_ID: d.doctor.doctorId,
Name: d.doctor.name, Name: d.doctor.name,
image: d.doctor.image ?? "",
})); }));
res.status(200).json({ res.status(200).json({
@@ -164,6 +167,7 @@ export const createDoctor = async (req, res) => {
const { const {
doctorId, doctorId,
name, name,
image,
designation, designation,
workingStatus, workingStatus,
qualification, qualification,
@@ -174,6 +178,7 @@ export const createDoctor = async (req, res) => {
data: { data: {
doctorId, doctorId,
name, name,
image,
designation, designation,
workingStatus, workingStatus,
qualification, qualification,
@@ -221,8 +226,14 @@ export const createDoctor = async (req, res) => {
export const updateDoctor = async (req, res) => { export const updateDoctor = async (req, res) => {
try { try {
const {doctorId} = req.params; const {doctorId} = req.params;
const {name, designation, workingStatus, qualification, departments} = const {
req.body; name,
designation,
image,
workingStatus,
qualification,
departments,
} = req.body;
const doctor = await prisma.doctor.findUnique({ const doctor = await prisma.doctor.findUnique({
where: {doctorId}, where: {doctorId},
@@ -236,7 +247,7 @@ export const updateDoctor = async (req, res) => {
await prisma.doctor.update({ await prisma.doctor.update({
where: {id: doctor.id}, where: {id: doctor.id},
data: {name, designation, workingStatus, qualification}, data: {name, designation, image, workingStatus, qualification},
}); });
const oldRelations = await prisma.doctorDepartment.findMany({ const oldRelations = await prisma.doctorDepartment.findMany({
@@ -1,5 +1,8 @@
import prisma from "../prisma/client.js"; import prisma from "../prisma/client.js";
import {sendEmail} from "../utils/sendEmail.js";
import {getEmailsByType} from "../utils/getEmailByTypes.js";
/* CREATE INQUIRY */ /* CREATE INQUIRY */
export const createInquiry = async (req, res) => { export const createInquiry = async (req, res) => {
try { try {
@@ -21,6 +24,28 @@ export const createInquiry = async (req, res) => {
message, message,
}, },
}); });
try {
const emailList = await getEmailsByType("INQUIRY");
if (emailList && emailList.length > 0) {
await sendEmail({
to: emailList,
subject: "New Inquiry Received",
html: `
<h2>New Inquiry</h2>
<p><b>Name:</b> ${fullName}</p>
<p><b>Phone:</b> ${number}</p>
<p><b>Email:</b> ${emailId}</p>
<p><b>Subject:</b> ${subject}</p>
<p><b>Message:</b> ${message}</p>
`,
});
}
} catch (err) {
console.error("Inquiry email failed:", err);
}
res.status(200).json({ res.status(200).json({
success: true, success: true,
@@ -7,8 +7,13 @@ export const getAllNews = async (req, res) => {
const page = parseInt(req.query.page); const page = parseInt(req.query.page);
const limit = parseInt(req.query.limit); const limit = parseInt(req.query.limit);
const includeImages = {
images: true,
};
if (!page && !limit) { if (!page && !limit) {
const news = await prisma.newsMedia.findMany({ const news = await prisma.newsMedia.findMany({
include: includeImages,
orderBy: { createdAt: "desc" }, orderBy: { createdAt: "desc" },
}); });
@@ -20,6 +25,10 @@ export const getAllNews = async (req, res) => {
SecondPara: n.secondPara, SecondPara: n.secondPara,
Date: n.date, Date: n.date,
Author: n.author, Author: n.author,
Images: n.images.map((img) => ({
id: img.id,
image: img.url,
})),
})); }));
return res.status(200).json({ return res.status(200).json({
@@ -36,6 +45,7 @@ export const getAllNews = async (req, res) => {
const [news, total] = await Promise.all([ const [news, total] = await Promise.all([
prisma.newsMedia.findMany({ prisma.newsMedia.findMany({
include: includeImages,
orderBy: { createdAt: "desc" }, orderBy: { createdAt: "desc" },
skip, skip,
take: currentLimit, take: currentLimit,
@@ -51,6 +61,10 @@ export const getAllNews = async (req, res) => {
SecondPara: n.secondPara, SecondPara: n.secondPara,
Date: n.date, Date: n.date,
Author: n.author, Author: n.author,
Images: n.images.map((img) => ({
id: img.id,
image: img.url,
})),
})); }));
return res.status(200).json({ return res.status(200).json({
@@ -80,6 +94,7 @@ export const getNewsById = async (req, res) => {
const n = await prisma.newsMedia.findUnique({ const n = await prisma.newsMedia.findUnique({
where: { id: Number(id) }, where: { id: Number(id) },
include: { images: true },
}); });
if (!n) { if (!n) {
@@ -97,6 +112,10 @@ export const getNewsById = async (req, res) => {
SecondPara: n.secondPara, SecondPara: n.secondPara,
Date: n.date, Date: n.date,
Author: n.author, Author: n.author,
Images: n.images.map((img) => ({
id: img.id,
image: img.url,
})),
}; };
return res.status(200).json({ return res.status(200).json({
@@ -116,7 +135,15 @@ export const getNewsById = async (req, res) => {
export const createNews = async (req, res) => { export const createNews = async (req, res) => {
try { try {
const { headline, content, firstPara, secondPara, date, author } = req.body; const {
headline,
content,
firstPara,
secondPara,
date,
author,
imageUrls,
} = req.body;
if (!headline) { if (!headline) {
return res.status(400).json({ return res.status(400).json({
@@ -133,7 +160,13 @@ export const createNews = async (req, res) => {
secondPara, secondPara,
date: date ? new Date(date) : null, date: date ? new Date(date) : null,
author, author,
images: imageUrls
? {
create: imageUrls.map((url) => ({ url })),
}
: undefined,
}, },
include: { images: true },
}); });
return res.status(201).json({ return res.status(201).json({
@@ -155,13 +188,21 @@ export const createNews = async (req, res) => {
export const updateNews = async (req, res) => { export const updateNews = async (req, res) => {
try { try {
const { id } = req.params; const { id } = req.params;
const { imageUrls, ...otherData } = req.body;
const news = await prisma.newsMedia.update({ const news = await prisma.newsMedia.update({
where: { id: Number(id) }, where: { id: Number(id) },
data: { data: {
...req.body, ...otherData,
date: req.body.date ? new Date(req.body.date) : undefined, date: req.body.date ? new Date(req.body.date) : undefined,
images: imageUrls
? {
deleteMany: {},
create: imageUrls.map((url) => ({ url })),
}
: undefined,
}, },
include: { images: true },
}); });
return res.status(200).json({ return res.status(200).json({
+8 -18
View File
@@ -8,6 +8,7 @@
"name": "frontend", "name": "frontend",
"version": "0.0.0", "version": "0.0.0",
"dependencies": { "dependencies": {
"@bytescale/sdk": "^3.53.0",
"@editorjs/code": "^2.9.4", "@editorjs/code": "^2.9.4",
"@editorjs/delimiter": "^1.4.2", "@editorjs/delimiter": "^1.4.2",
"@editorjs/editorjs": "^2.31.5", "@editorjs/editorjs": "^2.31.5",
@@ -115,7 +116,6 @@
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.0.tgz", "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.0.tgz",
"integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==", "integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@babel/code-frame": "^7.29.0", "@babel/code-frame": "^7.29.0",
"@babel/generator": "^7.29.0", "@babel/generator": "^7.29.0",
@@ -525,6 +525,12 @@
"node": ">=6.9.0" "node": ">=6.9.0"
} }
}, },
"node_modules/@bytescale/sdk": {
"version": "3.53.0",
"resolved": "https://registry.npmjs.org/@bytescale/sdk/-/sdk-3.53.0.tgz",
"integrity": "sha512-qCeNup3pSjaklXuBrO9JeKbozZEs/PjQEvuqCiOAWLBRl6lDjd0V9gRVYqyttPimXYFoV+J/7dmPWtK6RfOABQ==",
"license": "MIT"
},
"node_modules/@codexteam/icons": { "node_modules/@codexteam/icons": {
"version": "0.3.3", "version": "0.3.3",
"resolved": "https://registry.npmjs.org/@codexteam/icons/-/icons-0.3.3.tgz", "resolved": "https://registry.npmjs.org/@codexteam/icons/-/icons-0.3.3.tgz",
@@ -1760,7 +1766,6 @@
"resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-1.3.0.tgz", "resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-1.3.0.tgz",
"integrity": "sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw==", "integrity": "sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw==",
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": "^14.21.3 || >=16" "node": "^14.21.3 || >=16"
}, },
@@ -4093,7 +4098,6 @@
"integrity": "sha512-GYDxsZi3ChgmckRT9HPU0WEhKLP08ev/Yfcq2AstjrDASOYCSXeyjDsHg4v5t4jOj7cyDX3vmprafKlWIG9MXQ==", "integrity": "sha512-GYDxsZi3ChgmckRT9HPU0WEhKLP08ev/Yfcq2AstjrDASOYCSXeyjDsHg4v5t4jOj7cyDX3vmprafKlWIG9MXQ==",
"devOptional": true, "devOptional": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"undici-types": "~7.16.0" "undici-types": "~7.16.0"
} }
@@ -4104,7 +4108,6 @@
"integrity": "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==", "integrity": "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==",
"devOptional": true, "devOptional": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"csstype": "^3.2.2" "csstype": "^3.2.2"
} }
@@ -4115,7 +4118,6 @@
"integrity": "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==", "integrity": "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==",
"devOptional": true, "devOptional": true,
"license": "MIT", "license": "MIT",
"peer": true,
"peerDependencies": { "peerDependencies": {
"@types/react": "^19.2.0" "@types/react": "^19.2.0"
} }
@@ -4177,7 +4179,6 @@
"integrity": "sha512-XZzOmihLIr8AD1b9hL9ccNMzEMWt/dE2u7NyTY9jJG6YNiNthaD5XtUHVF2uCXZ15ng+z2hT3MVuxnUYhq6k1g==", "integrity": "sha512-XZzOmihLIr8AD1b9hL9ccNMzEMWt/dE2u7NyTY9jJG6YNiNthaD5XtUHVF2uCXZ15ng+z2hT3MVuxnUYhq6k1g==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@typescript-eslint/scope-manager": "8.57.0", "@typescript-eslint/scope-manager": "8.57.0",
"@typescript-eslint/types": "8.57.0", "@typescript-eslint/types": "8.57.0",
@@ -4468,7 +4469,6 @@
"integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"bin": { "bin": {
"acorn": "bin/acorn" "acorn": "bin/acorn"
}, },
@@ -4728,7 +4728,6 @@
} }
], ],
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"baseline-browser-mapping": "^2.9.0", "baseline-browser-mapping": "^2.9.0",
"caniuse-lite": "^1.0.30001759", "caniuse-lite": "^1.0.30001759",
@@ -5558,7 +5557,6 @@
"integrity": "sha512-XoMjdBOwe/esVgEvLmNsD3IRHkm7fbKIUGvrleloJXUZgDHig2IPWNniv+GwjyJXzuNqVjlr5+4yVUZjycJwfQ==", "integrity": "sha512-XoMjdBOwe/esVgEvLmNsD3IRHkm7fbKIUGvrleloJXUZgDHig2IPWNniv+GwjyJXzuNqVjlr5+4yVUZjycJwfQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/eslint-utils": "^4.8.0",
"@eslint-community/regexpp": "^4.12.1", "@eslint-community/regexpp": "^4.12.1",
@@ -5811,7 +5809,6 @@
"resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz",
"integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"accepts": "^2.0.0", "accepts": "^2.0.0",
"body-parser": "^2.2.1", "body-parser": "^2.2.1",
@@ -6466,7 +6463,6 @@
"resolved": "https://registry.npmjs.org/hono/-/hono-4.12.7.tgz", "resolved": "https://registry.npmjs.org/hono/-/hono-4.12.7.tgz",
"integrity": "sha512-jq9l1DM0zVIvsm3lv9Nw9nlJnMNPOcAtsbsgiUhWcFzPE99Gvo6yRTlszSLLYacMeQ6quHD6hMfId8crVHvexw==", "integrity": "sha512-jq9l1DM0zVIvsm3lv9Nw9nlJnMNPOcAtsbsgiUhWcFzPE99Gvo6yRTlszSLLYacMeQ6quHD6hMfId8crVHvexw==",
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=16.9.0" "node": ">=16.9.0"
} }
@@ -8131,7 +8127,6 @@
"resolved": "https://registry.npmjs.org/react/-/react-19.2.4.tgz", "resolved": "https://registry.npmjs.org/react/-/react-19.2.4.tgz",
"integrity": "sha512-9nfp2hYpCwOjAN+8TZFGhtWEwgvWHXqESH8qT89AT/lWklpLON22Lc8pEtnpsZz7VmawabSU0gCjnj8aC0euHQ==", "integrity": "sha512-9nfp2hYpCwOjAN+8TZFGhtWEwgvWHXqESH8qT89AT/lWklpLON22Lc8pEtnpsZz7VmawabSU0gCjnj8aC0euHQ==",
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=0.10.0" "node": ">=0.10.0"
} }
@@ -8141,7 +8136,6 @@
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.4.tgz", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.4.tgz",
"integrity": "sha512-AXJdLo8kgMbimY95O2aKQqsz2iWi9jMgKJhRBAxECE4IFxfcazB2LmzloIoibJI3C12IlY20+KFaLv+71bUJeQ==", "integrity": "sha512-AXJdLo8kgMbimY95O2aKQqsz2iWi9jMgKJhRBAxECE4IFxfcazB2LmzloIoibJI3C12IlY20+KFaLv+71bUJeQ==",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"scheduler": "^0.27.0" "scheduler": "^0.27.0"
}, },
@@ -8905,8 +8899,7 @@
"version": "4.2.1", "version": "4.2.1",
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.2.1.tgz", "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.2.1.tgz",
"integrity": "sha512-/tBrSQ36vCleJkAOsy9kbNTgaxvGbyOamC30PRePTQe/o1MFwEKHQk4Cn7BNGaPtjp+PuUrByJehM1hgxfq4sw==", "integrity": "sha512-/tBrSQ36vCleJkAOsy9kbNTgaxvGbyOamC30PRePTQe/o1MFwEKHQk4Cn7BNGaPtjp+PuUrByJehM1hgxfq4sw==",
"license": "MIT", "license": "MIT"
"peer": true
}, },
"node_modules/tailwindcss-animate": { "node_modules/tailwindcss-animate": {
"version": "1.0.7", "version": "1.0.7",
@@ -9113,7 +9106,6 @@
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
"devOptional": true, "devOptional": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"peer": true,
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
"tsserver": "bin/tsserver" "tsserver": "bin/tsserver"
@@ -9314,7 +9306,6 @@
"integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==", "integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"esbuild": "^0.27.0", "esbuild": "^0.27.0",
"fdir": "^6.5.0", "fdir": "^6.5.0",
@@ -9659,7 +9650,6 @@
"resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz", "resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz",
"integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==", "integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==",
"license": "MIT", "license": "MIT",
"peer": true,
"funding": { "funding": {
"url": "https://github.com/sponsors/colinhacks" "url": "https://github.com/sponsors/colinhacks"
} }
+1
View File
@@ -10,6 +10,7 @@
"preview": "vite preview" "preview": "vite preview"
}, },
"dependencies": { "dependencies": {
"@bytescale/sdk": "^3.53.0",
"@editorjs/code": "^2.9.4", "@editorjs/code": "^2.9.4",
"@editorjs/delimiter": "^1.4.2", "@editorjs/delimiter": "^1.4.2",
"@editorjs/editorjs": "^2.31.5", "@editorjs/editorjs": "^2.31.5",
+1
View File
@@ -3,6 +3,7 @@ import apiClient from "@/api/client";
export interface Department { export interface Department {
departmentId: string; departmentId: string;
name: string; name: string;
image?: string;
para1: string; para1: string;
para2: string; para2: string;
para3: string; para3: string;
+1
View File
@@ -3,6 +3,7 @@ import apiClient from "@/api/client";
export interface Doctor { export interface Doctor {
doctorId: string; doctorId: string;
name: string; name: string;
image?: string;
designation?: string; designation?: string;
workingStatus?: string; workingStatus?: string;
qualification?: string; qualification?: string;
@@ -0,0 +1,109 @@
import { useState, useRef } from "react";
import * as Bytescale from "@bytescale/sdk";
import { Button } from "@/components/ui/button";
import { User, X, Loader2 } from "lucide-react";
interface BytescaleUploaderProps {
value: string;
onChange: (url: string) => void;
folderPath: "/doctors" | "/departments" | "/news";
}
const uploadManager = new Bytescale.UploadManager({
apiKey: "public_223k2cv3MyaAxBeyALCfJa8EMLek",
});
export function BytescaleUploader({ value, onChange }: BytescaleUploaderProps) {
const [isUploading, setIsUploading] = useState(false);
const fileInputRef = useRef<HTMLInputElement>(null);
const onFileSelected = async (event: React.ChangeEvent<HTMLInputElement>) => {
const file = event.target.files?.[0];
if (!file) return;
setIsUploading(true);
try {
const { fileUrl } = await uploadManager.upload({
data: file,
path: {
folderPath: "/doctors",
},
});
onChange(fileUrl);
} catch (e: any) {
console.error("Upload Error:", e);
alert(`Error:\n${e.message}`);
} finally {
setIsUploading(false);
if (fileInputRef.current) fileInputRef.current.value = "";
}
};
return (
<div className="flex flex-col gap-2 p-3 border rounded-md bg-muted/5">
<div className="flex items-center gap-4">
<div className="relative">
{value ? (
<>
<img
src={value}
className="w-16 h-16 rounded-full object-cover border-2 border-primary/20"
alt="Doctor Profile"
/>
<button
type="button"
onClick={() => onChange("")}
className="absolute -top-1 -right-1 bg-destructive text-white rounded-full p-0.5 shadow-sm hover:scale-110 transition-transform"
>
<X className="w-3 h-3" />
</button>
</>
) : (
<div className="w-16 h-16 rounded-full bg-muted flex items-center justify-center">
{isUploading ? (
<Loader2 className="w-8 h-8 animate-spin text-primary" />
) : (
<User className="w-8 h-8 text-muted-foreground" />
)}
</div>
)}
</div>
<input
type="file"
ref={fileInputRef}
onChange={onFileSelected}
accept="image/jpeg,image/png,image/webp"
className="hidden"
/>
<Button
type="button"
variant="outline"
size="sm"
disabled={isUploading}
onClick={() => fileInputRef.current?.click()}
>
{isUploading ? (
<>
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
Uploading...
</>
) : value ? (
"Change Photo"
) : (
"Upload Photo"
)}
</Button>
</div>
{value && (
<p className="text-xs text-amber-600 pl-[72px]">
Make sure to save the changes by clicking the "Save Changes" button
at the bottom.
</p>
)}
</div>
);
}
+12
View File
@@ -1,5 +1,6 @@
import { useState, useEffect, useCallback } from "react"; import { useState, useEffect, useCallback } from "react";
import { AxiosError } from "axios"; import { AxiosError } from "axios";
import { BytescaleUploader } from "@/components/BytescaleUploader/BytescaleUploader";
import { import {
getDepartmentsApi, getDepartmentsApi,
@@ -45,6 +46,7 @@ import {
interface Department { interface Department {
departmentId: string; departmentId: string;
name: string; name: string;
image?: string;
para1: string; para1: string;
para2: string; para2: string;
para3: string; para3: string;
@@ -71,6 +73,7 @@ export default function DepartmentPage() {
const [form, setForm] = useState<Department>({ const [form, setForm] = useState<Department>({
departmentId: "", departmentId: "",
name: "", name: "",
image: "",
para1: "", para1: "",
para2: "", para2: "",
para3: "", para3: "",
@@ -132,6 +135,7 @@ export default function DepartmentPage() {
setForm({ setForm({
departmentId: "", departmentId: "",
name: "", name: "",
image: "",
para1: "", para1: "",
para2: "", para2: "",
para3: "", para3: "",
@@ -393,6 +397,14 @@ export default function DepartmentPage() {
</DialogHeader> </DialogHeader>
<div className="space-y-4"> <div className="space-y-4">
<div className="space-y-2">
<label className="text-sm font-semibold">Department Image</label>
<BytescaleUploader
value={form.image}
folderPath="/departments"
onChange={(url) => setForm({ ...form, image: url })}
/>
</div>
<Input <Input
name="departmentId" name="departmentId"
value={form.departmentId} value={form.departmentId}
+31 -7
View File
@@ -1,5 +1,8 @@
import { useState, useEffect, useCallback } from "react"; import { useState, useEffect, useCallback } from "react";
import { AxiosError } from "axios"; import { AxiosError } from "axios";
import { BytescaleUploader } from "@/components/BytescaleUploader/BytescaleUploader";
import { import {
getDoctorsApi, getDoctorsApi,
createDoctorApi, createDoctorApi,
@@ -36,6 +39,7 @@ import {
Trash, Trash,
ChevronLeft, ChevronLeft,
ChevronRight, ChevronRight,
User,
} from "lucide-react"; } from "lucide-react";
interface Department { interface Department {
@@ -72,6 +76,7 @@ export default function DoctorPage() {
const [form, setForm] = useState<any>({ const [form, setForm] = useState<any>({
doctorId: "", doctorId: "",
name: "", name: "",
image: "",
designation: "", designation: "",
workingStatus: "", workingStatus: "",
qualification: "", qualification: "",
@@ -161,6 +166,7 @@ export default function DoctorPage() {
setForm({ setForm({
doctorId: "", doctorId: "",
name: "", name: "",
image: "",
designation: "", designation: "",
workingStatus: "", workingStatus: "",
qualification: "", qualification: "",
@@ -177,6 +183,7 @@ export default function DoctorPage() {
setForm({ setForm({
doctorId: doc.doctorId, doctorId: doc.doctorId,
name: doc.name, name: doc.name,
image: doc.image || "",
designation: doc.designation, designation: doc.designation,
workingStatus: doc.workingStatus, workingStatus: doc.workingStatus,
qualification: doc.qualification, qualification: doc.qualification,
@@ -439,19 +446,31 @@ export default function DoctorPage() {
</Card> </Card>
<Dialog open={openModal} onOpenChange={setOpenModal}> <Dialog open={openModal} onOpenChange={setOpenModal}>
<DialogContent className="w-full !max-w-5xl max-h-[90vh] overflow-y-auto"> <DialogContent className="w-full !max-w-5xl h-[90vh] flex flex-col p-0 overflow-hidden">
<DialogHeader> <DialogHeader className="p-6 border-b bg-background z-10">
<DialogTitle className="text-2xl"> <DialogTitle className="text-2xl">
{editing ? "Edit Doctor" : "Add Doctor"} {editing ? "Edit Doctor" : "Add Doctor"}
</DialogTitle> </DialogTitle>
</DialogHeader> </DialogHeader>
<div className="grid grid-cols-1 md:grid-cols-2 gap-8 mt-6"> <div className="flex-1 overflow-y-auto p-6">
<div className="grid grid-cols-1 md:grid-cols-2 gap-8">
<div className="space-y-6"> <div className="space-y-6">
<h3 className="font-bold text-base border-b pb-2"> <h3 className="font-bold text-base border-b pb-2">
Basic Information Basic Information
</h3> </h3>
<div className="space-y-4"> <div className="space-y-4">
<div className="space-y-2">
<label className="text-sm font-semibold">
Doctor Photo
</label>
<BytescaleUploader
value={form.image}
folderPath="/doctors"
onChange={(url) => setForm({ ...form, image: url })}
/>
</div>
<div className="space-y-1"> <div className="space-y-1">
<label className="text-sm font-semibold">Doctor ID</label> <label className="text-sm font-semibold">Doctor ID</label>
<Input <Input
@@ -496,7 +515,9 @@ export default function DoctorPage() {
/> />
</div> </div>
<div className="space-y-1"> <div className="space-y-1">
<label className="text-sm font-semibold">Qualification</label> <label className="text-sm font-semibold">
Qualification
</label>
<Input <Input
name="qualification" name="qualification"
placeholder="MBBS, MD" placeholder="MBBS, MD"
@@ -520,8 +541,10 @@ export default function DoctorPage() {
type="button" type="button"
variant={isSelected ? "default" : "outline"} variant={isSelected ? "default" : "outline"}
size="sm" size="sm"
className="justify-start text-sm h-9" className="justify-start text-sm min-h-11 whitespace-normal break-words text-left py-2"
onClick={() => handleDepartmentToggle(dep.departmentId)} onClick={() =>
handleDepartmentToggle(dep.departmentId)
}
> >
{dep.name} {dep.name}
</Button> </Button>
@@ -586,8 +609,9 @@ export default function DoctorPage() {
)} )}
</div> </div>
</div> </div>
</div>
<DialogFooter className="mt-10 pt-6 border-t"> <DialogFooter className="p-6 border-t bg-background z-10 mt-0">
<Button <Button
variant="ghost" variant="ghost"
onClick={() => setOpenModal(false)} onClick={() => setOpenModal(false)}
+9 -4
View File
@@ -181,14 +181,16 @@ export default function EmailPage() {
<Button <Button
size="sm" size="sm"
variant="outline" variant="outline"
onClick={() => openEdit(item)}> onClick={() => openEdit(item)}
>
<Pencil className="h-4 w-4" /> <Pencil className="h-4 w-4" />
</Button> </Button>
<Button <Button
size="sm" size="sm"
variant="destructive" variant="destructive"
onClick={() => handleDelete(item.id)}> onClick={() => handleDelete(item.id)}
>
<Trash className="h-4 w-4" /> <Trash className="h-4 w-4" />
</Button> </Button>
</TableCell> </TableCell>
@@ -225,10 +227,12 @@ export default function EmailPage() {
name="type" name="type"
value={form.type} value={form.type}
onChange={handleChange} onChange={handleChange}
className="border rounded px-2 py-2 w-full"> className="border rounded px-2 py-2 w-full"
>
<option value="APPOINTMENT">APPOINTMENT</option> <option value="APPOINTMENT">APPOINTMENT</option>
<option value="CANDIDATE">CANDIDATE</option> <option value="CANDIDATE">CANDIDATE</option>
<option value="ACADEMICS">ACADEMICS</option> <option value="ACADEMICS">ACADEMICS</option>
<option value="INQUIRY">INQUIRY</option>
</select> </select>
<select <select
@@ -240,7 +244,8 @@ export default function EmailPage() {
isActive: e.target.value === "true", isActive: e.target.value === "true",
}) })
} }
className="border rounded px-2 py-2 w-full"> className="border rounded px-2 py-2 w-full"
>
<option value="true">Active</option> <option value="true">Active</option>
<option value="false">Inactive</option> <option value="false">Inactive</option>
</select> </select>
+99 -26
View File
@@ -1,4 +1,5 @@
import { useState, useEffect, useCallback } from "react"; import { useState, useEffect, useCallback } from "react";
import { BytescaleUploader } from "@/components/BytescaleUploader/BytescaleUploader";
import { import {
getNewsApi, getNewsApi,
@@ -39,6 +40,8 @@ import {
ChevronLeft, ChevronLeft,
ChevronRight, ChevronRight,
Newspaper, Newspaper,
ImageIcon,
X,
} from "lucide-react"; } from "lucide-react";
export default function NewsPage() { export default function NewsPage() {
@@ -60,6 +63,7 @@ export default function NewsPage() {
const [form, setForm] = useState({ const [form, setForm] = useState({
headline: "", headline: "",
content: "", content: "",
imageUrls: [] as string[],
firstPara: "", firstPara: "",
secondPara: "", secondPara: "",
date: "", date: "",
@@ -96,11 +100,19 @@ export default function NewsPage() {
setForm({ ...form, [e.target.name]: e.target.value }); setForm({ ...form, [e.target.name]: e.target.value });
} }
function removeImageUrl(index: number) {
setForm((prev) => ({
...prev,
imageUrls: prev.imageUrls.filter((_, i) => i !== index),
}));
}
function openAdd() { function openAdd() {
setEditing(null); setEditing(null);
setForm({ setForm({
headline: "", headline: "",
content: "", content: "",
imageUrls: [],
firstPara: "", firstPara: "",
secondPara: "", secondPara: "",
date: "", date: "",
@@ -114,6 +126,7 @@ export default function NewsPage() {
setForm({ setForm({
headline: item.Headline || "", headline: item.Headline || "",
content: item.Content || "", content: item.Content || "",
imageUrls: item.Images ? item.Images.map((img: any) => img.image) : [],
firstPara: item.FirstPara || "", firstPara: item.FirstPara || "",
secondPara: item.SecondPara || "", secondPara: item.SecondPara || "",
date: item.Date ? item.Date.split("T")[0] : "", date: item.Date ? item.Date.split("T")[0] : "",
@@ -205,6 +218,9 @@ export default function NewsPage() {
<TableHead className="w-[80px] bg-background font-bold"> <TableHead className="w-[80px] bg-background font-bold">
ID ID
</TableHead> </TableHead>
<TableHead className="w-[100px] bg-background font-bold">
Cover
</TableHead>
<TableHead className="w-[280px] bg-background font-bold"> <TableHead className="w-[280px] bg-background font-bold">
Headline Headline
</TableHead> </TableHead>
@@ -226,14 +242,14 @@ export default function NewsPage() {
<TableBody> <TableBody>
{loading ? ( {loading ? (
<TableRow> <TableRow>
<TableCell colSpan={6} className="text-center py-10"> <TableCell colSpan={7} className="text-center py-10">
<Loader2 className="h-8 w-8 animate-spin mx-auto text-primary" /> <Loader2 className="h-8 w-8 animate-spin mx-auto text-primary" />
</TableCell> </TableCell>
</TableRow> </TableRow>
) : filteredNews.length === 0 ? ( ) : filteredNews.length === 0 ? (
<TableRow> <TableRow>
<TableCell <TableCell
colSpan={6} colSpan={7}
className="text-center text-muted-foreground py-10 text-base" className="text-center text-muted-foreground py-10 text-base"
> >
No news articles found No news articles found
@@ -245,6 +261,19 @@ export default function NewsPage() {
<TableCell className="font-mono text-xs"> <TableCell className="font-mono text-xs">
{item.Id} {item.Id}
</TableCell> </TableCell>
<TableCell>
{item.Images?.[0] ? (
<img
src={item.Images[0].image}
className="w-10 h-10 object-cover rounded border"
alt="cover"
/>
) : (
<div className="w-10 h-10 bg-muted flex items-center justify-center rounded">
<ImageIcon className="w-4 h-4 text-muted-foreground" />
</div>
)}
</TableCell>
<TableCell> <TableCell>
<div <div
className="font-semibold text-base line-clamp-2" className="font-semibold text-base line-clamp-2"
@@ -343,20 +372,20 @@ export default function NewsPage() {
</Card> </Card>
<Dialog open={openModal} onOpenChange={setOpenModal}> <Dialog open={openModal} onOpenChange={setOpenModal}>
<DialogContent className="w-full !max-w-5xl max-h-[90vh] overflow-y-auto"> <DialogContent className="w-full !max-w-6xl max-h-[90vh] overflow-y-auto">
<DialogHeader> <DialogHeader>
<DialogTitle className="text-2xl font-bold"> <DialogTitle className="text-2xl font-bold">
{editing ? "Edit News Article" : "Add New News Article"} {editing ? "Edit News Article" : "Add New News Article"}
</DialogTitle> </DialogTitle>
</DialogHeader> </DialogHeader>
<div className="grid grid-cols-1 md:grid-cols-2 gap-8 mt-6"> <div className="grid grid-cols-1 lg:grid-cols-3 gap-8 mt-6">
<div className="space-y-6"> <div className="lg:col-span-2 space-y-6">
<h3 className="font-bold text-base border-b pb-2 text-primary"> <h3 className="font-bold text-base border-b pb-2 text-primary">
Article Information Article Information
</h3> </h3>
<div className="space-y-4"> <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div className="space-y-1"> <div className="space-y-1 col-span-2">
<label className="text-sm font-semibold">Headline</label> <label className="text-sm font-semibold">Headline</label>
<Input <Input
name="headline" name="headline"
@@ -385,35 +414,19 @@ export default function NewsPage() {
/> />
</div> </div>
</div> </div>
<div className="space-y-1 pt-2"> <div className="space-y-1">
<label className="text-sm font-semibold">Intro Paragraph</label> <label className="text-sm font-semibold">Intro Paragraph</label>
<Textarea <Textarea
name="firstPara" name="firstPara"
value={form.firstPara} value={form.firstPara}
onChange={handleChange} onChange={handleChange}
className="min-h-[140px] text-base" className="min-h-[100px] text-base"
/> />
</div> </div>
</div>
<div className="space-y-6">
<h3 className="font-bold text-base border-b pb-2 text-primary">
Story Details
</h3>
<div className="space-y-4">
<div className="space-y-1"> <div className="space-y-1">
<label className="text-sm font-semibold"> <label className="text-sm font-semibold">
Second Paragraph Full Story Content
</label> </label>
<Textarea
name="secondPara"
value={form.secondPara}
onChange={handleChange}
className="min-h-[140px] text-base"
/>
</div>
<div className="space-y-1">
<label className="text-sm font-semibold">Content</label>
<Textarea <Textarea
name="content" name="content"
value={form.content} value={form.content}
@@ -422,6 +435,55 @@ export default function NewsPage() {
/> />
</div> </div>
</div> </div>
{/* Image Management Sidebar */}
<div className="space-y-6 border-l pl-6">
<h3 className="font-bold text-base border-b pb-2 text-primary flex items-center gap-2">
<ImageIcon className="w-4 h-4" /> Gallery Management
</h3>
<div className="space-y-4">
<label className="text-sm font-semibold">Upload Images</label>
<BytescaleUploader
value=""
folderPath="/news"
onChange={(url) => {
if (url) {
setForm((prev) => ({
...prev,
imageUrls: [...prev.imageUrls, url],
}));
}
}}
/>
<div className="grid grid-cols-2 gap-2 max-h-[400px] overflow-y-auto pr-2 mt-4">
{form.imageUrls.map((url, index) => (
<div
key={index}
className="relative group border rounded-lg overflow-hidden h-24 bg-muted"
>
<img
src={url}
alt="upload"
className="w-full h-full object-cover"
/>
<button
type="button"
onClick={() => removeImageUrl(index)}
className="absolute top-1 right-1 bg-destructive text-white rounded-full p-1 opacity-0 group-hover:opacity-100 transition-opacity shadow-sm"
>
<X className="w-3 h-3" />
</button>
</div>
))}
</div>
{form.imageUrls.length === 0 && (
<p className="text-xs text-muted-foreground text-center py-10 border-2 border-dashed rounded-lg">
No images uploaded yet.
</p>
)}
</div>
</div> </div>
</div> </div>
@@ -470,6 +532,17 @@ export default function NewsPage() {
</div> </div>
</div> </div>
<div className="grid grid-cols-3 md:grid-cols-4 gap-2">
{viewData.Images?.map((img: any, i: number) => (
<img
key={i}
src={img.image}
className="w-full h-24 object-cover rounded-md border"
alt="gallery"
/>
))}
</div>
<div className="space-y-5 leading-relaxed text-base"> <div className="space-y-5 leading-relaxed text-base">
<div className="bg-muted/30 p-4 rounded-lg border-l-4 border-primary"> <div className="bg-muted/30 p-4 rounded-lg border-l-4 border-primary">
<p className="whitespace-pre-line">{viewData.FirstPara}</p> <p className="whitespace-pre-line">{viewData.FirstPara}</p>