Skip to content

Commit

Permalink
formatting (#358)
Browse files Browse the repository at this point in the history
  • Loading branch information
armintalaie authored Sep 2, 2024
1 parent 40cd76e commit edb34d4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 26 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up pnpm
uses: pnpm/[email protected]
with:
version: latest

- name: Install dependencies
run: pnpm install

- name: Run Prettier
run: pnpm exec prettier --check "**/*.{js,jsx,ts,tsx,json,css,md}"
49 changes: 27 additions & 22 deletions src/app/portal/admin/forms/[id]/submissions/data-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,35 @@ import {
TableHeader,
TableRow,
} from "@/components/primitives/table";
import React, {CSSProperties, useContext, useState} from "react";
import React, { CSSProperties, useContext, useState } from "react";
import { Columns3, ListFilterIcon, RefreshCcwIcon, XIcon } from "lucide-react";
import { DataTableProps } from "@/app/portal/admin/forms/[id]/submissions/dataTableWrapper";
import { formContext } from "@/components/layouts/formTabView";
import { getAllFormDetails } from "@/app/portal/admin/actions";
import { toast } from "sonner";


const getCommonPinningStyles = (column: Column<any>): CSSProperties => {
const isPinned = column.getIsPinned()
const isPinned = column.getIsPinned();
const isLastLeftPinnedColumn =
isPinned === 'left' && column.getIsLastColumn('left')
isPinned === "left" && column.getIsLastColumn("left");
const isFirstRightPinnedColumn =
isPinned === 'right' && column.getIsFirstColumn('right')
isPinned === "right" && column.getIsFirstColumn("right");

return {
...(isLastLeftPinnedColumn ? { borderRight: `1px solid var(--background-500)` } : {}),
...(isFirstRightPinnedColumn ? { borderLeft: `1px solid var(--background-500)` } : {}),
left: isPinned === 'left' ? `${column.getStart('left')}px` : undefined,
right: isPinned === 'right' ? `${column.getAfter('right')}px` : undefined,
...(isLastLeftPinnedColumn
? { borderRight: `1px solid var(--background-500)` }
: {}),
...(isFirstRightPinnedColumn
? { borderLeft: `1px solid var(--background-500)` }
: {}),
left: isPinned === "left" ? `${column.getStart("left")}px` : undefined,
right: isPinned === "right" ? `${column.getAfter("right")}px` : undefined,
opacity: isPinned ? 0.95 : 1,
position: isPinned ? 'sticky' : 'relative',
width: column.getSize() ? column.getSize() : '300px',
position: isPinned ? "sticky" : "relative",
width: column.getSize() ? column.getSize() : "300px",
// zIndex: isPinned ? 1 : 0,
};
}
};

export function DataTable<TData, TValue>({
columns,
Expand Down Expand Up @@ -92,7 +95,14 @@ export function DataTable<TData, TValue>({
columnFilters,
columnVisibility,
sorting,
columnOrder: ['status','level', 'reviewer_id', 'interviewer_id','notes','popover'],
columnOrder: [
"status",
"level",
"reviewer_id",
"interviewer_id",
"notes",
"popover",
],
// columnPinning: {
// left: ['status','level', 'reviewer_id', 'interviewer_id','notes','popover'],
// }
Expand Down Expand Up @@ -163,18 +173,15 @@ export function DataTable<TData, TValue>({
<Table>
<thead>
{table.getHeaderGroups().map((headerGroup) => (
<tr
key={headerGroup.id}
className={"border-background-500"}
>
<tr key={headerGroup.id} className={"border-background-500"}>
{headerGroup.headers.map((header) => {
return (
<td
key={header.id}
className={
" flex bg-background-600 text-xs flex-col border-background-500 font-semibold justify-center overflow-hidden line-clamp-2 text-ellipsis"
}
style={{...getCommonPinningStyles(header.column)}}
style={{ ...getCommonPinningStyles(header.column) }}
>
{header.isPlaceholder
? null
Expand All @@ -201,10 +208,8 @@ export function DataTable<TData, TValue>({
{row.getVisibleCells().map((cell) => (
<td
key={cell.id}
className={
" h-full text-xs min-h-24 overflow-hidden "
}
style={{...getCommonPinningStyles(cell.column)}}
className={" h-full text-xs min-h-24 overflow-hidden "}
style={{ ...getCommonPinningStyles(cell.column) }}
>
{flexRender(
cell.column.columnDef.cell,
Expand Down
5 changes: 4 additions & 1 deletion src/components/general/multiSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ export default function MultiSelect({
<span className="text-white justify-center flex z-1 items-center gap-2 ">
{selectedOptions !== [null] &&
selectedOptions.map((option) => (
<span key={option.label} className="p-0.5 px-2 z-1! rounded bg-lp-500">
<span
key={option.label}
className="p-0.5 px-2 z-1! rounded bg-lp-500"
>
{option.label}
</span>
))}
Expand Down

0 comments on commit edb34d4

Please sign in to comment.