Skip to content

Commit

Permalink
(web) wip: adding ts ignores to enable build
Browse files Browse the repository at this point in the history
  • Loading branch information
joewagner committed May 22, 2024
1 parent 9cd8360 commit 361275f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
29 changes: 22 additions & 7 deletions packages/web/components/data-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ export function DataTable<TData, TValue>({
const toggleInsert = function () {
setInsertingRow(!insertingRow);
};
const setInputValue = function (eve, cellId) {
const setInputValue = function (eve: Event, cellId: string) {
const column = cellId.split("_").pop();
if (typeof column !== "string") throw new Error("invalid cell id");
// @ts-ignore
setInsertingValues({ ...insertingValues, [column]: eve.target.value });
};
const commitInsert = async function () {
Expand All @@ -95,20 +97,24 @@ export function DataTable<TData, TValue>({
const entries = Object.entries(insertingValues);
const cols = entries.map((val) => {
const colTicks = columns.find(
// @ts-ignore
(col) => col.name.replace(/^`/, "").replace(/`$/, "") === val[0],
);
// @ts-ignore
if (colTicks) return "`" + colTicks.name + "`";

// @ts-ignore
const colPlain = columns.find((col) => col.name === val[0]);
// @ts-ignore
if (colPlain) return colPlain.name;
});

const vals = entries.map((val) => {
const col = columns.find(
// @ts-ignore
(col) => col.name.replace(/^`/, "").replace(/`$/, "") === val[0],
);

if (col.type === "text") return `'${val[1]}'`;
// @ts-ignore
if (col?.type === "text") return `'${val[1]}'`;
return val[1];
});

Expand All @@ -135,7 +141,7 @@ export function DataTable<TData, TValue>({
const [acl] = await validator.queryByStatement({
statement: `select* from system_acl where chain_id=${chainId} and table_id=${tableId}`,
});

// @ts-ignore
const show = isConnected && acl?.controller === address;
setShowEdit(show);
};
Expand Down Expand Up @@ -167,6 +173,7 @@ export function DataTable<TData, TValue>({
</>
) : (
<Button
// @ts-ignore
variant={saving ? "loading" : "outline"}
className="ml-4"
onClick={toggleInsert}
Expand Down Expand Up @@ -233,28 +240,36 @@ export function DataTable<TData, TValue>({
type:{" "}
<b>
{
// @ts-ignore
columns.find(
(col) =>
// @ts-ignore
col.name.replace(/^`/, "").replace(/`$/, "") ===
cell.id,
).type
// @ts-ignore
)?.type
}
</b>
</p>
<p className="text-foreground-muted">
constraints:{" "}
<b>
{columns
{
// @ts-ignore
columns
.find(
(col) =>
// @ts-ignore
col.name.replace(/^`/, "").replace(/`$/, "") ===
cell.id,
)
// @ts-ignore
.constraints?.join(", ") || "none"}
</b>
</p>
<Input
name={cell.id}
// @ts-ignore
onChange={(value) => setInputValue(value, cell.id)}
/>
</div>
Expand Down
1 change: 1 addition & 0 deletions packages/web/components/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ export default async function Table({
</TabsList>
<TabsContent value="data">
<DataTable
// @ts-ignore
columns={columns}
data={formattedData}
chainId={chainId}
Expand Down
2 changes: 1 addition & 1 deletion packages/web/scripts/validator/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@
"HashCalculationStep": 100
}
]
}
}

0 comments on commit 361275f

Please sign in to comment.