Skip to content

Commit 188ac93

Browse files
Cory feedback
1 parent 961ce9d commit 188ac93

5 files changed

Lines changed: 29 additions & 260 deletions

File tree

client/app/components/BatchEditMovieForm/BatchEditMovieForm.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ export default function BatchEditMovieForm({
4343
const validateForm = () => {
4444
const newErrors: Record<string, string> = {};
4545

46-
// For batch updates, we only validate if fields have values
46+
// For batch updates, we only validate if a field has a value and if
47+
// that value must meet certain criteria.
4748
// Empty fields will be ignored in the update
4849

4950
if (formData.year && (parseInt(formData.year) < 1800 || parseInt(formData.year) > new Date().getFullYear() + 5)) {
@@ -105,7 +106,7 @@ export default function BatchEditMovieForm({
105106
updateData.poster = formData.poster.trim();
106107
}
107108

108-
// Check if there's actually something to update
109+
// Check if user entered anything for the batch update
109110
if (Object.keys(updateData).length === 0) {
110111
setErrors({ general: 'Please fill in at least one field to update' });
111112
return;
@@ -208,7 +209,7 @@ export default function BatchEditMovieForm({
208209
onChange={(e) => handleInputChange('rated', e.target.value)}
209210
className={styles.input}
210211
disabled={isLoading}
211-
placeholder="e.g., PG-13, R, G"
212+
placeholder="PG-13"
212213
/>
213214
</div>
214215

@@ -241,7 +242,7 @@ export default function BatchEditMovieForm({
241242
className={styles.textarea}
242243
disabled={isLoading}
243244
rows={4}
244-
placeholder="Leave empty to keep existing plots..."
245+
placeholder="Leave empty to keep existing plots"
245246
/>
246247
</div>
247248

@@ -258,7 +259,7 @@ export default function BatchEditMovieForm({
258259
onChange={(e) => handleInputChange('genres', e.target.value)}
259260
className={styles.input}
260261
disabled={isLoading}
261-
placeholder="Action, Drama, Comedy"
262+
placeholder="e.g. Action, Drama, Comedy"
262263
/>
263264
</div>
264265

@@ -273,7 +274,7 @@ export default function BatchEditMovieForm({
273274
onChange={(e) => handleInputChange('directors', e.target.value)}
274275
className={styles.input}
275276
disabled={isLoading}
276-
placeholder="Director 1, Director 2"
277+
placeholder="e.g. Director 1, Director 2"
277278
/>
278279
</div>
279280

@@ -288,7 +289,7 @@ export default function BatchEditMovieForm({
288289
onChange={(e) => handleInputChange('writers', e.target.value)}
289290
className={styles.input}
290291
disabled={isLoading}
291-
placeholder="Writer 1, Writer 2"
292+
placeholder="e.g. Writer 1, Writer 2"
292293
/>
293294
</div>
294295

@@ -303,7 +304,7 @@ export default function BatchEditMovieForm({
303304
onChange={(e) => handleInputChange('cast', e.target.value)}
304305
className={styles.input}
305306
disabled={isLoading}
306-
placeholder="Actor 1, Actor 2, Actor 3"
307+
placeholder="e.g. Actor 1, Actor 2, Actor 3"
307308
/>
308309
</div>
309310

@@ -318,7 +319,7 @@ export default function BatchEditMovieForm({
318319
onChange={(e) => handleInputChange('countries', e.target.value)}
319320
className={styles.input}
320321
disabled={isLoading}
321-
placeholder="USA, UK, France"
322+
placeholder="e.g. USA, UK, France"
322323
/>
323324
</div>
324325

@@ -333,7 +334,7 @@ export default function BatchEditMovieForm({
333334
onChange={(e) => handleInputChange('languages', e.target.value)}
334335
className={styles.input}
335336
disabled={isLoading}
336-
placeholder="English, Spanish, French"
337+
placeholder="e.g. English, Spanish, French"
337338
/>
338339
</div>
339340
</div>

client/app/components/EditMovieForm/EditMovieForm.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ export default function EditMovieForm({
8787
Object.entries(updateData).filter(([_, value]) => value !== undefined)
8888
);
8989

90+
// Check if user entered anything for the batch update
91+
if (Object.keys(updateData).length === 0) {
92+
setErrors({ general: 'Please fill in at least one field to update' });
93+
return;
94+
}
95+
9096
onSave(cleanedData);
9197
};
9298

@@ -169,7 +175,7 @@ export default function EditMovieForm({
169175
onChange={(e) => handleInputChange('rated', e.target.value)}
170176
className={styles.input}
171177
disabled={isLoading}
172-
placeholder="e.g., PG-13, R, G"
178+
placeholder="PG-13"
173179
/>
174180
</div>
175181

@@ -219,7 +225,7 @@ export default function EditMovieForm({
219225
onChange={(e) => handleInputChange('genres', e.target.value)}
220226
className={styles.input}
221227
disabled={isLoading}
222-
placeholder="Action, Drama, Comedy"
228+
placeholder="e.g. Action, Drama, Comedy"
223229
/>
224230
</div>
225231

@@ -234,7 +240,7 @@ export default function EditMovieForm({
234240
onChange={(e) => handleInputChange('directors', e.target.value)}
235241
className={styles.input}
236242
disabled={isLoading}
237-
placeholder="Director 1, Director 2"
243+
placeholder="e.g. Director 1, Director 2"
238244
/>
239245
</div>
240246

@@ -249,7 +255,7 @@ export default function EditMovieForm({
249255
onChange={(e) => handleInputChange('writers', e.target.value)}
250256
className={styles.input}
251257
disabled={isLoading}
252-
placeholder="Writer 1, Writer 2"
258+
placeholder="e.g. Writer 1, Writer 2"
253259
/>
254260
</div>
255261

@@ -264,7 +270,7 @@ export default function EditMovieForm({
264270
onChange={(e) => handleInputChange('cast', e.target.value)}
265271
className={styles.input}
266272
disabled={isLoading}
267-
placeholder="Actor 1, Actor 2, Actor 3"
273+
placeholder="e.g. Actor 1, Actor 2, Actor 3"
268274
/>
269275
</div>
270276

@@ -279,7 +285,7 @@ export default function EditMovieForm({
279285
onChange={(e) => handleInputChange('countries', e.target.value)}
280286
className={styles.input}
281287
disabled={isLoading}
282-
placeholder="USA, UK, France"
288+
placeholder="e.g. USA, UK, France"
283289
/>
284290
</div>
285291

@@ -294,7 +300,7 @@ export default function EditMovieForm({
294300
onChange={(e) => handleInputChange('languages', e.target.value)}
295301
className={styles.input}
296302
disabled={isLoading}
297-
placeholder="English, Spanish, French"
303+
placeholder="e.g. English, Spanish, French"
298304
/>
299305
</div>
300306
</div>

client/app/lib/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ export async function deleteMoviesBatch(movieIds: string[]): Promise<{ success:
319319
export async function updateMoviesBatch(movieIds: string[], updateData: Partial<Movie>): Promise<{ success: boolean; error?: string; matchedCount?: number; modifiedCount?: number }> {
320320
try {
321321
// Create filter to match the movie IDs
322+
// Note: The server will handle ObjectId conversion
322323
const filter = {
323324
_id: {
324325
$in: movieIds

client/app/movies/page.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,10 @@ export default function Movies() {
8282
setSuccessMessage('Movie created successfully!');
8383
setShowAddForm(false);
8484

85-
// If we have a movieId, redirect to the new movie's page after a brief delay
86-
if (result.movieId) {
87-
setTimeout(() => {
88-
router.push(ROUTES.movie(result.movieId!));
89-
}, 2000);
90-
} else {
91-
// Otherwise, refresh the movies list
92-
loadMovies();
93-
}
85+
// Redirect to the new movie's page after a brief delay
86+
setTimeout(() => {
87+
router.push(ROUTES.movie(result.movieId!));
88+
}, 2000);
9489
} else {
9590
setError(result.error || 'Failed to create movie');
9691
}

0 commit comments

Comments
 (0)