-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): create event from link button
- Loading branch information
1 parent
4548421
commit 1ad4ba0
Showing
8 changed files
with
88 additions
and
85 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
48 changes: 48 additions & 0 deletions
48
packages/@liexp/ui/src/components/admin/common/EntityInputs.tsx
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,48 @@ | ||
import { type EventType } from "@liexp/shared/lib/io/http/Events"; | ||
import { | ||
DEATH, | ||
UNCATEGORIZED, | ||
} from "@liexp/shared/lib/io/http/Events/EventType"; | ||
import * as React from "react"; | ||
import { Stack } from "../../mui/index.js"; | ||
import ReferenceActorInput from "../actors/ReferenceActorInput.js"; | ||
import { Form } from "../react-admin.js"; | ||
|
||
interface EventFieldsFromTypeProps { | ||
eventType: EventType; | ||
defaultValues: any; | ||
onChange: (data: any) => void; | ||
} | ||
export const EventFieldsFromType: React.FC<EventFieldsFromTypeProps> = ({ | ||
eventType, | ||
defaultValues, | ||
onChange, | ||
}) => { | ||
const fields = React.useMemo(() => { | ||
switch (eventType) { | ||
case DEATH.value: { | ||
return ( | ||
<Stack spacing={1}> | ||
<ReferenceActorInput source="payload.victim" /> | ||
</Stack> | ||
); | ||
} | ||
case UNCATEGORIZED.value: | ||
default: { | ||
return <Stack spacing={1} />; | ||
} | ||
} | ||
}, [eventType]); | ||
|
||
return ( | ||
<Form | ||
defaultValues={() => defaultValues} | ||
validate={(data) => { | ||
console.log("validate", data); | ||
return {}; | ||
}} | ||
> | ||
<Stack spacing={2}>{fields}</Stack> | ||
</Form> | ||
); | ||
}; |
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
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