refactor: merge 6 EditableTitle wrappers into one file
Replace EditableSessionTitle, EditableMotivatorTitle, EditableYearReviewTitle, EditableWeatherTitle, EditableWeeklyCheckInTitle, EditableGifMoodTitle individual files with a single EditableTitles.tsx using spread props. Same public API. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,8 +5,7 @@ import { getWorkshop, getSessionsTabUrl } from '@/lib/workshops';
|
||||
import { getGifMoodSessionById } from '@/services/gif-mood';
|
||||
import { getUserTeams } from '@/services/teams';
|
||||
import { GifMoodBoard, GifMoodLiveWrapper } from '@/components/gif-mood';
|
||||
import { Badge } from '@/components/ui';
|
||||
import { EditableGifMoodTitle } from '@/components/ui/EditableGifMoodTitle';
|
||||
import { Badge, EditableGifMoodTitle } from '@/components/ui';
|
||||
|
||||
interface GifMoodSessionPageProps {
|
||||
params: Promise<{ id: string }>;
|
||||
|
||||
@@ -15,8 +15,7 @@ import {
|
||||
WeatherAverageBar,
|
||||
WeatherTrendChart,
|
||||
} from '@/components/weather';
|
||||
import { Badge } from '@/components/ui';
|
||||
import { EditableWeatherTitle } from '@/components/ui/EditableWeatherTitle';
|
||||
import { Badge, EditableWeatherTitle } from '@/components/ui';
|
||||
|
||||
interface WeatherSessionPageProps {
|
||||
params: Promise<{ id: string }>;
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { EditableTitle } from './EditableTitle';
|
||||
import { updateGifMoodSession } from '@/actions/gif-mood';
|
||||
|
||||
interface EditableGifMoodTitleProps {
|
||||
sessionId: string;
|
||||
initialTitle: string;
|
||||
canEdit: boolean;
|
||||
}
|
||||
|
||||
export function EditableGifMoodTitle({
|
||||
sessionId,
|
||||
initialTitle,
|
||||
canEdit,
|
||||
}: EditableGifMoodTitleProps) {
|
||||
return (
|
||||
<EditableTitle
|
||||
sessionId={sessionId}
|
||||
initialTitle={initialTitle}
|
||||
canEdit={canEdit}
|
||||
onUpdate={async (id, title) => {
|
||||
const result = await updateGifMoodSession(id, { title });
|
||||
return result;
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { EditableTitle } from './EditableTitle';
|
||||
import { updateMotivatorSession } from '@/actions/moving-motivators';
|
||||
|
||||
interface EditableMotivatorTitleProps {
|
||||
sessionId: string;
|
||||
initialTitle: string;
|
||||
canEdit: boolean;
|
||||
}
|
||||
|
||||
export function EditableMotivatorTitle({
|
||||
sessionId,
|
||||
initialTitle,
|
||||
canEdit,
|
||||
}: EditableMotivatorTitleProps) {
|
||||
return (
|
||||
<EditableTitle
|
||||
sessionId={sessionId}
|
||||
initialTitle={initialTitle}
|
||||
canEdit={canEdit}
|
||||
onUpdate={async (id, title) => {
|
||||
const result = await updateMotivatorSession(id, { title });
|
||||
return result;
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { EditableTitle } from './EditableTitle';
|
||||
import { updateSessionTitle } from '@/actions/session';
|
||||
|
||||
interface EditableSessionTitleProps {
|
||||
sessionId: string;
|
||||
initialTitle: string;
|
||||
canEdit: boolean;
|
||||
}
|
||||
|
||||
export function EditableSessionTitle({
|
||||
sessionId,
|
||||
initialTitle,
|
||||
canEdit,
|
||||
}: EditableSessionTitleProps) {
|
||||
return (
|
||||
<EditableTitle
|
||||
sessionId={sessionId}
|
||||
initialTitle={initialTitle}
|
||||
canEdit={canEdit}
|
||||
onUpdate={async (id, title) => {
|
||||
const result = await updateSessionTitle(id, title);
|
||||
return result;
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
39
src/components/ui/EditableTitles.tsx
Normal file
39
src/components/ui/EditableTitles.tsx
Normal file
@@ -0,0 +1,39 @@
|
||||
'use client';
|
||||
|
||||
import { EditableTitle } from './EditableTitle';
|
||||
import { updateSessionTitle } from '@/actions/session';
|
||||
import { updateMotivatorSession } from '@/actions/moving-motivators';
|
||||
import { updateYearReviewSession } from '@/actions/year-review';
|
||||
import { updateWeatherSession } from '@/actions/weather';
|
||||
import { updateWeeklyCheckInSession } from '@/actions/weekly-checkin';
|
||||
import { updateGifMoodSession } from '@/actions/gif-mood';
|
||||
|
||||
interface TitleProps {
|
||||
sessionId: string;
|
||||
initialTitle: string;
|
||||
canEdit: boolean;
|
||||
}
|
||||
|
||||
export function EditableSessionTitle(props: TitleProps) {
|
||||
return <EditableTitle {...props} onUpdate={updateSessionTitle} />;
|
||||
}
|
||||
|
||||
export function EditableMotivatorTitle(props: TitleProps) {
|
||||
return <EditableTitle {...props} onUpdate={(id, title) => updateMotivatorSession(id, { title })} />;
|
||||
}
|
||||
|
||||
export function EditableYearReviewTitle(props: TitleProps) {
|
||||
return <EditableTitle {...props} onUpdate={(id, title) => updateYearReviewSession(id, { title })} />;
|
||||
}
|
||||
|
||||
export function EditableWeatherTitle(props: TitleProps) {
|
||||
return <EditableTitle {...props} onUpdate={(id, title) => updateWeatherSession(id, { title })} />;
|
||||
}
|
||||
|
||||
export function EditableWeeklyCheckInTitle(props: TitleProps) {
|
||||
return <EditableTitle {...props} onUpdate={(id, title) => updateWeeklyCheckInSession(id, { title })} />;
|
||||
}
|
||||
|
||||
export function EditableGifMoodTitle(props: TitleProps) {
|
||||
return <EditableTitle {...props} onUpdate={(id, title) => updateGifMoodSession(id, { title })} />;
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { EditableTitle } from './EditableTitle';
|
||||
import { updateWeatherSession } from '@/actions/weather';
|
||||
|
||||
interface EditableWeatherTitleProps {
|
||||
sessionId: string;
|
||||
initialTitle: string;
|
||||
canEdit: boolean;
|
||||
}
|
||||
|
||||
export function EditableWeatherTitle({
|
||||
sessionId,
|
||||
initialTitle,
|
||||
canEdit,
|
||||
}: EditableWeatherTitleProps) {
|
||||
return (
|
||||
<EditableTitle
|
||||
sessionId={sessionId}
|
||||
initialTitle={initialTitle}
|
||||
canEdit={canEdit}
|
||||
onUpdate={async (id, title) => {
|
||||
const result = await updateWeatherSession(id, { title });
|
||||
return result;
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { EditableTitle } from './EditableTitle';
|
||||
import { updateWeeklyCheckInSession } from '@/actions/weekly-checkin';
|
||||
|
||||
interface EditableWeeklyCheckInTitleProps {
|
||||
sessionId: string;
|
||||
initialTitle: string;
|
||||
canEdit: boolean;
|
||||
}
|
||||
|
||||
export function EditableWeeklyCheckInTitle({
|
||||
sessionId,
|
||||
initialTitle,
|
||||
canEdit,
|
||||
}: EditableWeeklyCheckInTitleProps) {
|
||||
return (
|
||||
<EditableTitle
|
||||
sessionId={sessionId}
|
||||
initialTitle={initialTitle}
|
||||
canEdit={canEdit}
|
||||
onUpdate={async (id, title) => {
|
||||
const result = await updateWeeklyCheckInSession(id, { title });
|
||||
return result;
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { EditableTitle } from './EditableTitle';
|
||||
import { updateYearReviewSession } from '@/actions/year-review';
|
||||
|
||||
interface EditableYearReviewTitleProps {
|
||||
sessionId: string;
|
||||
initialTitle: string;
|
||||
canEdit: boolean;
|
||||
}
|
||||
|
||||
export function EditableYearReviewTitle({
|
||||
sessionId,
|
||||
initialTitle,
|
||||
canEdit,
|
||||
}: EditableYearReviewTitleProps) {
|
||||
return (
|
||||
<EditableTitle
|
||||
sessionId={sessionId}
|
||||
initialTitle={initialTitle}
|
||||
canEdit={canEdit}
|
||||
onUpdate={async (id, title) => {
|
||||
const result = await updateYearReviewSession(id, { title });
|
||||
return result;
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -4,11 +4,14 @@ export { Button } from './Button';
|
||||
export { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from './Card';
|
||||
export { CollaboratorDisplay } from './CollaboratorDisplay';
|
||||
export { EditableTitle } from './EditableTitle';
|
||||
export { EditableSessionTitle } from './EditableSessionTitle';
|
||||
export { EditableMotivatorTitle } from './EditableMotivatorTitle';
|
||||
export { EditableYearReviewTitle } from './EditableYearReviewTitle';
|
||||
export { EditableWeeklyCheckInTitle } from './EditableWeeklyCheckInTitle';
|
||||
export { EditableWeatherTitle } from './EditableWeatherTitle';
|
||||
export {
|
||||
EditableSessionTitle,
|
||||
EditableMotivatorTitle,
|
||||
EditableYearReviewTitle,
|
||||
EditableWeeklyCheckInTitle,
|
||||
EditableWeatherTitle,
|
||||
EditableGifMoodTitle,
|
||||
} from './EditableTitles';
|
||||
export { PageHeader } from './PageHeader';
|
||||
export { Input } from './Input';
|
||||
export { ParticipantInput } from './ParticipantInput';
|
||||
|
||||
Reference in New Issue
Block a user