Skip to content

Commit

Permalink
♻️ refactor(ConsultationEditor): Rewrite <Loader> signature.
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Jan 1, 2025
1 parent be37d3b commit cd5875d
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions imports/ui/consultations/ConsultationEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,19 +264,17 @@ const reducer = (state: State, action: Action) => {
};

type LoaderProps =
| {loading: true; found: any; consultation: any}
| {loading: false; found: false; consultation: any}
| {loading: true; found: unknown; consultation: unknown}
| {loading: false; found: false; consultation: unknown}
| {loading: false; found: true; consultation: ConsultationEditorFields};

const Loader = (props: LoaderProps) => {
if (props.loading) return <Loading />;
const Loader = ({loading, found, consultation}: LoaderProps) => {
if (loading) return <Loading />;

if (!props.found) {
if (!found) {
return <NoContent>Consultation not found.</NoContent>;
}

const {consultation} = props;

if (!consultation.isDone) return <Loading />;

return <ConsultationEditor consultation={consultation} />;
Expand Down

0 comments on commit cd5875d

Please sign in to comment.