mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 23:35:45 +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';
|
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 =====
|
// ===== PAYLOAD CREATION HELPERS =====
|
||||||
const createGrowingPayload = useCallback(
|
const createGrowingPayload = useCallback(
|
||||||
(values: RecordingGrowingFormValues) => {
|
(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'>
|
<div className='flex flex-col sm:flex-row sm:justify-between gap-2'>
|
||||||
{/* Left side - Detail & Edit actions */}
|
{/* Left side - Detail & Edit actions */}
|
||||||
<div className='flex flex-col sm:flex-row justify-start gap-2 w-full sm:w-auto'>
|
<div className='flex flex-col sm:flex-row justify-start gap-2 w-full sm:w-auto'>
|
||||||
{type === 'detail' && deleteRecordingClickHandler && (
|
{type === 'detail' &&
|
||||||
<RequirePermission permissions='lti.production.recording.delete'>
|
deleteRecordingClickHandler &&
|
||||||
<Button
|
isRecordingEditable(initialValues) && (
|
||||||
type='button'
|
<RequirePermission permissions='lti.production.recording.delete'>
|
||||||
color='error'
|
<Button
|
||||||
onClick={deleteRecordingClickHandler}
|
type='button'
|
||||||
|
color='error'
|
||||||
|
onClick={deleteRecordingClickHandler}
|
||||||
className='px-4'
|
className='px-4'
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon
|
||||||
@@ -3008,12 +3020,14 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
</Button>
|
</Button>
|
||||||
</RequirePermission>
|
</RequirePermission>
|
||||||
)}
|
)}
|
||||||
{type === 'detail' && initialValues && (
|
{type === 'detail' &&
|
||||||
<RequirePermission permissions='lti.production.recording.update'>
|
initialValues &&
|
||||||
<Button
|
isRecordingEditable(initialValues) && (
|
||||||
type='button'
|
<RequirePermission permissions='lti.production.recording.update'>
|
||||||
color='warning'
|
<Button
|
||||||
href={`/production/recording/detail/edit/?recordingId=${initialValues.id}`}
|
type='button'
|
||||||
|
color='warning'
|
||||||
|
href={`/production/recording/detail/edit/?recordingId=${initialValues.id}`}
|
||||||
className='px-4'
|
className='px-4'
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon
|
||||||
|
|||||||
Reference in New Issue
Block a user