mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
refactor(FE): Add isRecordingEditable check to detail actions
This commit is contained in:
@@ -272,6 +272,16 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
return recording?.approval?.action === 'REJECTED';
|
||||
}, []);
|
||||
|
||||
const isRecordingEditable = useCallback((recording?: Recording) => {
|
||||
if (
|
||||
recording?.executed_at &&
|
||||
recording?.project_flock?.project_flock_category === 'GROWING'
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}, []);
|
||||
|
||||
// ===== PAYLOAD CREATION HELPERS =====
|
||||
const createGrowingPayload = useCallback(
|
||||
(values: RecordingGrowingFormValues) => {
|
||||
@@ -2990,12 +3000,14 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
<div className='flex flex-col sm:flex-row sm:justify-between gap-2'>
|
||||
{/* Left side - Detail & Edit actions */}
|
||||
<div className='flex flex-col sm:flex-row justify-start gap-2 w-full sm:w-auto'>
|
||||
{type === 'detail' && deleteRecordingClickHandler && (
|
||||
<RequirePermission permissions='lti.production.recording.delete'>
|
||||
<Button
|
||||
type='button'
|
||||
color='error'
|
||||
onClick={deleteRecordingClickHandler}
|
||||
{type === 'detail' &&
|
||||
deleteRecordingClickHandler &&
|
||||
isRecordingEditable(initialValues) && (
|
||||
<RequirePermission permissions='lti.production.recording.delete'>
|
||||
<Button
|
||||
type='button'
|
||||
color='error'
|
||||
onClick={deleteRecordingClickHandler}
|
||||
className='px-4'
|
||||
>
|
||||
<Icon
|
||||
@@ -3008,12 +3020,14 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
</Button>
|
||||
</RequirePermission>
|
||||
)}
|
||||
{type === 'detail' && initialValues && (
|
||||
<RequirePermission permissions='lti.production.recording.update'>
|
||||
<Button
|
||||
type='button'
|
||||
color='warning'
|
||||
href={`/production/recording/detail/edit/?recordingId=${initialValues.id}`}
|
||||
{type === 'detail' &&
|
||||
initialValues &&
|
||||
isRecordingEditable(initialValues) && (
|
||||
<RequirePermission permissions='lti.production.recording.update'>
|
||||
<Button
|
||||
type='button'
|
||||
color='warning'
|
||||
href={`/production/recording/detail/edit/?recordingId=${initialValues.id}`}
|
||||
className='px-4'
|
||||
>
|
||||
<Icon
|
||||
|
||||
Reference in New Issue
Block a user