1- import { Box , Grid , Typography } from '@mui/material' ;
1+ import { Box , FormControl , Grid , Typography } from '@mui/material' ;
22import MilestoneTable from './MilestoneTable' ;
33import FAQsTable from './FAQTable' ;
44import React , { useState } from 'react' ;
5- import { useCurrentOrganization , useSetOrganizationPlatformLogoImage } from '../../../hooks/organizations.hooks' ;
5+ import { useForm } from 'react-hook-form' ;
6+ import { yupResolver } from '@hookform/resolvers/yup' ;
7+ import * as yup from 'yup' ;
8+ import {
9+ useCurrentOrganization ,
10+ useSetOrganizationPlatformLogoImage ,
11+ useSetPlatformDescription
12+ } from '../../../hooks/organizations.hooks' ;
613import LoadingIndicator from '../../../components/LoadingIndicator' ;
714import ErrorPage from '../../ErrorPage' ;
815import ApplicationLinkTable from './ApplicationLinkTable' ;
916import { useGetImageUrl } from '../../../hooks/onboarding.hook' ;
1017import NERUploadButton from '../../../components/NERUploadButton' ;
18+ import NERSuccessButton from '../../../components/NERSuccessButton' ;
19+ import ReactHookTextField from '../../../components/ReactHookTextField' ;
1120import { useToast } from '../../../hooks/toasts.hooks' ;
1221import { MAX_FILE_SIZE } from 'shared' ;
1322
23+ const platformDescriptionSchema = yup . object ( ) . shape ( {
24+ platformDescription : yup . string ( ) . required ( )
25+ } ) ;
26+
1427const AdminToolsRecruitmentConfig : React . FC = ( ) => {
1528 const {
1629 data : organization ,
@@ -20,13 +33,30 @@ const AdminToolsRecruitmentConfig: React.FC = () => {
2033 } = useCurrentOrganization ( ) ;
2134
2235 const { mutateAsync : setPlatformLogoImage , isLoading : platformLogoLoading } = useSetOrganizationPlatformLogoImage ( ) ;
36+ const { mutateAsync : setPlatformDescriptionMutation , isLoading : platformDescriptionSaving } = useSetPlatformDescription ( ) ;
2337
2438 const { data : platformLogoImageUrl } = useGetImageUrl ( organization ?. platformLogoImageId ?? null ) ;
2539
2640 const toast = useToast ( ) ;
2741
2842 const [ addedPlatformLogo , setAddedPlatformLogo ] = useState < File | undefined > ( undefined ) ;
2943
44+ const { control, handleSubmit, reset } = useForm < { platformDescription : string } > ( {
45+ resolver : yupResolver ( platformDescriptionSchema ) ,
46+ defaultValues : { platformDescription : organization ?. platformDescription ?? '' }
47+ } ) ;
48+ const formKey = organization ?. organizationId ?? 'loading' ;
49+
50+ const onPlatformDescriptionSubmit = async ( data : { platformDescription : string } ) => {
51+ try {
52+ const updated = await setPlatformDescriptionMutation ( data . platformDescription ) ;
53+ reset ( { platformDescription : updated . platformDescription } ) ;
54+ toast . success ( 'Platform description saved.' ) ;
55+ } catch ( e ) {
56+ toast . error ( e instanceof Error ? e . message : 'Failed to save platform description' ) ;
57+ }
58+ } ;
59+
3060 const handlePlatformLogoUpload = async ( ) => {
3161 if ( ! addedPlatformLogo ) return ;
3262 if ( addedPlatformLogo . size >= MAX_FILE_SIZE ) {
@@ -99,6 +129,47 @@ const AdminToolsRecruitmentConfig: React.FC = () => {
99129 </ Box >
100130 ) }
101131 </ Grid >
132+ < Grid item xs = { 12 } md = { 6 } >
133+ < Typography variant = "h5" gutterBottom borderBottom = { 1 } color = "#ef4345" borderColor = "white" >
134+ Platform Description
135+ </ Typography >
136+ < form
137+ id = "platform-description-form"
138+ key = { formKey }
139+ onSubmit = { ( e ) => {
140+ e . preventDefault ( ) ;
141+ e . stopPropagation ( ) ;
142+ handleSubmit ( onPlatformDescriptionSubmit ) ( e ) ;
143+ } }
144+ onKeyPress = { ( e ) => {
145+ e . key === 'Enter' && e . preventDefault ( ) ;
146+ } }
147+ >
148+ < FormControl sx = { { width : '100%' } } >
149+ < ReactHookTextField
150+ name = "platformDescription"
151+ control = { control }
152+ multiline
153+ rows = { 5 }
154+ fullWidth
155+ required
156+ placeholder = "Enter platform description for the guest home page..."
157+ sx = { { mb : 1 } }
158+ />
159+ </ FormControl >
160+ < Box sx = { { display : 'flex' , justifyContent : 'end' } } >
161+ < NERSuccessButton
162+ type = "submit"
163+ form = "platform-description-form"
164+ variant = "contained"
165+ disabled = { platformDescriptionSaving }
166+ sx = { { mt : 1 } }
167+ >
168+ { platformDescriptionSaving ? 'Saving...' : 'Save' }
169+ </ NERSuccessButton >
170+ </ Box >
171+ </ form >
172+ </ Grid >
102173 </ Grid >
103174 </ Box >
104175 ) ;
0 commit comments