diff --git a/api/app/Controllers/Http/PlacesController.ts b/api/app/Controllers/Http/PlacesController.ts index 019232f..e2ebd74 100644 --- a/api/app/Controllers/Http/PlacesController.ts +++ b/api/app/Controllers/Http/PlacesController.ts @@ -45,6 +45,7 @@ export default class PlacesController { return response.status(403).send({ message: 'You do not have permission to access this resource' }) } + posted.user_id = auth.user?.id const place = await Place.create(posted) await illustration.related('places').save(place) return response.send({message: 'Created successfully', id: place.id}) @@ -60,7 +61,7 @@ export default class PlacesController { */ public async update({ params, auth, request, response }: HttpContextContract) { - const post = request.post() + const post = request.body() let place = await Place.findOrFail(params.id) diff --git a/api/tests/functional/place.spec.ts b/api/tests/functional/place.spec.ts index 205ca7e..7ed6462 100644 --- a/api/tests/functional/place.spec.ts +++ b/api/tests/functional/place.spec.ts @@ -49,11 +49,19 @@ test.group('Place', (group) => { const loggedInUser = await client.post('/login').json({ email: goodUser.email, password: 'oasssadfasdf' }) const illustration = await Illustration.findByOrFail('title', 'Places Test') - const place = await PlaceFactory.make() -// console.log(place.toJSON()) - const response = await client.post(`/places/${illustration.id}`).bearerToken(loggedInUser.body().token).json(place.toJSON()) + // not forcing the user ID here + // also not using factory, which creates a user + const place = { + place: 'Gusikowski and Sons', + location: 'South Tressie, South Dakota', + used: '2023-03-11' + } + + const response = await client.post(`/places/${illustration.id}`).bearerToken(loggedInUser.body().token).json(place) response.assertStatus(200) - assert.equal(response.body().message,'Created successfully') + // console.log(response.body()) + assert.equal(response.body().message, 'Created successfully') + assert.equal(response.body().place.user_id,goodUser.id) assert.isNumber(response.body().id) }) diff --git a/frontend/src/components/IllustrationForm.tsx b/frontend/src/components/IllustrationForm.tsx index c693508..6a1f826 100644 --- a/frontend/src/components/IllustrationForm.tsx +++ b/frontend/src/components/IllustrationForm.tsx @@ -88,7 +88,8 @@ export default function IllustrationForm({ illustration }: { - : <> -
-
- Title: - {illustration?.title ? illustration.title : 'Default Title'} -
-
- Author: - {illustration?.author ? illustration.author : 'Default Title'} -
-
- Source: - {illustration?.source ? - isValidHttpUrl(illustration.source) ? {illustration.source} : illustration.source - : 'Default Title'} -
-
- Tags: - {illustration?.tags ? illustration.tags.map((tag, index, arr) => ( - {tag.name.replace(/-/g, " ")}{index != (arr.length-1) ? ', ' : ''} - )) - : 'no tags'} -
+
+
+ Title: + {/* Title is required */} + {illustration?.title} +
+ {illustration?.author && +
+ Author: + {illustration.author} +
} + {illustration?.source &&
+ Source: + {isValidHttpUrl(illustration.source) ? {illustration.source} : illustration.source} +
} + {illustration?.tags &&
+ Tags: + {illustration?.tags ? illustration.tags.map((tag, index, arr) => ( + {tag.name.replace(/-/g, " ")}{index != (arr.length - 1) ? ', ' : ''} + )) + : 'no tags'} +
}
{illustration?.content && } -
+
{illustration?.content ? illustration.content : 'No Content'}
@@ -144,10 +144,10 @@ export default function IllustrationWrapper() { Back + Edit Illustration + Delete Illustration
@@ -157,14 +157,14 @@ export default function IllustrationWrapper() {
Illustration Use:
-
+
{illustration && illustration?.places.length > 0 ? illustration.places.map((p, index) => (
{p.place}, {p.location} - {p.used}
)) @@ -174,7 +174,7 @@ export default function IllustrationWrapper() {
-
+
@@ -183,10 +183,10 @@ export default function IllustrationWrapper() { name="Place" id="Place" placeholder="Place" - className="block w-full rounded-l-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6" + className="block w-full lg:rounded-l-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6" />
-
+
@@ -198,7 +198,7 @@ export default function IllustrationWrapper() { className="block w-full border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6" />
-
+
@@ -211,7 +211,7 @@ export default function IllustrationWrapper() { />