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

fix: preview reservation unit link disabled #1238

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion apps/admin-ui/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NEXT_PUBLIC_BASE_URL=/kasittely
TILAVARAUS_API_URL=http://localhost:8000
TUNNISTAMO_URL=https://tunnistamo.test.hel.ninja
RESERVATION_UNIT_PREVIEW_URL_PREFIX="/"
RESERVATION_UNIT_PREVIEW_URL_PREFIX="http://localhost:3000/reservation-unit"
11 changes: 7 additions & 4 deletions apps/admin-ui/src/spa/ReservationUnit/edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,7 @@ function OpeningHoursSection({

const previewUrl = `${previewUrlPrefix}/${reservationUnit?.pk}?ru=${reservationUnit?.uuid}#calendar`;
const previewDisabled =
previewUrlPrefix !== "" || !reservationUnit?.pk || !reservationUnit?.uuid;
previewUrlPrefix === "" || !reservationUnit?.pk || !reservationUnit?.uuid;

// TODO refactor this to inner wrapper (so we don't have a ternary in the middle)
return (
Expand Down Expand Up @@ -2095,8 +2095,9 @@ function ReservationUnitEditor({
const previewDisabled =
isSaving ||
!reservationUnit?.pk ||
!reservationUnit?.uuid ||
previewUrlPrefix !== "";
!reservationUnit.uuid ||
previewUrlPrefix === "";

const draftEnabled = hasChanges || !watch("isDraft");
const publishEnabled = hasChanges || watch("isDraft");
const archiveEnabled = watch("pk") !== 0 && !watch("isArchived");
Expand Down Expand Up @@ -2288,6 +2289,8 @@ function EditorWrapper({ previewUrlPrefix }: { previewUrlPrefix: string }) {
];
const backLink = reservationUnitPk == null ? `/unit/${unitPk}` : undefined;

const cleanPreviewUrlPrefix = previewUrlPrefix.replace(/\/$/, "");

return (
<Wrapper>
<BreadcrumbWrapper route={route} backLink={backLink} />
Expand All @@ -2296,7 +2299,7 @@ function EditorWrapper({ previewUrlPrefix }: { previewUrlPrefix: string }) {
form={form}
unitPk={unitPk}
refetch={refetch}
previewUrlPrefix={previewUrlPrefix}
previewUrlPrefix={cleanPreviewUrlPrefix}
/>
</Wrapper>
);
Expand Down
Loading