Skip to content

Commit

Permalink
refactor:format for date created and task table
Browse files Browse the repository at this point in the history
  • Loading branch information
ademsuslu committed Nov 24, 2024
1 parent 0a979b0 commit 8a59340
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
11 changes: 8 additions & 3 deletions components/shared/datatables/task/task-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
import Link from "next/link"
import { Task } from "@/types/task/model"
import { sanitizeInput } from "@/utils/regex";
import { formatToTurkeyTime } from "@/lib/utils";



Expand Down Expand Up @@ -90,12 +91,16 @@ export const columns: ColumnDef<Task>[] = [
{
accessorKey: "description",
header: "Description",
cell: ({ row }) => <div>{row.getValue("description")}</div>,
cell: ({ row }) => {
const description = row.getValue("description");
return <div>{typeof description === "string" ? description.slice(0, 12)+'..' : ""}</div>;
},
},

{
accessorKey: "dueDate",
header: "Due Date",
cell: ({ row }) => <div>{row.getValue("dueDate")}</div>,
cell: ({ row }) => <div>{formatToTurkeyTime(row.getValue("dueDate"))}</div>,
},
{
accessorKey: "status",
Expand Down Expand Up @@ -217,7 +222,7 @@ const TaskTable: React.FC<TaskTableProps> = ({ data }) => {
<DropdownMenu>
<div className="flex space-x-2">
<Button asChild className="inline-flex items-center justify-center gap-2 whitespace-nowrap text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&amp;_svg]:pointer-events-none [&amp;_svg]:size-4 [&amp;_svg]:shrink-0 border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground h-9 w-9 ml-auto rounded-full" data-state="closed">
<Link href="/customer/create">
<Link href="/bussines/create-task">
<Plus className="w-4 h-4 text-white"/>
</Link>
</Button>
Expand Down
15 changes: 15 additions & 0 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,18 @@ import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}



export function formatToTurkeyTime(dateString: string) {
const date = new Date(dateString); // Tarihi oluştur
return date.toLocaleString("tr-TR", {
timeZone: "Europe/Istanbul",
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
});
}

0 comments on commit 8a59340

Please sign in to comment.