From 267aaa17761bee09e70e70a6b663f78d003028c7 Mon Sep 17 00:00:00 2001 From: Philipp Lang Date: Wed, 20 Dec 2023 22:58:26 +0100 Subject: [PATCH] Only display promised_at when is_age_group --- app/Membership/MembershipResource.php | 2 +- package-lock.json | 13 ++++ package.json | 1 + .../js/views/member/MemberMemberships.vue | 60 +++++++++++++------ tests/Feature/Membership/IndexTest.php | 1 + 5 files changed, 58 insertions(+), 19 deletions(-) diff --git a/app/Membership/MembershipResource.php b/app/Membership/MembershipResource.php index a7bcf9f2..f24e68e7 100644 --- a/app/Membership/MembershipResource.php +++ b/app/Membership/MembershipResource.php @@ -52,7 +52,7 @@ class MembershipResource extends JsonResource ], 'groups' => NestedGroup::cacheForSelect(), 'activities' => $activities->map(fn ($activity) => ['id' => $activity->id, 'name' => $activity->name]), - 'subactivities' => $activities->mapWithKeys(fn ($activity) => [$activity->id => $activity->subactivities->map(fn ($subactivity) => ['id' => $subactivity->id, 'name' => $subactivity->name])]), + 'subactivities' => $activities->mapWithKeys(fn ($activity) => [$activity->id => $activity->subactivities->map(fn ($subactivity) => ['id' => $subactivity->id, 'name' => $subactivity->name, 'is_age_group' => $subactivity->is_age_group])]), 'default' => [ 'group_id' => $member->group_id, 'activity_id' => null, diff --git a/package-lock.json b/package-lock.json index 90857362..c02bccb4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,6 +27,7 @@ "devDependencies": { "autoprefixer": "^10.4.14", "axios": "^1.4.0", + "dayjs": "^1.11.10", "eslint": "^8.43.0", "eslint-config-prettier": "^8.8.0", "eslint-plugin-vue": "^8.7.1", @@ -1545,6 +1546,12 @@ "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==" }, + "node_modules/dayjs": { + "version": "1.11.10", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz", + "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==", + "dev": true + }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -5165,6 +5172,12 @@ "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==" }, + "dayjs": { + "version": "1.11.10", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz", + "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==", + "dev": true + }, "debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", diff --git a/package.json b/package.json index c387126f..0d62d2ba 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "devDependencies": { "autoprefixer": "^10.4.14", "axios": "^1.4.0", + "dayjs": "^1.11.10", "eslint": "^8.43.0", "eslint-config-prettier": "^8.8.0", "eslint-plugin-vue": "^8.7.1", diff --git a/resources/js/views/member/MemberMemberships.vue b/resources/js/views/member/MemberMemberships.vue index b1cac382..e9da003f 100644 --- a/resources/js/views/member/MemberMemberships.vue +++ b/resources/js/views/member/MemberMemberships.vue @@ -1,24 +1,25 @@ diff --git a/tests/Feature/Membership/IndexTest.php b/tests/Feature/Membership/IndexTest.php index ce8a40ce..c41acf36 100644 --- a/tests/Feature/Membership/IndexTest.php +++ b/tests/Feature/Membership/IndexTest.php @@ -41,6 +41,7 @@ class IndexTest extends TestCase ->assertJsonPath('meta.groups.0.id', $group->id) ->assertJsonPath('meta.activities.0.id', $membership->activity_id) ->assertJsonPath("meta.subactivities.{$membership->activity_id}.0.id", $membership->subactivity_id) + ->assertJsonPath("meta.subactivities.{$membership->activity_id}.0.is_age_group", true) ->assertJsonPath('meta.links.store', route('member.membership.store', ['member' => $member])); }