Skip to content

Commit

Permalink
Merge pull request #189 from Peppermint-Lab/next
Browse files Browse the repository at this point in the history
bugfixes
  • Loading branch information
potts99 authored Nov 28, 2023
2 parents 88c6679 + 54965ea commit aafc65e
Show file tree
Hide file tree
Showing 9 changed files with 1,016 additions and 13,512 deletions.
4 changes: 2 additions & 2 deletions apps/api/src/controllers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,11 @@ export function authRoutes(fastify: FastifyInstance) {
});

reply.send({
sucess: true,
success: true,
});
} else {
reply.send({
sucess: false,
success: false,
});
}
}
Expand Down
12 changes: 7 additions & 5 deletions apps/client/components/ResetPassword/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import { Dialog, Transition } from "@headlessui/react";
import { XMarkIcon } from "@heroicons/react/24/outline";
import { notifications } from "@mantine/notifications";
import { getCookie } from "cookies-next";
import React, { Fragment, useState } from "react";

export default function ResetPassword({ user }) {
export default function ResetPassword() {
const [open, setOpen] = useState(false);
const [password, setPassword] = useState("");
const [check, setCheck] = useState("");

const postData = async () => {
if (check === password && password.length > 0) {
if (check === password && password.length > 3) {
await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/api/v1/auth/reset-password`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + token,
Authorization: "Bearer " + getCookie("session"),
},
body: JSON.stringify({
password,
Expand All @@ -24,7 +26,7 @@ export default function ResetPassword({ user }) {
)
.then((res) => res.json())
.then((res) => {
if (res.failed === false) {
if (res.success) {
notifications.show({
title: "Success",
message: `Password updated :)`,
Expand All @@ -34,7 +36,7 @@ export default function ResetPassword({ user }) {
} else {
notifications.show({
title: "Error",
message: `Error: ${res.message}`,
message: `Error: failed to update password`,
color: "red",
autoClose: 5000,
});
Expand Down
2 changes: 1 addition & 1 deletion apps/client/layouts/adminLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function AdminLayout({ children }: any) {

const { user } = useUser();

if (user || user.role === "admin") {
if (user && !user.isAdmin) {
return (
<div className="flex items-center justify-center h-screen">
<h1 className="text-4xl font-bold">You are not an admin</h1>
Expand Down
11 changes: 9 additions & 2 deletions apps/client/layouts/newLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
HomeIcon,
XMarkIcon,
} from "@heroicons/react/24/outline";
import { deleteCookie } from "cookies-next";
import { deleteCookie, getCookie } from "cookies-next";
import Link from "next/link";
import { useRouter } from "next/router";
import { Fragment, useCallback, useEffect, useState } from "react";
Expand Down Expand Up @@ -90,7 +90,14 @@ export default function NewLayout({ children }: any) {
async function logout() {
// clears session on server
const res = await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/api/v1/auth/user/${user.id}/logout`
`${process.env.NEXT_PUBLIC_API_URL}/api/v1/auth/user/${user.id}/logout`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${getCookie("session")}`,
},
}
).then((res) => res.json());

// delete session cookie
Expand Down
20 changes: 11 additions & 9 deletions apps/client/pages/admin/users/internal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ const fetchUsers = async (token) => {

function DefaultColumnFilter({ column: { filterValue, setFilter } }) {
return (
<input
className="shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-md"
type="text"
value={filterValue || ""}
onChange={(e) => {
setFilter(e.target.value || undefined); // Set undefined to remove the filter entirely
}}
placeholder="Type to filter"
/>
// <input
// className="shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-md"
// type="text"
// value={filterValue || ""}
// autoComplete="off"
// onChange={(e) => {
// setFilter(e.target.value || undefined); // Set undefined to remove the filter entirely
// }}
// placeholder="Type to filter"
// />
<></>
);
}
function Table({ columns, data }) {
Expand Down
6 changes: 3 additions & 3 deletions apps/client/pages/settings/password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function PasswordChange({ children }) {
const [check, setCheck] = useState("");

const postData = async () => {
if (check === password && password.length > 0) {
if (check === password && password.length > 2) {
await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/api/v1/auth/reset-password`,
{
Expand All @@ -26,7 +26,7 @@ export default function PasswordChange({ children }) {
)
.then((res) => res.json())
.then((res) => {
if (res.failed === false) {
if (res.success) {
notifications.show({
title: "Success",
message: `Password updated :)`,
Expand All @@ -36,7 +36,7 @@ export default function PasswordChange({ children }) {
} else {
notifications.show({
title: "Error",
message: `Error: ${res.message}`,
message: `Error: Failed to update password`,
color: "red",
autoClose: 5000,
});
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
"description": "",
"main": "index.js",
"scripts": {
"dev": "next",
"dev": "next -p 3005",
"build": "next build",
"start": "next start"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"next": "^14.0.3",
"next": "13",
"nextra": "^2.13.2",
"nextra-theme-docs": "^2.13.2",
"react": "^18.2.0",
Expand Down
Loading

0 comments on commit aafc65e

Please sign in to comment.