2024-07-20 02:00:00 +02:00
|
|
|
import * as React from "bloatless-react";
|
|
|
|
|
|
|
|
|
|
export function Option(text: string, value: string, selectedOnCreate: boolean) {
|
2026-04-01 08:29:39 +00:00
|
|
|
return (
|
|
|
|
|
<option value={value} toggle:selected={selectedOnCreate}>
|
|
|
|
|
{text}
|
|
|
|
|
</option>
|
|
|
|
|
);
|
2024-07-20 02:00:00 +02:00
|
|
|
}
|
2024-07-20 02:56:44 +02:00
|
|
|
|
|
|
|
|
export const StringToOption: React.StateItemConverter<string> = (
|
2026-04-01 08:29:39 +00:00
|
|
|
string: string,
|
2024-07-20 02:56:44 +02:00
|
|
|
) => {
|
2026-04-01 08:29:39 +00:00
|
|
|
return Option(string, string, false);
|
2024-07-20 02:56:44 +02:00
|
|
|
};
|
2024-07-24 15:57:02 +02:00
|
|
|
|
2024-07-28 17:09:27 +02:00
|
|
|
export const EntryToOption: React.StateItemConverter<Entry> = (
|
2026-04-01 08:29:39 +00:00
|
|
|
entry: Entry,
|
2024-07-28 17:09:27 +02:00
|
|
|
) => {
|
2026-04-01 08:29:39 +00:00
|
|
|
return Option(entry[1], entry[0], false);
|
2024-07-28 17:09:27 +02:00
|
|
|
};
|
|
|
|
|
|
2024-07-24 15:57:02 +02:00
|
|
|
export const VersionIdToOption: React.StateItemConverter<string> = (
|
2026-04-01 08:29:39 +00:00
|
|
|
versionId: string,
|
2024-07-24 15:57:02 +02:00
|
|
|
) => {
|
2026-04-01 08:29:39 +00:00
|
|
|
const [date, rest] = versionId.split("T");
|
|
|
|
|
const [time] = rest.split(".");
|
|
|
|
|
const readableName = `${date} ${time}`;
|
|
|
|
|
return Option(readableName, versionId, false);
|
2024-07-24 15:57:02 +02:00
|
|
|
};
|
2024-07-28 17:09:27 +02:00
|
|
|
|
|
|
|
|
export type Entry = [string, string];
|