Yash-Ainapure / dypcetclubs.live

An initaitive repository for managing all college clubs and there Hiring process through a website. deployed backend on : https://dypcetclubs-live.onrender.com
https://dypcetclubs-live.vercel.app
MIT License
14 stars 34 forks source link

Displaying the club info #111

Open Gauravtb2253 opened 6 days ago

Gauravtb2253 commented 6 days ago

Hello I would like to work on displaying the club with their members. Pls assign me

Yash-Ainapure commented 6 days ago

Hello I would like to work on displaying the club with their members. Pls assign me

But first we have to create a the add club memebers functionality. refer the prisma schema,i have made tables in db.

Gauravtb2253 commented 5 days ago

Actually I am getting some error while adding new club member can you pls guide for this

image

I have compiled the ts code and also included proper routes and functions in the backend

It would be nice if you tell something like what can I do or if you have faced similar kind of error before

Thank you

Yash-Ainapure commented 5 days ago

Actually I am getting some error while adding new club member can you pls guide for this

image

I have compiled the ts code and also included proper routes and functions in the backend

It would be nice if you tell something like what can I do or if you have faced similar kind of error before

Thank you

Could you try logging the whole error message so that we can find the solution?

Yash-Ainapure commented 5 days ago

I think this could be some problems:

  1. change the backend url to localhost from file axiosInstance.tsx.
  2. the backend cold starts when starting at first for at least 1min so wait for 1min to check again when you request for the first time. 3.I tried to ceate a route to add members which worked for me to add the club member through postman . here is the code:

export const addClubMember = async (req: Request, res: Response) => {
  try {
    const { ClubID } = req.body;
    if (!ClubID) {
      logger.warn("Attempted to add club member with missing required fields.");
      return res
        .status(400)
        .json({ error: "ClubID is required." });
    }

    const newMember = await prisma.clubMember.create({
      data: {
        ClubID,
        FirstName: req.body.FirstName,
        LastName: req.body.LastName,
        Email: req.body.Email,
        Role: req.body.Role,
        JoinDate: req.body.JoinDate,
        ProfileImageURL: req.body.ProfileImageURL,
      },
    });

    logger.info(`New member added to ClubID: ${ClubID}`);
    res.status(201).json(newMember);
  } catch (error) {
    logger.error(`Error adding club member: ${error}`);
    res
      .status(500)
      .json({ error: "An error occurred while adding club member."+error });
  }
};

you can verify this by sending request through: http://localhost:4000/api/clubs/addMember

demo data: { "ClubID":10, "FirstName":"Sami", "LastName":"Bhangaonkar", "Email":"sami@gmail.com", "Role":"developer", "JoinDate":"10/10/2024", "ProfileImageURL":"https://demo.png"
}

Yash-Ainapure commented 5 days ago

@Gauravtb2253 , try these solutions or you can tell me to do the backend stuff for you

Gauravtb2253 commented 5 days ago

export const addClubMember = async (req: Request, res: Response) => { try { const { ClubID, FirstName, LastName, Email, Role, JoinDate, ProfileImageURL } = req.body;
console.log(req.body) if (!ClubID || !FirstName || !LastName) { logger.warn( "Attempted to add a club member with missing required fields." ); return res .status(400) .json({ error: "ClubID, FirstName, and LastName are required." }); } const newMember = await prisma.clubMember.create({ data: { FirstName, LastName, Email, Role, JoinDate, ProfileImageURL, Club: { connect: { ClubID } } }, }); logger.info( New member added to ClubID ${ClubID}: ${FirstName} ${LastName} ); res.status(201).json(newMember); } catch (error) { logger.error(Error adding club member: ${error}); res.status(500).json({ error: "Error adding club member" }); } };

this is my code for adding member

Gauravtb2253 commented 5 days ago

{ "ClubID": 1, "FirstName": "abc", "LastName": "def", "Email": "abc@gmail.com", "Role": "Member", "JoinDate": "2024-10-17", "ProfileImageURL": "url" }

this is demo data

Gauravtb2253 commented 5 days ago

I am getting internal server error

Yash-Ainapure commented 5 days ago

{ "ClubID": 1, "FirstName": "abc", "LastName": "def", "Email": "abc@gmail.com", "Role": "Member", "JoinDate": "2024-10-17", "ProfileImageURL": "url" }

this is demo data

Sorry but the club for club id 1 there is no club present, that's why the error was coming i think.

refer the below image for adding member to specific club with there id mentioned. when we login we get the club id in response for that logged club.use that to add the club member when adding thourgh the webaite.

Screenshot from 2024-10-17 18-16-56

Gauravtb2253 commented 5 days ago

Can you give me email and password for any one club pls for login purpose

Yash-Ainapure commented 5 days ago

Can you give me email and password for any one club pls for login purpose

demo@gmail.com pass: 123456

Gauravtb2253 commented 5 days ago

Bro when I am using localhost for adding a new club then I am unables to do it But when I do with the render url it works

Same with the case of login

So is there any setting that you need to do in your render backend server to add my route of adding club member

Gauravtb2253 commented 5 days ago

image

Yash-Ainapure commented 4 days ago

image

On backend file axiosInstance.tsx change the url from onrender backend url to http://localhost:4000 See, on render there isn't a route to add member ,its at your local,when we push these changes the onrender will work to addmember. just remember to change it back to onrender url when pushing.

Gauravtb2253 commented 4 days ago

the error is solved I will try to do the work till tonight

Yash-Ainapure commented 4 days ago

the error is solved I will try to do the work till tonight

ok,great

Yash-Ainapure commented 4 days ago

Just pull the latest changes or it could create conflicts further