Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose updated_at detail and render correctly #744

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions adminapp/src/pages/OrganizationDetailPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ export default function OrganizationDetailPage() {
organizationLabel: `(${model.id}) ${model.name || "-"}`,
})}
addNewRole="organizationMembership"
headers={["Id", "Member", "Created At", "Updated At"]}
headers={["Id", "Member", "Created At"]}
keyRowAttr="id"
toCells={(row) => [
<AdminLink model={row} />,
<AdminLink key="member" model={row.member}>
{row.member.name}
</AdminLink>,
dayjs(row.createdAt).format("lll"),
dayjs(row.updatedAt).format("lll"),
]}
/>
</>
Expand Down
2 changes: 1 addition & 1 deletion adminapp/src/pages/PaymentTriggerDetailPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function PaymentTriggerDetailPage() {
{ label: "ID", value: model.id },
{ label: "Label", value: model.label },
{ label: "Created At", value: dayjs(model.createdAt) },
{ label: "Updated At", value: model.updatedAt && dayjs(model.updatedAt) },
{ label: "Updated At", value: dayjs(model.updatedAt) },
{ label: "Starting", value: dayjs(model.activeDuringBegin) },
{ label: "Ending", value: dayjs(model.activeDuringEnd) },
{ label: "Match Multiplier", value: model.matchMultiplier },
Expand Down
2 changes: 2 additions & 0 deletions lib/suma/admin_api/anon_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ class VendorAccountEntity < BaseEntity

class DetailedVendorConfigurationEntity < VendorConfigurationEntity
include Suma::AdminAPI::Entities
include AutoExposeDetail
expose :programs, with: ProgramEntity
expose :instructions, with: TranslatedTextEntity
end

class DetailedVendorAccountEntity < VendorAccountEntity
include Suma::AdminAPI::Entities
include AutoExposeDetail
expose :latest_access_code
expose :latest_access_code_set_at
expose :latest_access_code_requested_at
Expand Down
1 change: 1 addition & 0 deletions lib/suma/admin_api/commerce_offering_products.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Suma::AdminAPI::CommerceOfferingProducts < Suma::AdminAPI::V1
class DetailedCommerceOfferingProductEntity < BaseEntity
include Suma::AdminAPI::Entities
include AutoExposeBase
include AutoExposeDetail
expose :offering, with: OfferingEntity
expose :product, with: ProductEntity
expose :customer_price, with: MoneyEntity
Expand Down
4 changes: 3 additions & 1 deletion lib/suma/admin_api/entities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ def self.included(ctx)
# detailed entities, or limited lists.
module AutoExposeDetail
def self.included(ctx)
ctx.expose :updated_at, if: ->(o) { o.respond_to?(:updated_at) }
ctx.expose :updated_at, if: ->(o) { o.respond_to?(:updated_at) } do |inst|
inst.updated_at || inst.created_at
end
# Always expose an external links array when we mix this in
ctx.expose :external_links do |inst|
inst.respond_to?(:external_links) ? inst.external_links : []
Expand Down
1 change: 1 addition & 0 deletions lib/suma/admin_api/organizations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Suma::AdminAPI::Organizations < Suma::AdminAPI::V1

class DetailedOrganizationEntity < OrganizationEntity
include Suma::AdminAPI::Entities
include AutoExposeDetail
expose :memberships, with: OrganizationMembershipEntity
expose :program_enrollments, with: ProgramEnrollmentEntity
end
Expand Down
2 changes: 2 additions & 0 deletions lib/suma/admin_api/program_enrollments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

class Suma::AdminAPI::ProgramEnrollments < Suma::AdminAPI::V1
include Suma::AdminAPI::Entities

class DetailedProgramEnrollmentEntity < ProgramEnrollmentEntity
include Suma::AdminAPI::Entities
include AutoExposeDetail
expose :approved?, as: :approved
expose :approved_by, with: MemberEntity
expose :unenrolled?, as: :unenrolled
Expand Down
6 changes: 5 additions & 1 deletion lib/suma/admin_api/roles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

class Suma::AdminAPI::Roles < Suma::AdminAPI::V1
class RoleEntity < Suma::AdminAPI::Entities::RoleEntity; end
class DetailedRoleEntity < RoleEntity; end

class DetailedRoleEntity < RoleEntity
include Suma::AdminAPI::Entities
include AutoExposeDetail
end

resource :roles do
desc "Return all roles, ordered by name"
Expand Down
2 changes: 2 additions & 0 deletions lib/suma/admin_api/vendor_services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Suma::AdminAPI::VendorServices < Suma::AdminAPI::V1
class DetailedMobilityTripEntity < BaseEntity
include Suma::AdminAPI::Entities
include AutoExposeBase
include AutoExposeDetail
expose :vehicle_id
expose :vendor_service_rate, as: :rate, with: VendorServiceRateEntity
expose :begin_lat
Expand All @@ -23,6 +24,7 @@ class DetailedMobilityTripEntity < BaseEntity

class DetailedVendorServiceEntity < VendorServiceEntity
include Suma::AdminAPI::Entities
include AutoExposeDetail
expose :external_name
expose :internal_name
expose :mobility_vendor_adapter_key
Expand Down
1 change: 1 addition & 0 deletions lib/suma/admin_api/vendors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Suma::AdminAPI::Vendors < Suma::AdminAPI::V1

class DetailedVendorEntity < VendorEntity
include Suma::AdminAPI::Entities
include AutoExposeDetail
expose :slug
expose :services, with: VendorServiceEntity
expose :products, with: ProductEntity
Expand Down
Loading