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

chore: Cleanup Admin columns and default values #2236

Merged
merged 5 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
74 changes: 31 additions & 43 deletions assets/src/components/admin/admin_add_modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,13 @@ const fields = [
key: "app_id",
label: "App ID",
FormCell: buildFormSelect([
"bus_eink",
"bus_eink_v2",
"bus_shelter_v2",
"busway_v2",
"dup",
"dup_v2",
"gl_eink_double",
"gl_eink_single",
"gl_eink_v2",
"pre_fare_v2",
"solari",
"solari_large",
"solari_large_v2",
]),
},
{
Expand All @@ -42,52 +36,47 @@ const fields = [
{ key: "device_id", label: "Device ID", FormCell: FormTextCell },
];

const commonV2Params = {
header: { stop_id: "" },
digitalcora marked this conversation as resolved.
Show resolved Hide resolved
evergreen_content: [],
};

const departuresWidgetParams = { sections: [] };
const footerWidgetParams = { stop_id: "" };
const alertsWidgetParams = { stop_id: "" };

const defaultAppParamsByAppId = {
bus_eink: { stop_id: "STOP_ID" },
bus_eink_v2: {
departures: {},
footer: {},
header: {},
alerts: {},
},
gl_eink_single: {
stop_id: "STOP_ID",
platform_id: "PLATFORM_ID",
route_id: "ROUTE_ID",
direction_id: -1,
},
gl_eink_double: {
stop_id: "STOP_ID",
platform_id: "PLATFORM_ID",
route_id: "ROUTE_ID",
direction_id: -1,
...commonV2Params,
departures: departuresWidgetParams,
footer: footerWidgetParams,
alerts: alertsWidgetParams,
},
gl_eink_v2: {
departures: {},
footer: {},
header: {},
alerts: {},
...commonV2Params,
departures: departuresWidgetParams,
footer: footerWidgetParams,
alerts: alertsWidgetParams,
},
solari: { station_name: "STATION_NAME" },
dup: { header: "STATION_NAME" },
dup_v2: {
...commonV2Params,
primary_departures: departuresWidgetParams,
secondary_departures: departuresWidgetParams,
alerts: alertsWidgetParams,
},
bus_shelter_v2: {
departures: {},
footer: {},
header: {},
alerts: {},
...commonV2Params,
departures: departuresWidgetParams,
footer: footerWidgetParams,
alerts: alertsWidgetParams,
},
busway_v2: {
departures: {},
header: {},
},
solari_large_v2: {
departures: {},
header: {},
...commonV2Params,
departures: departuresWidgetParams,
},
pre_fare_v2: {
header: {
stop_name: "",
},
...commonV2Params,
},
};

Expand All @@ -101,8 +90,7 @@ const AddModal = ({ setData, closeModal }): JSX.Element => {
const addScreen = () => {
const newRow = {
app_id: formValues.app_id,
// @ts-expect-error
app_params: defaultAppParamsByAppId[formValues.app_id],
app_params: defaultAppParamsByAppId[formValues.app_id ?? 0],
digitalcora marked this conversation as resolved.
Show resolved Hide resolved
device_id: formValues.device_id,
disabled: false,
id: formValues.id,
Expand Down
Loading
Loading