MCPcopy
hub / github.com/Peppermint-Lab/peppermint / Tickets

Function Tickets

apps/client/pages/notifications.tsx:9–75  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7import { useUser } from "../store/session";
8
9export default function Tickets() {
10 const router = useRouter();
11 const { t } = useTranslation("peppermint");
12
13 const token = getCookie("session");
14
15 const { user, fetchUserProfile } = useUser();
16
17 async function markasread(id) {
18 await fetch(`/api/v1/user/notifcation/${id}`, {
19 method: "GET",
20 headers: {
21 Authorization: `Bearer ${token}`,
22 },
23 }).then((res) => res.json());
24 await fetchUserProfile();
25 }
26 return (
27 <div>
28 <div className="flex flex-col">
29 <div className="py-2 px-6 flex flex-row items-center justify-between bg-gray-200 dark:bg-[#0A090C] border-b-[1px]">
30 <span className="text-sm font-bold">
31 You have {user.notifcations.filter((e) => !e.read).length} unread
32 notifcations
33 {user.notifcations.length > 1 ? "'s" : ""}
34 </span>
35 </div>
36 {user.notifcations.filter((e) => !e.read).length > 0 ? (
37 user.notifcations
38 .filter((e) => !e.read)
39 .map((item) => {
40 return (
41 <Link href={`/issue/${item.ticketId}`}>
42 <div className="flex flex-row w-full bg-white dark:bg-[#0A090C] dark:hover:bg-green-600 border-b-[1px] p-2 justify-between px-6 hover:bg-gray-100">
43 <div className="flex flex-row space-x-2 items-center">
44 <span className="text-xs font-semibold">{item.text}</span>
45 </div>
46 <div className="flex flex-row space-x-3 items-center">
47 <button
48 onClick={(e) => {
49 e.preventDefault();
50 e.stopPropagation();
51 markasread(item.id);
52 }}
53 className="inline-flex z-10 items-center px-2.5 py-1.5 border font-semibold border-gray-300 shadow-sm text-xs rounded text-gray-700 bg-white hover:bg-gray-50 hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
54 >
55 mark as read
56 </button>
57 <span className="text-xs">
58 {moment(item.createdAt).format("DD/MM/yyyy")}
59 </span>
60 </div>
61 </div>
62 </Link>
63 );
64 })
65 ) : (
66 <div className="min-h-screen flex items-center justify-center">

Callers

nothing calls this directly

Calls 2

useUserFunction · 0.90
markasreadFunction · 0.85

Tested by

no test coverage detected