Skip to content

Commit

Permalink
chore: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
anandbaburajan committed Feb 19, 2023
1 parent 463568c commit c7f0e9c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const Home = (): JSX.Element => {

if (createPollResponse.statusCode === 201) {
if (typeof window !== "undefined") {
let kukkeeCreatedPolls = localStorage.getItem("kukkeeCreatedPolls");
const kukkeeCreatedPolls = localStorage.getItem("kukkeeCreatedPolls");

if (!kukkeeCreatedPolls) {
const initKukkeeCreatedPolls = {
Expand All @@ -129,15 +129,15 @@ const Home = (): JSX.Element => {
JSON.stringify(initKukkeeCreatedPolls)
);
} else {
kukkeeCreatedPolls = JSON.parse(kukkeeCreatedPolls);
let kukkeeCreatedPollsJSON = JSON.parse(kukkeeCreatedPolls);

kukkeeCreatedPolls.polls.push({
kukkeeCreatedPollsJSON.polls.push({
[`${createPollResponse.data._id}-${pollTitle}`]: `${encryptedSecret}`,
});

localStorage.setItem(
"kukkeeCreatedPolls",
JSON.stringify(kukkeeCreatedPolls)
JSON.stringify(kukkeeCreatedPollsJSON)
);
}
}
Expand Down
14 changes: 7 additions & 7 deletions pages/recent-polls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ const RecentPolls = (): JSX.Element => {
let votedPolls = [];

if (typeof window !== "undefined") {
let createdPollsFromLS = localStorage.getItem("kukkeeCreatedPolls");
const createdPollsFromLS = localStorage.getItem("kukkeeCreatedPolls");

if (createdPollsFromLS) {
createdPollsFromLS = JSON.parse(createdPollsFromLS);
const createdPollsFromLSJSON = JSON.parse(createdPollsFromLS);

for (let i = 0; i < createdPollsFromLS.polls.length; i += 1) {
createdPolls.push(createdPollsFromLS.polls[i]);
for (let i = 0; i < createdPollsFromLSJSON.polls.length; i += 1) {
createdPolls.push(createdPollsFromLSJSON.polls[i]);
}
}

let votedPollsFromLS = localStorage.getItem("kukkeeVotedPolls");

if (votedPollsFromLS) {
votedPollsFromLS = JSON.parse(votedPollsFromLS);
const votedPollsFromLSJSON = JSON.parse(votedPollsFromLS);

for (let i = 0; i < votedPollsFromLS.polls.length; i += 1) {
votedPolls.push(votedPollsFromLS.polls[i]);
for (let i = 0; i < votedPollsFromLSJSON.polls.length; i += 1) {
votedPolls.push(votedPollsFromLSJSON.polls[i]);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/poll/DeletePoll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ const DeletePoll = (props: {
msg: "Your poll been successfully deleted.",
});
if (typeof window !== "undefined") {
let kukkeeCreatedPolls = localStorage.getItem("kukkeeCreatedPolls");
const kukkeeCreatedPolls = localStorage.getItem("kukkeeCreatedPolls");

if (kukkeeCreatedPolls) {
kukkeeCreatedPolls = JSON.parse(kukkeeCreatedPolls);
const kukkeeCreatedPollsJSON = JSON.parse(kukkeeCreatedPolls);

let newKukkeeCreatedPolls = {
polls: kukkeeCreatedPolls.polls.filter(
polls: kukkeeCreatedPollsJSON.polls.filter(
(poll) => Object.keys(poll)[0] !== `${pollID}-${pollTitle}`
),
};
Expand Down
8 changes: 4 additions & 4 deletions src/components/poll/SubmitTimes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const SubmitTimes = (props: {
submitTimeResponse = await markTimes(voterArgs);
if (submitTimeResponse && submitTimeResponse.statusCode === 201) {
if (typeof window !== "undefined") {
let votedPolls = localStorage.getItem("kukkeeVotedPolls");
const votedPolls = localStorage.getItem("kukkeeVotedPolls");

if (!votedPolls) {
const initKukkeePolls = {
Expand All @@ -76,15 +76,15 @@ const SubmitTimes = (props: {
JSON.stringify(initKukkeePolls)
);
} else {
votedPolls = JSON.parse(votedPolls);
const votedPollsJSON = JSON.parse(votedPolls);

votedPolls.polls.push({
votedPollsJSON.polls.push({
[`${pollID}`]: `${pollFromDB.title}`,
});

localStorage.setItem(
"kukkeeVotedPolls",
JSON.stringify(votedPolls)
JSON.stringify(votedPollsJSON)
);
}
}
Expand Down

1 comment on commit c7f0e9c

@vercel
Copy link

@vercel vercel bot commented on c7f0e9c Feb 19, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.