Skip to content

Commit 07002cf

Browse files
authored
Merge pull request #8561 from sagemathinc/fix-admin-license-8559
frontend/admin/license: fix expire date field
2 parents 6f00c6e + 9cf993f commit 07002cf

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/packages/frontend/cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"ggplot",
1919
"ipython",
2020
"ipywidgets",
21+
"jsonic",
2122
"katex",
2223
"knitr",
2324
"kucalc",

src/packages/frontend/site-licenses/admin/license.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ import jsonic from "jsonic";
77
import { DebounceInput } from "react-debounce-input";
88
import { useIntl } from "react-intl";
99

10-
import { labels } from "@cocalc/frontend/i18n";
1110
import { Projects } from "@cocalc/frontend/admin/users/projects";
1211
import { Button, Checkbox } from "@cocalc/frontend/antd-bootstrap";
1312
import { CSS, Rendered, TypedMap } from "@cocalc/frontend/app-framework";
1413
import {
1514
A,
1615
CopyToClipBoard,
1716
DateTimePicker,
18-
Icon,
1917
Gap,
18+
Icon,
2019
TimeAgo,
2120
} from "@cocalc/frontend/components";
21+
import { labels } from "@cocalc/frontend/i18n";
2222
import {
2323
capitalize,
2424
days_ago,
@@ -35,7 +35,7 @@ import { actions } from "./actions";
3535
import { Managers } from "./managers";
3636
import Owner from "./owner";
3737
import { DisplayQuota, EditQuota } from "./quota";
38-
import { license_fields, license_field_type, ManagerInfo } from "./types";
38+
import { license_field_type, license_fields, ManagerInfo } from "./types";
3939
import {
4040
DisplayUpgrades,
4141
EditUpgrades,
@@ -142,6 +142,12 @@ export const License: React.FC<Props> = (props: Props) => {
142142
actions.set_edit(license.get("id"), field, new_val);
143143
}
144144

145+
function on_date_change(field, _date, dateString): void {
146+
// For date fields, use the dateString instead of the Day.js object
147+
// to ensure proper serialization for PostgreSQL
148+
actions.set_edit(license.get("id"), field, dateString || null);
149+
}
150+
145151
function render_value_editing(
146152
type: license_field_type,
147153
field,
@@ -190,7 +196,9 @@ export const License: React.FC<Props> = (props: Props) => {
190196
x = (
191197
<DateTimePicker
192198
value={val}
193-
onChange={onChange}
199+
onChange={(date, dateString) =>
200+
on_date_change(field, date, dateString)
201+
}
194202
style={{ width: "100%", maxWidth: "40ex" }}
195203
/>
196204
);
@@ -517,7 +525,7 @@ export const License: React.FC<Props> = (props: Props) => {
517525
return (
518526
<>
519527
<Button onClick={() => actions.cancel_editing(id)} disabled={saving}>
520-
{intl.formatMessage(labels.cancel)}
528+
{intl.formatMessage(labels.cancel)}
521529
</Button>
522530
<Gap />
523531
<Button
@@ -577,7 +585,7 @@ export const License: React.FC<Props> = (props: Props) => {
577585

578586
// Show a message explaining whether -- with the current saved settings --
579587
// this license will upgrade any projects. Only shown in view mode, to
580-
// avoid potentional confusion in edit mode.
588+
// avoid potential confusion in edit mode.
581589
function render_status(): Rendered {
582590
if (editing) {
583591
return (

0 commit comments

Comments
 (0)