Skip to content

Commit

Permalink
up again
Browse files Browse the repository at this point in the history
  • Loading branch information
RafsanAmin committed Oct 11, 2024
1 parent 913f4a6 commit b0e3268
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/app/club/admin/eventEdit/[eventID]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,17 @@ const Page = ({ params }: { params: { eventID: string } }) => {
goToAdminPanel();
};

const save = async (event: any) => {
localStorage.setItem(
`event.${eventUID}`,
JSON.stringify({
questions,
answers,
}),
);
toast.info("Saved questions and answers.");
};

const loadLocal = async () => {
const local = JSON.parse(localStorage.getItem(`event.${eventUID}`) || "{}");
console.dir(local);
Expand Down Expand Up @@ -701,6 +712,19 @@ const Page = ({ params }: { params: { eventID: string } }) => {
)}
</button>
</div>
<div className="w-full justify-self-end py-3 md:w-auto md:py-0">
<button
className="w-full rounded-xl bg-primary px-8 py-2 text-lg text-white transition-all hover:bg-secondary_light hover:text-primary"
type="button"
onClick={save}
>
{loading ? (
<CgSpinner className="mx-auto h-7 w-7 animate-spin text-white" />
) : (
"💾 Questions Locally"
)}
</button>
</div>
<div className="w-full justify-self-end py-3 md:w-auto md:py-0">
<button
className="w-full rounded-xl bg-primary px-8 py-2 text-lg text-white transition-all hover:bg-secondary_light hover:text-primary"
Expand All @@ -710,7 +734,7 @@ const Page = ({ params }: { params: { eventID: string } }) => {
{loading ? (
<CgSpinner className="mx-auto h-7 w-7 animate-spin text-white" />
) : (
"Save Questions Locally"
"💾 Questions Locally & Quit"
)}
</button>
</div>
Expand All @@ -723,7 +747,7 @@ const Page = ({ params }: { params: { eventID: string } }) => {
{loading ? (
<CgSpinner className="mx-auto h-7 w-7 animate-spin text-white" />
) : (
"Load Local Questions"
"Load Local Ques."
)}
</button>
</div>
Expand Down

0 comments on commit b0e3268

Please sign in to comment.