Skip to content

Commit

Permalink
Avenmia/fix demographic survey size for mobile (#143)
Browse files Browse the repository at this point in the history
* Fixing demographic survey width

* Adding y overflow scroll on demographic survey

* Removing y scroll and justify content center on demographic survey

* Removing extra console.log statements
  • Loading branch information
avenmia authored Jul 31, 2023
1 parent 3a2ffb5 commit fa18696
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/components/survey/demographicssurvey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export default function DemographicsSurvey() {
);
};
return (
<div className="flex h-screen flex-col items-center justify-center">
<div className="flex h-screen flex-col items-center">
{surveyCompleted ? (
completedSurvey()
) : (
Expand Down
2 changes: 1 addition & 1 deletion src/components/survey/surveyquestion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default function SurveyQuestion({
}
};
return (
<div className="mt-8 flex w-[32rem] flex-col rounded-md bg-[#FFFFFF] px-8 py-8 shadow-xl">
<div className="mt-8 flex max-w-[32rem] flex-col rounded-md bg-[#FFFFFF] px-8 py-8 shadow-xl">
<h1 className="mb-8 font-semibold">
{surveyInfo.questionNumber + 1}. {question.question}
</h1>
Expand Down
43 changes: 25 additions & 18 deletions src/pages/api/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import multiparty from "multiparty";
import ObjectsToCsv from "objects-to-csv";
import csv from "csv-parser";
import fs from "fs";
import { authOptions } from './../../server/auth'
import { getServerSession } from "next-auth/next"
import { authOptions } from "./../../server/auth";
import { getServerSession } from "next-auth/next";

import { prisma } from "../../server/db";

Expand All @@ -17,12 +17,17 @@ export const config = {
},
};

export const authorizedEmails = fs.readFileSync(process.env.AUTHORIZED_POLIS_CONVERT_EMAILS_FILE, 'utf8').split(/\r?\n/);
console.log("Emails authorized to export POLIS data: " + authorizedEmails);
export const authorizedEmails = fs
.readFileSync(process.env.AUTHORIZED_POLIS_CONVERT_EMAILS_FILE, "utf8")
.split(/\r?\n/);

function handleError(error, res) {
console.error(error.stack);
res.status(500).end("Sorry, an error occured while processing a Pol.is export. The error has been logged for admistrators.");
res
.status(500)
.end(
"Sorry, an error occured while processing a Pol.is export. The error has been logged for admistrators."
);
}

const handler = nc({
Expand All @@ -31,7 +36,6 @@ const handler = nc({
res.status(404).end("Page is not found");
},
}).post(async (req, res) => {

const sessionData = await getServerSession(req, res, authOptions);

if (!sessionData) {
Expand All @@ -40,7 +44,9 @@ const handler = nc({
}
const email = sessionData.user.email;
if (!authorizedEmails.includes(email)) {
res.status(403).end(email + ", you are not authorized to export Pol.is data.");
res
.status(403)
.end(email + ", you are not authorized to export Pol.is data.");
return;
}

Expand Down Expand Up @@ -92,18 +98,19 @@ const handler = nc({
})
.on("end", function () {
// wait for all promises to be completed
Promise.all(output).then((resolved) => {
// convert all rows back to CSV
// TODO - remove numeral keys from object, so that they are not added as extra columns in export
new ObjectsToCsv(resolved).toString().then((text) => {
// write CSV to output stream
res.setHeader("Content-Type", "text/csv");
res.end(text);
Promise.all(output)
.then((resolved) => {
// convert all rows back to CSV
// TODO - remove numeral keys from object, so that they are not added as extra columns in export
new ObjectsToCsv(resolved).toString().then((text) => {
// write CSV to output stream
res.setHeader("Content-Type", "text/csv");
res.end(text);
});
})
.catch((error) => {
handleError(error, res);
});
})
.catch(error => {
handleError(error, res);
});
});
});
});
Expand Down
1 change: 0 additions & 1 deletion src/pages/loggedinas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ interface LoggedInAsProps {
}

export default function LoggedInAs({ email }: LoggedInAsProps) {
console.log("Email is:", email);
if (!email) {
return null;
}
Expand Down

1 comment on commit fa18696

@vercel
Copy link

@vercel vercel bot commented on fa18696 Jul 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

hierr – ./

hierr-git-main-codeforhawaii.vercel.app
hierr.vercel.app
hierr-codeforhawaii.vercel.app

Please sign in to comment.