Skip to content

Commit

Permalink
Added new ui changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aju-alen committed Oct 21, 2024
1 parent deda69e commit 3a65acd
Show file tree
Hide file tree
Showing 8 changed files with 971 additions and 471 deletions.
470 changes: 364 additions & 106 deletions api/controllers/excel-controller.js

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions api/controllers/survey-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const createNewSurvey = async (req, res) => {
surveyTitle,
surveyDescription: "Test",
userId,
surveyStatus: 'Active',
}
});
await prisma.$disconnect();
Expand Down Expand Up @@ -192,3 +193,22 @@ export const deleteUserSurvey = async (req, res) => {
}
}

export const updateUserStatus = async (req, res) => {
const surveyId = req.params.surveyId;
try {
const updateStatus = await prisma.survey.update({
where: {
id: surveyId
},
data: {
surveyStatus: req.body.surveyStatus
}
});
await prisma.$disconnect();
res.status(200).send({ message: 'Survey status updated successfully' });
}
catch (err) {
console.log(err);
res.status(500).send({ message: 'Internal server error' });
}
}
3 changes: 2 additions & 1 deletion api/routes/survey-route.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import express from 'express';
const router = express.Router();
import { createNewSurvey,getUserSurvey,getSurveyById,updateSurveyById,getAllSurveyResponse,getAllSurveyOfOneUser,updateUserView,deleteUserSurvey} from '../controllers/survey-controller.js';
import { createNewSurvey,getUserSurvey,getSurveyById,updateSurveyById,getAllSurveyResponse,getAllSurveyOfOneUser,updateUserView,deleteUserSurvey,updateUserStatus} from '../controllers/survey-controller.js';
import { apiCallLimiter } from '../middleware/rateLimiter.js'
import { verifyJwt } from '../middleware/verifyJwt.js';

Expand All @@ -13,6 +13,7 @@ router.get('/get-all-sruvey-from-oneuser/:userId',apiCallLimiter,verifyJwt, getA
router.put('/update-user-view/:surveyId',apiCallLimiter,verifyJwt, updateUserView); // Get all the survey of a particular user

router.delete('/delete-survey/:surveyId',apiCallLimiter,verifyJwt, deleteUserSurvey); // Get all the survey of a particular user
router.put('/update-survey-status/:surveyId',apiCallLimiter,verifyJwt, updateUserStatus)


export default router;
923 changes: 567 additions & 356 deletions client/package-lock.json

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion client/src/pages/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ const Dashboard = () => {
}
}, [userSurveyData]);

const handleDeleteSurveyFromParent = (surveyId) => {
console.log('delete survey from parent', surveyId);

setUserSurveyData(userSurveyData.filter((survey) => survey.id !== surveyId));
};


return isLoading ? (

<Box sx={{ display: 'flex', justifyContent: 'center', alignItems: "center", height: '100vh' }}>
Expand Down Expand Up @@ -160,7 +167,7 @@ const Dashboard = () => {
</Grid>


<MySurvery userSurveyData={userSurveyData} isSubscribed={isSubscribed} />
<MySurvery userSurveyData={userSurveyData} isSubscribed={isSubscribed} onDeleteSurvey={handleDeleteSurveyFromParent} />
<Snackbar open={open} autoHideDuration={6000} onClose={handleClose}>
<Alert onClose={handleClose} severity={alertColor} variant="filled" sx={{ width: '100%' }}>
{alertMessage}
Expand Down
9 changes: 5 additions & 4 deletions client/src/pages/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,19 @@ export default function Login() {
mt: 1,
display: 'flex',
justifyContent: 'center',

}}

>
<GoogleOAuthProvider clientId={import.meta.env.VITE_GOOGLE_LOGIN_CLIENT_ID}>
<div>
<h1>Google Login</h1>
{/* <GoogleOAuthProvider clientId={import.meta.env.VITE_GOOGLE_LOGIN_CLIENT_ID}>
<div >
<GoogleLogin
onSuccess={handleLoginSuccess}
onError={handleLoginError}
/>
</div>
</GoogleOAuthProvider>
</GoogleOAuthProvider> */}
</Box>
<Grid container>
<Grid item xs>
Expand Down
4 changes: 2 additions & 2 deletions client/src/pages/Register.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,15 @@ export default function Register() {

}}
>
<GoogleOAuthProvider clientId={import.meta.env.VITE_GOOGLE_LOGIN_CLIENT_ID}>
{/* <GoogleOAuthProvider clientId={import.meta.env.VITE_GOOGLE_LOGIN_CLIENT_ID}>
<div >
<GoogleLogin
onSuccess={handleLoginSuccess}
onError={handleLoginError}
/>
</div>
</GoogleOAuthProvider>
</GoogleOAuthProvider> */}
</Box>
<Grid container justifyContent="flex-end">
<Grid item>
Expand Down
4 changes: 3 additions & 1 deletion client/src/pages/UserSubmitSurvey.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,9 @@ const UserSubmitSurvey = () => {
<div className=" flex justify-center items-center h-screen">
{(surveyData.surveyResponses > 500) && (<h1 className=' font-bold text-blue-500 text-xl'> This survey has exceeded it's alloted responses. Please contact host.</h1>)}

{(introduction && welcomePage && surveyData.surveyResponses <= 500) && (<div className=" flex flex-col">
{(surveyData.surveyStatus !== 'Active') && (<h1 className=' font-bold text-blue-500 text-xl'> This survey is not active. Please contact host.</h1>)}

{(introduction && welcomePage && surveyData.surveyResponses <= 500 && surveyData.surveyStatus==='Active') && (<div className=" flex flex-col">
<h1 className=' font-bold text-blue-500 text-xl text-center'>Hello, welcome to the survey!</h1>


Expand Down

0 comments on commit 3a65acd

Please sign in to comment.