ENCOA-16: Added a creation date to the Code List
This commit is contained in:
@@ -139,6 +139,7 @@ export interface Code {
|
|||||||
creator: string;
|
creator: string;
|
||||||
expiryDate: Date;
|
expiryDate: Date;
|
||||||
type: Type;
|
type: Type;
|
||||||
|
creationDate?: string;
|
||||||
userId?: string;
|
userId?: string;
|
||||||
email?: string;
|
email?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {Code, User} from "@/interfaces/user";
|
|||||||
import {USER_TYPE_LABELS} from "@/resources/user";
|
import {USER_TYPE_LABELS} from "@/resources/user";
|
||||||
import {createColumnHelper, flexRender, getCoreRowModel, useReactTable} from "@tanstack/react-table";
|
import {createColumnHelper, flexRender, getCoreRowModel, useReactTable} from "@tanstack/react-table";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import moment from "moment";
|
||||||
import {useEffect, useState} from "react";
|
import {useEffect, useState} from "react";
|
||||||
import {BsTrash} from "react-icons/bs";
|
import {BsTrash} from "react-icons/bs";
|
||||||
import {toast} from "react-toastify";
|
import {toast} from "react-toastify";
|
||||||
@@ -129,6 +130,10 @@ export default function CodeList({user}: {user: User}) {
|
|||||||
header: "Code",
|
header: "Code",
|
||||||
cell: (info) => info.getValue(),
|
cell: (info) => info.getValue(),
|
||||||
}),
|
}),
|
||||||
|
columnHelper.accessor("creationDate", {
|
||||||
|
header: "Creation Date",
|
||||||
|
cell: (info) => (info.getValue() ? moment(info.getValue()).format("DD/MM/YYYY") : "N/A"),
|
||||||
|
}),
|
||||||
columnHelper.accessor("email", {
|
columnHelper.accessor("email", {
|
||||||
header: "Invited E-mail",
|
header: "Invited E-mail",
|
||||||
cell: (info) => info.getValue() || "N/A",
|
cell: (info) => info.getValue() || "N/A",
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
type,
|
type,
|
||||||
code,
|
code,
|
||||||
creator: req.session.user!.id,
|
creator: req.session.user!.id,
|
||||||
|
creationDate: new Date().toISOString(),
|
||||||
expiryDate,
|
expiryDate,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user