Skip to content

Commit a13ae0f

Browse files
authored
fix: ticket title placement (#299)
* fix admin reset password * nav * ticket ui improvements * only send internal users * flagged * move title to top of screen
1 parent e7e295e commit a13ae0f

File tree

6 files changed

+115
-79
lines changed

6 files changed

+115
-79
lines changed

apps/api/src/controllers/auth.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,57 @@ export function authRoutes(fastify: FastifyInstance) {
590590
}
591591
);
592592

593+
// Reset password by admin
594+
fastify.post(
595+
"/api/v1/auth/admin/reset-password",
596+
async (request: FastifyRequest, reply: FastifyReply) => {
597+
let { password, user } = request.body as {
598+
password: string;
599+
user: string;
600+
};
601+
602+
console.log(user);
603+
604+
const bearer = request.headers.authorization!.split(" ")[1];
605+
const token = checkToken(bearer);
606+
607+
if (token) {
608+
let session = await prisma.session.findUnique({
609+
where: {
610+
sessionToken: bearer,
611+
},
612+
});
613+
614+
const check = await prisma.user.findUnique({
615+
where: { id: session?.userId },
616+
});
617+
618+
if (check?.isAdmin === false) {
619+
reply.code(401).send({
620+
message: "Unauthorized",
621+
});
622+
}
623+
624+
const hashedPass = await bcrypt.hash(password, 10);
625+
626+
await prisma.user.update({
627+
where: { id: user },
628+
data: {
629+
password: hashedPass,
630+
},
631+
});
632+
633+
reply.send({
634+
success: true,
635+
});
636+
} else {
637+
reply.send({
638+
success: false,
639+
});
640+
}
641+
}
642+
);
643+
593644
// Update a users profile/config
594645
fastify.put(
595646
"/api/v1/auth/profile",

apps/api/src/controllers/users.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ export function userRoutes(fastify: FastifyInstance) {
1616
const token = checkToken(bearer);
1717
if (token) {
1818
const users = await prisma.user.findMany({
19+
where: {
20+
external_user: false,
21+
},
1922
select: {
2023
id: true,
2124
name: true,

apps/client/components/ResetPassword/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,30 @@ import { notifications } from "@mantine/notifications";
44
import { getCookie } from "cookies-next";
55
import React, { Fragment, useState } from "react";
66

7-
export default function ResetPassword() {
7+
export default function ResetPassword({ user }) {
88
const [open, setOpen] = useState(false);
99
const [password, setPassword] = useState("");
1010
const [check, setCheck] = useState("");
1111

1212
const postData = async () => {
1313
if (check === password && password.length > 3) {
14-
await fetch(`/api/v1/auth/reset-password`, {
14+
await fetch(`/api/v1/auth/admin/reset-password`, {
1515
method: "POST",
1616
headers: {
1717
"Content-Type": "application/json",
1818
Authorization: "Bearer " + getCookie("session"),
1919
},
2020
body: JSON.stringify({
2121
password,
22+
user: user.id,
2223
}),
2324
})
2425
.then((res) => res.json())
2526
.then((res) => {
2627
if (res.success) {
2728
notifications.show({
2829
title: "Success",
29-
message: `Password updated :)`,
30+
message: `Password updated`,
3031
color: "green",
3132
autoClose: 5000,
3233
});

apps/client/layouts/newLayout.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -770,11 +770,11 @@ export default function NewLayout({ children }: any) {
770770
item.current
771771
? "bg-[#F0F3F9] dark:bg-gray-800 dark:text-green-600"
772772
: " hover:bg-[#F0F3F9] dark:hover:bg-gray-800 dark:hover:text-gray-900 ",
773-
"group -mx-2 flex gap-x-3 p-1 text-xs font-semibold leading-6"
773+
"group -mx-2 flex gap-x-3 p-1 text-xs rounded-md font-semibold leading-6"
774774
)}
775775
>
776776
<item.icon
777-
className="h-4 w-4 shrink-0 mt-1"
777+
className="h-4 w-4 ml-1 shrink-0 mt-1"
778778
aria-hidden="true"
779779
/>
780780
<span className="whitespace-nowrap">{item.name}</span>
@@ -794,10 +794,10 @@ export default function NewLayout({ children }: any) {
794794
location.pathname === "/tickets"
795795
? "bg-[#F0F3F9] dark:bg-gray-800 dark:text-green-600"
796796
: " hover:bg-[#F0F3F9] dark:hover:bg-white dark:hover:text-gray-900 ",
797-
"group -mx-2 flex gap-x-3 p-1 text-xs font-semibold leading-6"
797+
"group -mx-2 flex gap-x-3 p-1 rounded-md text-xs font-semibold leading-6"
798798
)}
799799
>
800-
<TicketIcon className="h-4 w-4 shrink-0 mt-1" />
800+
<TicketIcon className="h-4 w-4 ml-1 shrink-0 mt-1" />
801801
<span className="whitespace-nowrap">Tickets</span>
802802
<div className="flex w-full justify-end float-right">
803803
<span className="flex h-6 w-6 shrink-0 items-center bg-transparent border-none justify-center text-md font-medium">
@@ -813,7 +813,7 @@ export default function NewLayout({ children }: any) {
813813
location.pathname === "/tickets/open"
814814
? "bg-[#F0F3F9] dark:bg-gray-800 dark:text-green-600"
815815
: " hover:bg-[#F0F3F9] dark:hover:bg-white dark:hover:text-gray-900 ",
816-
"group -mx-2 flex gap-x-3 p-1 mll-2 text-xs font-semibold leading-6"
816+
"group -mx-2 flex gap-x-3 p-1 pl-3 rounded-md text-xs font-semibold leading-6"
817817
)}
818818
>
819819
<span className="whitespace-nowrap">
@@ -834,7 +834,7 @@ export default function NewLayout({ children }: any) {
834834
location.pathname === "/tickets/closed"
835835
? "bg-[#F0F3F9] dark:bg-gray-800 dark:text-green-600"
836836
: " hover:bg-[#F0F3F9] dark:hover:bg-white dark:hover:text-gray-900 ",
837-
"group -mx-2 flex gap-x-3 p-1 text-xs font-semibold leading-6"
837+
"group -mx-2 flex gap-x-3 p-1 pl-3 rounded-md text-xs font-semibold leading-6"
838838
)}
839839
>
840840
<span className="whitespace-nowrap">
@@ -856,14 +856,14 @@ export default function NewLayout({ children }: any) {
856856
location.pathname.includes("/admin")
857857
? "bg-[#F0F3F9] dark:bg-gray-800 dark:text-green-600"
858858
: " hover:bg-[#F0F3F9] dark:hover:bg-white dark:hover:text-gray-900 ",
859-
"group -mx-2 flex gap-x-3 p-1 text-xs font-semibold leading-6"
859+
"group -mx-2 flex gap-x-3 p-1 rounded-md text-xs font-semibold leading-6"
860860
)}
861861
>
862862
<ContextMenu.Root>
863863
<ContextMenu.Trigger>
864864
<>
865865
<Cog6ToothIcon
866-
className="h-4 w-4 shrink-0 mt-1"
866+
className="h-4 w-4 ml-1 shrink-0 mt-1"
867867
aria-hidden="true"
868868
/>
869869
<span className="whitespace-nowrap">

apps/client/pages/new.tsx

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Link, RichTextEditor } from "@mantine/tiptap";
2-
import Placeholder from '@tiptap/extension-placeholder';
32
import Highlight from "@tiptap/extension-highlight";
3+
import Placeholder from "@tiptap/extension-placeholder";
44
import Underline from "@tiptap/extension-underline";
55
import { useEditor } from "@tiptap/react";
66
import StarterKit from "@tiptap/starter-kit";
@@ -55,7 +55,7 @@ export default function CreateTicket() {
5555
Superscript,
5656
SubScript,
5757
Highlight,
58-
Placeholder.configure({ placeholder: t("ticket_extra_details") })
58+
Placeholder.configure({ placeholder: t("ticket_extra_details") }),
5959
// TextAlign.configure({ types: ['heading', 'paragraph'] }),
6060
],
6161
content: issue,
@@ -378,6 +378,17 @@ export default function CreateTicket() {
378378
</div>
379379
<div className="flex flex-col xl:flex-row h-full w-full">
380380
<div className="w-full xl:w-2/3 order-2 xl:order-2">
381+
<div className="px-4 border-b border-gray-700">
382+
<input
383+
type="text"
384+
name="title"
385+
placeholder={t("ticket_details")}
386+
maxLength={64}
387+
autoComplete="off"
388+
onChange={(e) => setTitle(e.target.value)}
389+
className="w-full pl-0 pr-0 sm:text-xl border-none dark:bg-[#0A090C] dark:text-white focus:outline-none focus:shadow-none focus:ring-0 focus:border-none"
390+
/>
391+
</div>
381392
<RichTextEditor
382393
editor={editor}
383394
placeholder={t("ticket_extra_details")}
@@ -428,22 +439,6 @@ export default function CreateTicket() {
428439
</div>
429440
<div className="w-full xl:w-1/6 p-3 flex flex-col dark:bg-[#0A090C] dark:text-white border-b-[1px] xl:border-b-0 xl:border-r-[1px] order-1 xl:order-1">
430441
<div className="flex flex-col">
431-
<div>
432-
<label>
433-
<span className="block text-sm font-medium text-gray-700 dark:text-white">
434-
Title
435-
</span>
436-
</label>
437-
<input
438-
type="text"
439-
name="title"
440-
placeholder={t("ticket_details")}
441-
maxLength={64}
442-
autoComplete="off"
443-
onChange={(e) => setTitle(e.target.value)}
444-
className="w-full pl-0 pr-0 sm:text-xl border-none dark:bg-[#0A090C] dark:text-white focus:outline-none focus:shadow-none focus:ring-0 focus:border-none"
445-
/>
446-
</div>
447442
<div>
448443
<label>
449444
<span className="block text-sm font-medium text-gray-700 dark:text-white">

0 commit comments

Comments
 (0)