-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from avored/improvements
Improvements
- Loading branch information
Showing
13 changed files
with
451 additions
and
387 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import {useTranslation} from "react-i18next"; | ||
import {getFormattedDate} from "../../lib/common"; | ||
import IComponentModel from "../../types/component/IComponentModel"; | ||
|
||
interface ISelectedComponentFunction { | ||
(e: React.MouseEvent, id: string): void | ||
} | ||
|
||
interface IPageComponentProps { | ||
components: Array<IComponentModel>; | ||
componentSelected: ISelectedComponentFunction | ||
} | ||
|
||
function PageComponentTable(props: IPageComponentProps) { | ||
const [t] = useTranslation("global"); | ||
return ( | ||
<table className="min-w-full bg-white shadow-md rounded"> | ||
<thead> | ||
<tr className="bg-gray-700 text-white"> | ||
<th className="py-3 px-4 rounded-l font-semibold text-left"> | ||
{t("common.id")} | ||
</th> | ||
<th className="py-3 px-4 font-semibol text-left"> | ||
{t("common.name")} | ||
</th> | ||
<th className="py-3 px-4 font-semibol text-left"> | ||
{t("common.identifier")} | ||
</th> | ||
<th className="py-3 px-4 font-semibol text-left"> | ||
{t("common.created_at")} | ||
</th> | ||
<th className="py-3 px-4 font-semibol text-left"> | ||
{t("common.updated_at")} | ||
</th> | ||
<th className="py-3 px-4 font-semibol text-left"> | ||
{t("common.created_by")} | ||
</th> | ||
<th className="py-3 px-4 font-semibol text-left"> | ||
{t("common.updated_by")} | ||
</th> | ||
<th className="py-3 px-4 rounded-r font-semibol text-left"> | ||
{t("common.action")} | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody className=""> | ||
{props.components.map((component) => { | ||
return ( | ||
<tr key={component.id} className="border-b"> | ||
<td className="py-3 px-4">{component.id}</td> | ||
<td className="py-3 px-4">{component.name}</td> | ||
<td className="py-3 px-4"> | ||
{component.identifier} | ||
</td> | ||
<td className="py-3 px-4"> | ||
{getFormattedDate(component.created_at)} | ||
</td> | ||
<td className="py-3 px-4"> | ||
{getFormattedDate(component.updated_at)} | ||
</td> | ||
<td className="py-3 px-4"> | ||
{component.created_by} | ||
</td> | ||
<td className="py-3 px-4"> | ||
{component.updated_by} | ||
</td> | ||
<td className="py-3 px-4"> | ||
<button | ||
type="button" | ||
className="font-medium text-primary-600 hover:text-primary-800" | ||
onClick={(e) => | ||
props.componentSelected(e, component.id) | ||
} | ||
> | ||
{t("common.select")} | ||
</button> | ||
</td> | ||
</tr> | ||
); | ||
})} | ||
</tbody> | ||
</table> | ||
) | ||
} | ||
|
||
export default PageComponentTable |
Oops, something went wrong.