const prisma = require("./prismaClient");

// Get Latest News
const getLatestNews = async () => {
  try {
    let latestNewsData = await prisma.latestNews.findMany();
    return latestNewsData;
  } catch (error) {
    console.log(8, error);
  }
};

// Get Slider Images Data
const getSliderImages = async () => {
  try {
    const sliderImageData = await prisma.sliderImages.findMany();
    return sliderImageData;
  } catch (error) {}
};

// Get All Home Data
const getAllHomeData = async () => {
  try {
    const AllHomeData = await prisma.homeData.findMany();
    return AllHomeData;
  } catch (error) {
    console.log(error);
  }
};

// Get missions & objectives
const getMissions = async () => {
  try {
    const missionData = await prisma.missions.findMany({
      include: {
        objectiveList: true,
      },
    });
    return missionData[0];
  } catch (error) {
    console.log(error);
  }
};

// Get Former Chairmen
const getFormerChairmen = async () => {
  try {
    const FormerChairmenData = await prisma.formerChairman.findMany();
    return FormerChairmenData;
  } catch (error) {
    console.log(error);
  }
};

// Get Former Sr Vice Chairmen
const getFormerSrViceChairmen = async () => {
  try {
    const FormerChairmenData = await prisma.formerSrViceChairman.findMany();
    return FormerChairmenData;
  } catch (error) {
    console.log(error);
  }
};

// Get Former Vice Chairmen
const getFormerViceChairmen = async () => {
  try {
    const FormerChairmenData = await prisma.formerViceChairman.findMany();
    return FormerChairmenData;
  } catch (error) {
    console.log(error);
  }
};

// Get Board of Directors
const getBOD = async () => {
  try {
    const BODData = await prisma.boardOfDirectors.findMany();
    return BODData;
  } catch (error) {
    console.log(error);
  }
};

// Get Brief
const getBrief = async () => {
  try {
    const BriefData = await prisma.briefData.findMany();
    return BriefData;
  } catch (error) {
    console.log(error);
  }
};

// Get Service
const getService = async () => {
  try {
    const serviceData = await prisma.serviceData.findMany();
    return serviceData;
  } catch (error) {
    console.log(error);
  }
};

//  Get Activities
const getActivities = async () => {
  try {
    const activityData = await prisma.activitiesData.findMany();
    return activityData;
  } catch (error) {
    console.log(error);
  }
};

// Get Chairman Profile
const getChairmanProfile = async () => {
  try {
    const chairmanProfile = await prisma.chairmanProfile.findMany({
      include: {
        clubs: true,
        associations: true,
      },
    });
    return chairmanProfile;
  } catch (error) {
    console.log(error);
  }
};

// Get Secretariat
const getSecretariat = async () => {
  try {
    const secretariat = await prisma.secretariat.findMany();
    return secretariat;
  } catch (error) {
    console.log(error);
  }
};

// Get Memorandum
const getMemorandum = async () => {
  try {
    const memorandum = await prisma.memorandum.findMany();
    return memorandum;
  } catch (error) {
    console.log(error);
  }
};

// Get Eligibility Data
const getEligibilityData = async () => {
  try {
    const eligiblity = await prisma.eligibility.findMany();
    return eligiblity;
  } catch (error) {
    console.log(error);
  }
};

// Get Relevant Papers
const getRelevantPaper = async () => {
  try {
    const paper = await prisma.relevantPapers.findMany();
    return paper;
  } catch (error) {
    console.log(error);
  }
};

// Get Benefits of Member
const getBenefits = async () => {
  try {
    const benefits = await prisma.benefits.findMany();
    return benefits;
  } catch (error) {
    console.log(error);
  }
};

// Get Membership Texts
const getMembershipText = async () => {
  try {
    const membership = await prisma.membershipText.findMany();
    return membership;
  } catch (error) {
    console.log(error);
  }
};

// Get Application Procedure
const getApplication = async () => {
  try {
    const application = await prisma.applicationProcedure.findMany();
    return application;
  } catch (error) {
    console.log(error);
  }
};

// Get Upcoming Seminars
const getUpcomingSeminar = async () => {
  try {
    const data = await prisma.sCBSeminar.findMany({
      where: {
        type: "upcoming",
      },
    });
    return data;
  } catch (error) {
    console.log(error);
  }
};

// Get Previous Seminars
const getPrevSeminar = async () => {
  try {
    const data = await prisma.sCBSeminar.findMany({
      where: {
        type: "previous",
      },
    });
    return data;
  } catch (error) {
    console.log(error);
  }
};

// Get Chairman Message
const getChairMessage = async () => {
  try {
    const data = await prisma.chairmanMessage.findMany();
    return data;
  } catch (error) {
    console.log(error);
  }
};

// Get Chiarman Speech
const getChairSpeech = async () => {
  try {
    const data = await prisma.chairmanSpeech.findMany();
    return data;
  } catch (error) {
    console.log(error);
  }
};

// Get Chiarman Presentation
const getChairPresentation = async () => {
  try {
    const data = await prisma.chairmanPresentation.findMany();
    return data;
  } catch (error) {
    console.log(error);
  }
};

// Get Chiarman Interview Print
const getChairInterviewPrint = async () => {
  try {
    const data = await prisma.chairmanInterviewPrint.findMany();
    return data;
  } catch (error) {
    console.log(error);
  }
};

// Get Chiarman Interview Electronic
const getChairInterviewElectronic = async () => {
  try {
    const data = await prisma.chairmanInterviewElectronic.findMany();
    return data;
  } catch (error) {
    console.log(error);
  }
};

// Get Ordinary Members
const getOrdinaryMember = async () => {
  try {
    const data = await prisma.membersList.findMany({
      where: {
        type: "ordinary",
      },
    });
    return data;
  } catch (error) {
    console.log(error);
  }
};

// Get Associate Members
const getAssociateMember = async () => {
  try {
    const data = await prisma.membersList.findMany({
      where: {
        type: "associate",
      },
    });
    return data;
  } catch (error) {
    console.log(error);
  }
};

// Get Members
const getMember = async () => {
  try {
    const data = await prisma.membersList.findMany();
    return data;
  } catch (error) {
    console.log(error);
  }
};

// Get Shippers News
const getNews = async () => {
  try {
    const data = await prisma.shippersNews.findMany();
    return data;
  } catch (error) {
    console.log(error);
  }
};

// Get Annual Reports
const getAnnualReport = async () => {
  try {
    const data = await prisma.annualReport.findMany();
    return data;
  } catch (error) {
    console.log(error);
  }
};

// Get Other Publications
const getOtherPub = async () => {
  try {
    const data = await prisma.otherPublications.findMany();
    return data;
  } catch (error) {
    console.log(error);
  }
};

// Get Budget
const getBudget = async () => {
  try {
    const data = await prisma.sCBRecommendations.findMany({
      where: {
        type: "budget",
      },
    });
    return data;
  } catch (error) {
    console.log(error);
  }
};

// Get Ports
const getPort = async () => {
  try {
    const data = await prisma.sCBRecommendations.findMany({
      where: {
        type: "port",
      },
    });
    return data;
  } catch (error) {
    console.log(error);
  }
};

const getAffiliates = async () => {
  try {
    const data = await prisma.affiliates.findMany();
    return data;
  } catch (error) {
    console.log(error);
  }
};

// Get All Photos
const getAllPhotos = async () => {
  try {
    const data = await prisma.photoAlbum.findMany({
      include: {
        photos: true,
      },
    });
    return data;
  } catch (error) {
    console.log(error);
  }
};

// Get Gallery Videos
const getVideos = async () => {
  try {
    const data = await prisma.galleryVideo.findMany();
    return data;
  } catch (error) {
    console.log(error);
  }
};

// Get Condolence
const getCondolence = async () => {
  try {
    const data = await prisma.condolence.findMany();
    return data;
  } catch (error) {
    console.log(error);
  }
};

// Get Useful Links
const getUsefulLinks = async () => {
  try {
    const data = await prisma.usefulLinks.findMany();
    return data;
  } catch (error) {
    console.log(error);
  }
};

module.exports = {
  getBudget,
  getLatestNews,
  getSliderImages,
  getMissions,
  getAllHomeData,
  getFormerChairmen,
  getFormerSrViceChairmen,
  getFormerViceChairmen,
  getBOD,
  getBrief,
  getService,
  getActivities,
  getChairmanProfile,
  getSecretariat,
  getMemorandum,
  getEligibilityData,
  getRelevantPaper,
  getBenefits,
  getMembershipText,
  getApplication,
  getUpcomingSeminar,
  getPrevSeminar,
  getChairMessage,
  getChairSpeech,
  getChairPresentation,
  getChairInterviewPrint,
  getChairInterviewElectronic,
  getOrdinaryMember,
  getAssociateMember,
  getMember,
  getNews,
  getAnnualReport,
  getOtherPub,
  getPort,
  getAffiliates,
  getAllPhotos,
  getVideos,
  getCondolence,
  getUsefulLinks,
};
