Skip to content

Commit

Permalink
chore: generalize PaMessageForm
Browse files Browse the repository at this point in the history
Moves form component for PA messages from `NewPaMessage` into
`PaMessageForm` so that it can be used to make an `EditPaMessage`
component later on.
  • Loading branch information
sloanelybutsurely committed Aug 20, 2024
1 parent 635a43b commit d727b89
Show file tree
Hide file tree
Showing 17 changed files with 16 additions and 10 deletions.
13 changes: 7 additions & 6 deletions assets/js/components/Dashboard/NewPaMessage/NewPaMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React, { useState } from "react";
import moment, { type Moment } from "moment";
import { Page } from "./types";
import NewPaMessagePage from "./NewPaMessagePage";
import AssociateAlertPage from "./AssociateAlertPage";
import PaMessageForm, {
Page,
SelectStationsAndZones,
AssociateAlert,
} from "../PaMessageForm";
import { Alert, InformedEntity } from "Models/alert";
import SelectStationsAndZones from "./StationsAndZones/SelectStationsAndZones";
import { usePlacesWithPaEss } from "Hooks/usePlacesWithPaEss";
import ErrorToast from "Components/ErrorToast";
import { PaMessage } from "Models/pa_message";
Expand Down Expand Up @@ -105,7 +106,7 @@ const NewPaMessage = () => {
return (
<div className="new-pa-message">
{page === Page.NEW && (
<NewPaMessagePage
<PaMessageForm
{...{
days,
interval,
Expand Down Expand Up @@ -150,7 +151,7 @@ const NewPaMessage = () => {
</div>
)}
{page === Page.ALERTS && (
<AssociateAlertPage
<AssociateAlert
associatedAlert={associatedAlert}
endWithEffectPeriod={endWithEffectPeriod}
onImportMessage={onImportMessage}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface AssociateAlertPageProps {
setEndWithEffectPeriod: Dispatch<SetStateAction<boolean>>;
}

const AssociateAlertPage = ({
const AssociateAlert = ({
associatedAlert,
endWithEffectPeriod,
onImportMessage,
Expand Down Expand Up @@ -346,4 +346,4 @@ const AssociateAlertsTableRow: ComponentType<AssociateAlertsTableRowProps> = ({
);
};

export default AssociateAlertPage;
export default AssociateAlert;
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ interface Props {
onSubmit: () => void;
}

const NewPaMessagePage = ({
const PaMessageForm = ({
days,
startDateTime,
setStartDateTime,
Expand Down Expand Up @@ -538,4 +538,4 @@ const NewPaMessageHeader = ({
);
};

export default NewPaMessagePage;
export default PaMessageForm;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./SelectStationsAndZones";
4 changes: 4 additions & 0 deletions assets/js/components/Dashboard/PaMessageForm/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { Page } from "./types";
export { default } from "./PaMessageForm";
export { default as SelectStationsAndZones } from "./SelectStationsAndZones";
export { default as AssociateAlert } from "./AssociateAlert";

0 comments on commit d727b89

Please sign in to comment.