forked from umami-software/umami
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename website column. Table component.
- Loading branch information
Showing
8 changed files
with
66 additions
and
9 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,10 +1,32 @@ | ||
import React from 'react'; | ||
import React, { useState, useEffect } from 'react'; | ||
import Page from './Page'; | ||
import Table from './Table'; | ||
import { get } from 'lib/web'; | ||
|
||
const columns = [ | ||
{ key: 'name', label: 'Name' }, | ||
{ key: 'domain', label: 'Domain' }, | ||
]; | ||
|
||
export default function Settings() { | ||
const [data, setData] = useState(); | ||
|
||
async function loadData() { | ||
setData(await get(`/api/website`)); | ||
} | ||
|
||
useEffect(() => { | ||
loadData(); | ||
}, []); | ||
|
||
if (!data) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Page> | ||
<h2>Settings</h2> | ||
<Table columns={columns} rows={data.websites} /> | ||
</Page> | ||
); | ||
} |
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,25 @@ | ||
import React from 'react'; | ||
import styles from './Table.module.css'; | ||
|
||
export default function Table({ columns, rows }) { | ||
return ( | ||
<table className={styles.table}> | ||
<thead> | ||
<tr> | ||
{columns.map(({ key, label }) => ( | ||
<th key={key}>{label}</th> | ||
))} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{rows.map((row, rowIndex) => ( | ||
<tr key={rowIndex}> | ||
{columns.map(({ key }) => ( | ||
<td key={`${rowIndex}${key}`}>{row[key]}</td> | ||
))} | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
); | ||
} |
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,7 @@ | ||
.table { | ||
width: 100%; | ||
} | ||
|
||
.table th { | ||
text-align: left; | ||
} |
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
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
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
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