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

Edit crag routes #62

Open
wants to merge 72 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
f36e631
Basic layout.
salamca Nov 17, 2024
a9830f0
Add error message to select and update focus ring.
salamca Nov 22, 2024
33a9a98
New, update, delete route.
salamca Nov 22, 2024
62aade1
Hide lenght when no length on route.
salamca Nov 22, 2024
915ceec
Rework urls and folder structure.
salamca Nov 22, 2024
efa70d6
Add route sorting.
salamca Nov 22, 2024
5a8d578
Enable move route(s) to another sector.
salamca Nov 22, 2024
6e04909
Make actions row sticky.
salamca Nov 24, 2024
b700247
Export routes actions row to own component.
salamca Nov 24, 2024
10a6e84
Export new first route button into it's own component
salamca Nov 24, 2024
896db57
Fix issue with focus ring and z-index on add new first route button.
salamca Nov 24, 2024
d09ac42
Export new first sector button into it's own component
salamca Nov 24, 2024
deb65f3
Enable bulk move routes.
salamca Nov 24, 2024
5c9ff80
Fix new route button focus ring again, so that also dialog and within…
salamca Nov 24, 2024
f9bd1cb
Add bulk delete routes.
salamca Nov 26, 2024
257cacb
Fox some type names.
salamca Nov 30, 2024
c3c3df6
Adjust some radio component prop name.
salamca Nov 30, 2024
5db8f6d
Enable merge routes action.
salamca Nov 30, 2024
8275740
Add indeterminate checkbox state and wire up check all on edit routes.
salamca Nov 30, 2024
42add73
Wire up edit routes button on 'no-sectors' crags.
salamca Nov 30, 2024
614e75c
Fix some paddings and some other clean up.
salamca Nov 30, 2024
2d495dd
Wire up checking crag-has-sectors checkbox.
salamca Nov 30, 2024
21475cf
Use new mutation for moving routes to sector.
salamca Dec 7, 2024
000b988
Wire up unchecking crag-has-sectors checkbox.
salamca Dec 7, 2024
e91efd2
Change form handling to onSumbit event where action was used to make …
salamca Dec 7, 2024
d6d4fca
Disable move to another sector button when no sector to move to.
salamca Dec 7, 2024
02b3140
Fix usages of sector label, name. Also adjust titles and breadcrumbs …
salamca Dec 7, 2024
6cce46e
Add convert to sectorfullCrag cb to routes on sectorless crag. Fix ac…
salamca Dec 7, 2024
3b3d671
Enable publish status actions on routes.
salamca Dec 14, 2024
70b370b
Some layout adjustments on unpublished routes in admin.
salamca Dec 14, 2024
18369bc
Show text on publish actions if space allows.
salamca Dec 14, 2024
7baec13
Fix sorting routes.
salamca Dec 14, 2024
ad06f54
Display 'tvoj prispevek' instead of fullname if contributalbe is yours
salamca Jan 3, 2025
4415fc4
Add publish statuses and actions to edit sectors.
salamca Jan 5, 2025
4fe23a1
Add publish notification and actions to crag edit form.
salamca Jan 5, 2025
66689f6
Fix redirection after rejecting a crag.
salamca Jan 9, 2025
63dfd13
Auth put in context.
salamca Jan 11, 2025
c0e5791
Some layout fixes.
salamca Jan 13, 2025
9f2aa3f
Move scripts folder out of src.
salamca Jan 15, 2025
e27293a
Consolidate hooks folders.
salamca Jan 15, 2025
8393b64
Delete some deprecated file. Remove unneccessary import.
salamca Jan 15, 2025
5b6ea84
Rename user geter.
salamca Jan 15, 2025
df29380
Add loggedIn status to authContext. Some minor cleanup.
salamca Jan 15, 2025
a6cc83b
Remove cancel button on edit crag and disable save until data is actu…
salamca Jan 15, 2025
c4d00ce
Remove unneccessary clientProviders wrapper.
salamca Jan 15, 2025
7a8e6b1
Fix import typo.
salamca Jan 15, 2025
b62e330
Merge branch 'auth-context' into edit-crag-routes
salamca Jan 15, 2025
46acdac
Get rid of a bunch of prop drilling by using authContext.
salamca Jan 15, 2025
e0df83f
Fix dummy sector handling.
salamca Jan 18, 2025
6eead7f
Some props passing modifications.
salamca Jan 18, 2025
f727f96
Missed prop.
salamca Jan 18, 2025
3e2aba5
Adjust permissions on some edit actions. Some cleanup.
salamca Jan 18, 2025
217e942
Merge branch 'fix-checkbox' into edit-crag-routes
salamca Jan 18, 2025
03c8f4d
Merge fixed checkbox, add missing onChange.
salamca Jan 18, 2025
0b11e47
Merge branch 'text-area-hui' into edit-crag-routes
salamca Jan 18, 2025
f01827b
Fix new text-area usage.
salamca Jan 18, 2025
61c16ec
Some dry on contributables styles.
salamca Jan 18, 2025
d43c572
Dropdown menu component and sandbox.
salamca Jan 19, 2025
0650ce3
Some renaming as per new agreement.
salamca Jan 19, 2025
18119c3
Merge branch 'main' into edit-crag-routes
salamca Jan 19, 2025
3bf3a23
Fix merge salad.
salamca Jan 19, 2025
ef3bf1f
Merge branch 'popover-menu' into edit-crag-routes
salamca Jan 19, 2025
4f0c6c4
Add position prop.
salamca Jan 19, 2025
97b21e3
Merge branch 'popover-menu' into edit-crag-routes
salamca Jan 19, 2025
9cdac4b
One item only menu enabled.
salamca Jan 19, 2025
5939873
Merge branch 'popover-menu' into edit-crag-routes
salamca Jan 19, 2025
e5f6e29
Remove scroll locking. Disable word wrap on items. Remove align prop.
salamca Jan 21, 2025
03d970b
Merge branch 'popover-menu' into edit-crag-routes
salamca Jan 21, 2025
a7d8a02
Fix map auto bounds from markers as seen on crag info page.
salamca Jan 23, 2025
b4fdc51
Merge branch 'fix-map-again' into edit-crag-routes
salamca Jan 23, 2025
089963a
Wire up more button with edit crag on crag info page.
salamca Jan 23, 2025
5dc9e35
Fix tw scan dirs.
salamca Jan 24, 2025
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
1,142 changes: 636 additions & 506 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { Crag } from "@/graphql/generated";
import PublishStatusActions from "../../../components/publish-status-actions";
import { genderizeVerb } from "@/lib/text-helpers";
import getCurrentUser from "@/lib/auth/get-current-user";
import { getBgStyle } from "@/lib/contributables-helpers";

type TCragPublishStatusCard = {
crag: Crag;
};

async function CragPublishStatusCard({ crag }: TCragPublishStatusCard) {
const currentUser = await getCurrentUser();

return (
<div className="flex justify-center px-4 xs:px-8 mt-7 mb-8">
<div
className={`@container max-w-2xl w-full mx-auto rounded-lg ${getBgStyle(crag.publishStatus)}`}
>
<div className="px-4 py-3">
{currentUser?.roles.includes("admin") ? (
<>
{crag.publishStatus === "draft" && (
<>
Plezališče je v statusu{" "}
<span className="font-medium">osnutek</span>. Ko zaključiš z
urejanjem plezališča ter sektorjev in smeri v njem, ga objavi.
</>
)}

{crag.publishStatus === "in_review" && (
<>
Plezališče je v statusu{" "}
<span className="font-medium">v pregledu</span>. Ko zaključiš
s pregledom potrdi ali zavrni objavo.
</>
)}
</>
) : (
<>
{crag.publishStatus === "draft" && (
<>
Plezališče je v statusu{" "}
<span className="font-medium">osnutek</span>. Ko zaključiš z
urejanjem plezališča ter sektorjev in smeri v njem, ga pošlji
uredništvu v pregled in objavo.
</>
)}

{crag.publishStatus === "in_review" && (
<>
Plezališče je v statusu{" "}
<span className="font-medium">v pregledu</span>. Prispevek bo
objavljen ko bo pregledan s strani uredništva.
</>
)}
</>
)}
</div>

<div className="px-4 py-2 border-t border-neutral-200 flex justify-between items-center">
{/* contributor */}
<div className="flex text-neutral-500 py-1">
{currentUser && currentUser.id === crag.user?.id ? (
"Tvoj prispevek"
) : (
<>
<span className="hidden @sm:block">
{genderizeVerb("Prispeval", "M")}:&nbsp;
</span>
{crag.user?.fullName}
</>
)}
</div>

<PublishStatusActions contributable={crag} disabled={false} />
</div>
</div>
</div>
);
}

export default CragPublishStatusCard;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Country, Crag } from "@/graphql/generated";
import CragForm from "../../components/crag-form";
import CragForm from "../../../components/crag-form";

type TEditCragForm = {
countriesWithAreas: Country[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import Breadcrumbs from "@/components/breadcrumbs";
import ContentHeader from "@/components/content-header";
import IconInfo from "@/components/ui/icons/info";
import IconRoutes from "@/components/ui/icons/routes";
import TabMenu, { TTabMenuItem } from "@/components/ui/tab-menu";
import TabMenu from "@/components/ui/tab-menu";
import {
EditCragPageCountriesDocument,
EditCragPageCragDocument,
} from "@/graphql/generated";
import urqlServer from "@/graphql/urql-server";
import { gql } from "urql";
import EditCragForm from "./components/edit-crag-form";
import CragPublishStatusCard from "./components/crag-publish-status-card";

type TEditCragPageProps = {
params: { cragSlug: string };
Expand All @@ -30,21 +31,6 @@ async function EditCragPage({ params: { cragSlug } }: TEditCragPageProps) {

const crag = cragData.cragBySlug;

const tabMenuItems: TTabMenuItem[] = [
{
label: "Osnovni podatki",
link: `/edit/${cragSlug}`,
isActive: true,
icon: <IconInfo />,
},
{
label: "Sektorji in smeri",
link: `/edit/${cragSlug}/sectors`,
isActive: false,
icon: <IconRoutes />,
},
];

return (
<>
<ContentHeader
Expand All @@ -54,13 +40,35 @@ async function EditCragPage({ params: { cragSlug } }: TEditCragPageProps) {
crumbs={[
{ label: "Plezanje.net", link: "/" },
{ label: "Urejanje", link: null },
{ label: "Plezališča", link: null },
{ label: crag.name, link: null },
]}
/>
}
tabMenu={<TabMenu items={tabMenuItems} />}
tabMenu={
<TabMenu
items={[
{
label: "Osnovni podatki",
link: `/urejanje/plezalisca/${cragSlug}/uredi`,
isActive: true,
icon: <IconInfo />,
},
{
label: "Sektorji in smeri",
link: `/urejanje/plezalisca/${cragSlug}/sektorji`,
isActive: false,
icon: <IconRoutes />,
},
]}
/>
}
/>

{crag.publishStatus !== "published" && (
<CragPublishStatusCard crag={crag} />
)}

<EditCragForm countriesWithAreas={countriesData.countries} crag={crag} />
</>
);
Expand Down Expand Up @@ -116,6 +124,19 @@ gql`
maxIntrinsicWidth
aspectRatio
}
publishStatus
user {
id
fullName
}
sectors {
id
label
name
routes {
id
}
}
}
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import Dialog from "@/components/ui/dialog";
import { Dispatch, SetStateAction, useState } from "react";
import { useRouter } from "next/navigation";
import { Route } from "@/graphql/generated";
import deleteRoutesAction from "../lib/delete-routes-action";

type TDeleteRoutesDialogProps = {
isOpen: boolean;
setIsOpen: Dispatch<SetStateAction<boolean>>;
routes: Route[];
};

function DeleteRoutesDialog({
isOpen,
setIsOpen,
routes,
}: TDeleteRoutesDialogProps) {
const router = useRouter();

const [loading, setLoading] = useState(false);

const handleConfirm = async () => {
setLoading(true);
await deleteRoutesAction(routes.map((route) => route.id));
setIsOpen(false);
setLoading(false);
router.refresh();
};

return (
<Dialog
title="Brisanje smeri"
isOpen={isOpen}
setIsOpen={setIsOpen}
cancel={{ label: "Prekliči", disabled: loading }}
confirm={{
label: "Izbriši",
callback: handleConfirm,
dontCloseOnConfirm: true,
loading: loading,
disabled: loading,
}}
>
<>
<div>
Ali res želiš izbrisati{" "}
{routes.length == 1 ? (
<span>
smer <span className="font-medium">{routes[0].name}</span>
</span>
) : (
<span>vse označene smeri</span>
)}
?
</div>
</>
</Dialog>
);
}

export default DeleteRoutesDialog;
Loading