mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-05 04:16:31 +02:00
* Update billing date subtext * Update billing acceptance tests... * Code cleanup and tests Co-authored-by: Kianna <30884335+kiannaquach@users.noreply.github.com>
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
/**
|
|
* Copyright IBM Corp. 2016, 2025
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Component from '@glimmer/component';
|
|
import { action } from '@ember/object';
|
|
import { dateFormat } from 'core/helpers/date-format';
|
|
|
|
import type { Month } from 'vault/vault/billing/overview';
|
|
|
|
interface Args {
|
|
months: Month[];
|
|
onDateChange: (selectedMonth: Month | null | undefined) => void;
|
|
selectedDateOption: Month | null | undefined;
|
|
}
|
|
|
|
export default class BillingDateRange extends Component<Args> {
|
|
get selectedDate() {
|
|
return this.args.selectedDateOption;
|
|
}
|
|
|
|
get dateDropdownOptions() {
|
|
const options = [];
|
|
|
|
for (const option of this.args.months) {
|
|
const formattedDate = dateFormat([option.month, 'MMMM yyyy'], {});
|
|
options.push({ label: formattedDate, value: option.month });
|
|
}
|
|
|
|
return options;
|
|
}
|
|
|
|
@action
|
|
updateSelectedDropdownOption(dropdownOption: string) {
|
|
const selectedDateOption: Month | undefined = this.args.months.find(
|
|
(option) => option.month === dropdownOption
|
|
);
|
|
this.args.onDateChange(selectedDateOption);
|
|
}
|
|
}
|