hackclub / hackclub/hcb

Standardize model status fields

Open
#5,002 1 comment 0 reactions 1 assignee Claimed by @Luke-Oldenburg View on GitHub
Dominant language
Ruby
Stars
870
Forks
138
Avg merge
1d 18h
Merged PRs (30d)
205

Description

The `AchTransfer` model has `status`, `status_text`, `status_text_long`, `state`, and `state_icon`, and they all return different things!

https://github.com/hackclub/hcb/blob/4236fc109e38ecd8a623bd51cc63bb5300fa3353/app/models/ach_transfer.rb#L161-L195

I propose that every stateful model should have:

- `state`, which returns the raw, unformatted state as a symbol (e.g. `:deposited`)
- `state_color`, which returns a CSS class for the color of the state badge (e.g. `info`)
- `state_icon`, an optional icon to display alongside the badge
- `---`
- An entry in `config/locales/en.yml` that contains humanized states, e.g.
```yml
states:
ach_transfer:
pending: "Pending approval"
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.