diff --git a/assets/pen.svg b/assets/pen.svg new file mode 100644 index 00000000..426c520c --- /dev/null +++ b/assets/pen.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/components/Settings.js b/components/Settings.js index 6729dfb4..60b7196a 100644 --- a/components/Settings.js +++ b/components/Settings.js @@ -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 (

Settings

+ ); } diff --git a/components/Table.js b/components/Table.js new file mode 100644 index 00000000..a957ee7a --- /dev/null +++ b/components/Table.js @@ -0,0 +1,25 @@ +import React from 'react'; +import styles from './Table.module.css'; + +export default function Table({ columns, rows }) { + return ( +
+ + + {columns.map(({ key, label }) => ( + + ))} + + + + {rows.map((row, rowIndex) => ( + + {columns.map(({ key }) => ( + + ))} + + ))} + +
{label}
{row[key]}
+ ); +} diff --git a/components/Table.module.css b/components/Table.module.css new file mode 100644 index 00000000..ce2ba655 --- /dev/null +++ b/components/Table.module.css @@ -0,0 +1,7 @@ +.table { + width: 100%; +} + +.table th { + text-align: left; +} diff --git a/components/WebsiteDetails.js b/components/WebsiteDetails.js index 3b84f2f0..1f120057 100644 --- a/components/WebsiteDetails.js +++ b/components/WebsiteDetails.js @@ -45,7 +45,7 @@ export default function WebsiteDetails({ websiteId, defaultDateRange = '7day' })
-

{data.label}

+

{data.name}

{data && - data.websites.map(({ website_id, label }) => ( + data.websites.map(({ website_id, name }) => (

- {label} + {name}

} /> View details
- +
))} diff --git a/prisma/schema.prisma b/prisma/schema.prisma index fdf9505e..65f0b145 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -71,9 +71,10 @@ model session { model website { website_id Int @default(autoincrement()) @id website_uuid String @unique - label String + name String created_at DateTime? @default(now()) user_id Int + domain String? account account @relation(fields: [user_id], references: [user_id]) event event[] pageview pageview[] diff --git a/sql/schema.postgresql.sql b/sql/schema.postgresql.sql index c237de3a..776e5049 100644 --- a/sql/schema.postgresql.sql +++ b/sql/schema.postgresql.sql @@ -11,7 +11,8 @@ create table website ( website_id serial primary key, website_uuid uuid unique not null, user_id int not null references account(user_id) on delete cascade, - label varchar(100) not null, + name varchar(100) not null, + domain varchar(500), created_at timestamp with time zone default current_timestamp );