Skip to content

Commit

Permalink
Merge pull request #865 from hngprojects/feat/manage-users-crud_integ…
Browse files Browse the repository at this point in the history
…rations-ui

feat: manage users crud integrations ui
  • Loading branch information
frank1003A authored Aug 1, 2024
2 parents 2c2c928 + 14cae11 commit 45dd172
Show file tree
Hide file tree
Showing 16 changed files with 587 additions and 68 deletions.
4 changes: 4 additions & 0 deletions public/images/integration/atlassian.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions public/images/integration/dropbox.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions public/images/integration/gdrive.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions public/images/integration/jira.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions public/images/integration/ms-office-teams.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions public/images/integration/ms-office.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/images/integration/notion.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions public/images/integration/onedrive.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions public/images/integration/slack.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions public/images/integration/trello.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { UserData } from "../page";
import UserTableBody from "./userTableBody";
import UserTableHead from "./userTableHead";

const UserTable = () => {
const UserTable = ({ data }: { data: UserData[] }) => {
return (
<>
<table className="user-table z-10 h-full w-full overflow-hidden">
<table className="user-table h-full w-full overflow-hidden">
<UserTableHead />
<UserTableBody />
<UserTableBody data={data} />
</table>
{data.length === 0 && (
<div className="w-full pb-5 pt-10 text-center text-neutral-dark-2">
No data
</div>
)}
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { EllipsisVertical } from "lucide-react";
import Image from "next/image";
import { useState } from "react";

import { Button } from "~/components/ui/button";
Expand All @@ -10,19 +9,25 @@ import {
DropdownMenuLabel,
DropdownMenuTrigger,
} from "~/components/ui/dropdown-menu";
import { userData } from "../data/user-dummy-data";
import { UserData } from "../page";
import DeleteDialog from "./dialogue/delete-dialog";

const UserTableBody = () => {
const UserTableBody = ({ data }: { data: UserData[] }) => {
const [isDialogOpen, setIsDialogOpen] = useState(false);
const handleOpenDialog = () => setIsDialogOpen(true);
const handleCloseDialog = () => setIsDialogOpen(false);

return (
<>
<tbody className="user-table z-10">
{userData.map((data, index) => {
const { avatar, date, email, fullName, phone, status } = data;
{data.map((_data, index) => {
const {
email,
phone,
is_active: status,
name: fullName,
created_at: date,
} = _data;

return (
<tr key={index} className="w-full border-b border-b-border">
Expand All @@ -31,13 +36,18 @@ const UserTableBody = () => {
>
<div className="flex flex-row items-center gap-2">
<div className="h-10 w-10 overflow-hidden rounded-full bg-gray-200">
<Image
src={avatar}
{/* <Image
src="/images/latest-articles/avatar.png"
className="object-cover"
height={40}
width={40}
alt={fullName}
/>
/> */}
<div className="grid h-[40px] w-[40px] place-items-center rounded-full bg-[#e1e7ef]">
<h6 className="font-semibold text-neutral-dark-1">
{fullName[0]}
</h6>
</div>
</div>
<div>
<h3 className="text-sm font-[500] leading-6 text-neutral-dark-2">
Expand All @@ -53,27 +63,27 @@ const UserTableBody = () => {
<td
className={`gap-2 whitespace-nowrap p-4 text-left text-sm font-normal capitalize leading-4 text-neutral-dark-2`}
>
{phone}
{phone ?? "Nil"}
</td>

<td
className={`whitespace-nowrap p-4 text-left text-sm font-normal capitalize leading-4 text-neutral-dark-2`}
>
{date}
{formatMongoDate(date)}
</td>

<td
className={`whitespace-nowrap p-4 text-left text-sm font-normal capitalize leading-4 text-neutral-dark-2`}
>
<div className="flex items-center gap-1">
{status.active && (
{status && (
<>
<div className="h-3 w-3 rounded-full bg-success"></div>
<div className="text-sm">Active</div>
</>
)}

{!status.active && (
{!status && (
<>
<div className="h-3 w-3 rounded-full bg-error"></div>
<div className="text-sm">Inactive</div>
Expand Down Expand Up @@ -112,4 +122,19 @@ const UserTableBody = () => {
);
};

function formatMongoDate(mongoDateString: string): string {
// Parse the date string into a JavaScript Date object
const date = new Date(mongoDateString);

// Extract the day, month, and year
const day = date.getUTCDate();
const month = date.getUTCMonth() + 1; // Months are zero-based in JavaScript
const year = date.getUTCFullYear();

// Format the values into DD/MM/YYYY
const formattedDate = `${String(day).padStart(2, "0")}/${String(month).padStart(2, "0")}/${year}`;

return formattedDate;
}

export default UserTableBody;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { LucideIconName } from "~/components/common/lucide-icon";

interface UserCardData {
export interface UserCardData {
title: string;
value: number;
description: string;
Expand Down
Loading

0 comments on commit 45dd172

Please sign in to comment.