Skip to content

Commit

Permalink
Fixed typescript issue causing project not to build
Browse files Browse the repository at this point in the history
  • Loading branch information
timwekkenbc committed Aug 13, 2024
1 parent c8dc42a commit 9ae0403
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 3 additions & 6 deletions app/admin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Link from "next/link";
import { Table, Input, Button, Flex } from "antd";
import { ColumnsType } from "antd/es/table";
import { HomeOutlined } from "@ant-design/icons";
import { RuleInfo } from "../types/ruleInfo";
import { RuleInfo, RuleInfoBasic } from "../types/ruleInfo";
import { getAllRuleData, postRuleData, updateRuleData, deleteRuleData } from "../utils/api";

enum ACTION_STATUS {
Expand Down Expand Up @@ -33,11 +33,8 @@ export default function Admin() {
getOrRefreshRuleList();
}, []);

const updateRule = (e: React.ChangeEvent<HTMLInputElement>, index: number, property: keyof RuleInfo) => {
const updateRule = (e: React.ChangeEvent<HTMLInputElement>, index: number, property: keyof RuleInfoBasic) => {
const newRules = [...rules];
if (property === "ruleDraft") {
throw new Error("Can't update the draft this way");
}
newRules[index][property] = e.target.value;
setRules(newRules);
};
Expand Down Expand Up @@ -99,7 +96,7 @@ export default function Admin() {
getOrRefreshRuleList();
};

const renderInputField = (fieldName: keyof RuleInfo) => {
const renderInputField = (fieldName: keyof RuleInfoBasic) => {
const Component = (value: string, _: RuleInfo, index: number) => (
<Input value={value} onChange={(e: React.ChangeEvent<HTMLInputElement>) => updateRule(e, index, fieldName)} />
);
Expand Down
5 changes: 4 additions & 1 deletion app/types/ruleInfo.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ export interface RuleDraft {
content: DecisionGraphType;
}

export interface RuleInfo {
export interface RuleInfoBasic {
_id: string;
title?: string;
goRulesJSONFilename: string;
}

export interface RuleInfo extends RuleInfoBasic {
ruleDraft?: RuleDraft;
reviewBranch?: string;
isPublished?: boolean;
Expand Down

0 comments on commit 9ae0403

Please sign in to comment.