From e1f681eee1b75bbb4c0679ac286b7024c506c437 Mon Sep 17 00:00:00 2001
From: Michal Masrna <38047051+michalmasrna1@users.noreply.github.com>
Date: Sat, 23 Nov 2024 23:39:16 +0100
Subject: [PATCH] RA EventRegistration autofill Grade and School from Profile
(#475)
---
.../EventRegistrationCreate.tsx | 54 ++++++++++++-------
1 file changed, 35 insertions(+), 19 deletions(-)
diff --git a/src/components/Admin/resources/competition/event-registration/EventRegistrationCreate.tsx b/src/components/Admin/resources/competition/event-registration/EventRegistrationCreate.tsx
index 91f64fc6..9b866f25 100644
--- a/src/components/Admin/resources/competition/event-registration/EventRegistrationCreate.tsx
+++ b/src/components/Admin/resources/competition/event-registration/EventRegistrationCreate.tsx
@@ -1,23 +1,39 @@
import {FC} from 'react'
-import {AutocompleteInput, ReferenceInput, required, SimpleForm} from 'react-admin'
+import {AutocompleteInput, RaRecord, ReferenceInput, required, SimpleForm} from 'react-admin'
+import {useFormContext} from 'react-hook-form'
import {MyCreate} from '@/components/Admin/custom/MyCreate'
-export const EventRegistrationCreate: FC = () => (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-)
+const ProfileInput = () => {
+ const {setValue} = useFormContext()
+ const prefill = (_: number, profile: RaRecord | string) => {
+ if (typeof profile === 'string') return
+ setValue('school', profile.school.code)
+ setValue('grade', profile.grade)
+ }
+
+ return (
+
+
+
+ )
+}
+
+export const EventRegistrationCreate: FC = () => {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+}