Skip to content

Commit

Permalink
fix: org creation bug and hidden organization config in insiders
Browse files Browse the repository at this point in the history
  • Loading branch information
danh91 committed Feb 1, 2025
1 parent 9a3f9ad commit 0810c66
Show file tree
Hide file tree
Showing 17 changed files with 268 additions and 201 deletions.
2 changes: 1 addition & 1 deletion ee/insiders
2 changes: 1 addition & 1 deletion ee/platform
12 changes: 7 additions & 5 deletions packages/core/modules/Settings/account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { WorkspaceConfigForm } from "@karrio/ui/forms/workspace-config-form";
import { CloseAccountAction } from "@karrio/ui/forms/close-account-action";
import { dynamicMetadata } from "@karrio/core/components/metadata";
import { ConfirmModal } from "@karrio/ui/modals/confirm-modal";
import { useAPIMetadata } from "@karrio/hooks/api-metadata";
import { AppLink } from "@karrio/ui/components/app-link";

export const generateMetadata = dynamicMetadata("Account Settings");

export default function AccountPage(pageProps: any) {
const { APP_NAME, MULTI_ORGANIZATIONS } = (pageProps as any).metadata || {};

const Component= (): JSX.Element => {
const Component = (): JSX.Element => {
const { metadata } = useAPIMetadata();
return (
<>
<header className="px-0 pb-0 pt-4 is-flex is-justify-content-space-between">
Expand Down Expand Up @@ -38,10 +38,11 @@ export default function AccountPage(pageProps: any) {
<span>Profile</span>
</AppLink>
</li>
{MULTI_ORGANIZATIONS && (
{metadata?.MULTI_ORGANIZATIONS && (
<li className={`is-capitalized has-text-weight-semibold`}>
<AppLink
href="/settings/organization"

shallow={false}
prefetch={false}
>
Expand Down Expand Up @@ -91,10 +92,11 @@ export default function AccountPage(pageProps: any) {
<p className="subtitle is-6 py-1">Close Account</p>
<p className="is-size-7">
<strong>Warning:</strong> You will lose access to your{" "}
{APP_NAME} services
{metadata?.APP_NAME} services
</p>
</div>


<div className="column is-5">
<CloseAccountAction>
<span>Close this account...</span>
Expand Down
6 changes: 3 additions & 3 deletions packages/core/modules/Settings/addresses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import { GoogleGeocodingScript } from "@karrio/ui/components/google-geocoding-script";
import { ConfirmModal, useConfirmModal } from "@karrio/ui/modals/confirm-modal";
import { dynamicMetadata } from "@karrio/core/components/metadata";
import { useAPIMetadata } from "@karrio/hooks/api-metadata";
import { AppLink } from "@karrio/ui/components/app-link";
import { useLoader } from "@karrio/ui/components/loader";
import { useSearchParams } from "next/navigation";
Expand All @@ -25,9 +26,8 @@ import React, { useEffect } from "react";
export const generateMetadata = dynamicMetadata("Addresses");

export default function AddressPage(pageProps: any) {
const { MULTI_ORGANIZATIONS } = (pageProps as any).metadata || {};

const Component = (): JSX.Element => {
const { metadata } = useAPIMetadata();
const searchParams = useSearchParams();
const modal = searchParams.get("modal") as string;
const { setLoading } = useLoader();
Expand Down Expand Up @@ -109,7 +109,7 @@ export default function AddressPage(pageProps: any) {
<span>Profile</span>
</AppLink>
</li>
{MULTI_ORGANIZATIONS && (
{metadata?.MULTI_ORGANIZATIONS && (
<li className={`is-capitalized has-text-weight-semibold`}>
<AppLink
href="/settings/organization"
Expand Down
11 changes: 6 additions & 5 deletions packages/core/modules/Settings/organization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { OrganizationManagement } from "@karrio/ui/forms/organization-management
import { InviteMemberProvider } from "@karrio/ui/modals/invite-member-modal";
import { dynamicMetadata } from "@karrio/core/components/metadata";
import { ConfirmModal } from "@karrio/ui/modals/confirm-modal";
import { useAPIMetadata } from "@karrio/hooks/api-metadata";
import { AppLink } from "@karrio/ui/components/app-link";

export const generateMetadata = dynamicMetadata("Organization Settings");

export default function AccountPage(pageProps: any) {
const { MULTI_ORGANIZATIONS } = (pageProps as any).metadata || {};

const Component= (): JSX.Element => {
const Component = (): JSX.Element => {
const { metadata } = useAPIMetadata();
return (
<>
<header className="px-0 pb-0 pt-4 is-flex is-justify-content-space-between">
Expand Down Expand Up @@ -38,10 +38,11 @@ export default function AccountPage(pageProps: any) {
<span>Profile</span>
</AppLink>
</li>
{MULTI_ORGANIZATIONS && (
{metadata?.MULTI_ORGANIZATIONS && (
<li
className={`is-capitalized has-text-weight-semibold is-active`}
>

<AppLink
href="/settings/organization"
shallow={false}
Expand Down Expand Up @@ -81,7 +82,7 @@ export default function AccountPage(pageProps: any) {
</ul>
</div>

{MULTI_ORGANIZATIONS && (
{metadata?.MULTI_ORGANIZATIONS && (
<div>
<InviteMemberProvider>
<OrganizationManagement />
Expand Down
10 changes: 5 additions & 5 deletions packages/core/modules/Settings/parcels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@ import { ConfirmModal, useConfirmModal } from "@karrio/ui/modals/confirm-modal";
import { ParcelDescription } from "@karrio/ui/components/parcel-description";
import { dynamicMetadata } from "@karrio/core/components/metadata";
import { getURLSearchParams, isNoneOrEmpty } from "@karrio/lib";
import { AppLink } from "@karrio/ui/components/app-link";
import { useAPIMetadata } from "@karrio/hooks/api-metadata";
import { useLoader } from "@karrio/ui/components/loader";
import { AppLink } from "@karrio/ui/components/app-link";
import React, { useEffect, useState } from "react";
import { useSearchParams } from "next/navigation";

export const generateMetadata = dynamicMetadata("Parcels");

export default function ParcelsPage(pageProps: any) {
const { MULTI_ORGANIZATIONS } = (pageProps as any).metadata || {};

const Component = (): JSX.Element => {
const { metadata } = useAPIMetadata();
const searchParams = useSearchParams();
const modal = searchParams.get("modal") as string;
const { setLoading } = useLoader();
Expand Down Expand Up @@ -103,10 +102,11 @@ export default function ParcelsPage(pageProps: any) {
<span>Profile</span>
</AppLink>
</li>
{MULTI_ORGANIZATIONS && (
{metadata?.MULTI_ORGANIZATIONS && (
<li className={`is-capitalized has-text-weight-semibold`}>
<AppLink
href="/settings/organization"

shallow={false}
prefetch={false}
>
Expand Down
11 changes: 6 additions & 5 deletions packages/core/modules/Settings/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { EmailManagement } from "@karrio/ui/forms/email-management";
import { dynamicMetadata } from "@karrio/core/components/metadata";
import { ConfirmModal } from "@karrio/ui/modals/confirm-modal";
import { AppLink } from "@karrio/ui/components/app-link";
import { useAPIMetadata } from "@karrio/hooks/api-metadata";

export const generateMetadata = dynamicMetadata("Profile Settings");

export default function AccountPage(pageProps: any) {
const { APP_NAME, MULTI_ORGANIZATIONS } = (pageProps as any).metadata || {};

const Component= (): JSX.Element => {
const Component = (): JSX.Element => {
const { metadata } = useAPIMetadata();
return (
<>
<header className="px-0 pb-0 pt-4 is-flex is-justify-content-space-between">
Expand Down Expand Up @@ -39,10 +39,11 @@ export default function AccountPage(pageProps: any) {
<span>Profile</span>
</AppLink>
</li>
{MULTI_ORGANIZATIONS && (
{metadata?.MULTI_ORGANIZATIONS && (
<li className={`is-capitalized has-text-weight-semibold`}>
<AppLink
href="/settings/organization"

shallow={false}
prefetch={false}
>
Expand Down Expand Up @@ -85,7 +86,7 @@ export default function AccountPage(pageProps: any) {
<div className="column is-5 pr-2">
<p className="subtitle is-6 py-1">Profile</p>
<p className="is-size-7 pr-2">
Your email address is your identity on {APP_NAME} and is used to
Your email address is your identity on {metadata?.APP_NAME} and is used to
log in.
</p>
</div>
Expand Down
34 changes: 17 additions & 17 deletions packages/core/modules/Settings/templates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import { DocumentTemplateType, NotificationType } from "@karrio/types";
import { dynamicMetadata } from "@karrio/core/components/metadata";
import { useConfirmModal } from "@karrio/ui/modals/confirm-modal";
import { useNotifier } from "@karrio/ui/components/notifier";
import { useAPIMetadata } from "@karrio/hooks/api-metadata";
import { AppLink } from "@karrio/ui/components/app-link";
import React from "react";

export const generateMetadata = dynamicMetadata("Document Templates");

export default function TemplatesPage(pageProps: any) {
const { MULTI_ORGANIZATIONS } = (pageProps as any).metadata || {};

const Component = (): JSX.Element => {
const { notify } = useNotifier();
const { metadata } = useAPIMetadata();
const mutation = useDocumentTemplateMutation();
const { confirm: confirmDeletion } = useConfirmModal();
const {
Expand All @@ -35,20 +35,20 @@ export default function TemplatesPage(pageProps: any) {
};
const toggle =
({ active, id }: DocumentTemplateType) =>
async () => {
try {
await mutation.updateDocumentTemplate.mutateAsync({
id,
active: !active,
});
notify({
type: NotificationType.success,
message: `template ${!active ? "enabled" : "disabled"}!`,
});
} catch (message: any) {
notify({ type: NotificationType.error, message });
}
};
async () => {
try {
await mutation.updateDocumentTemplate.mutateAsync({
id,
active: !active,
});
notify({
type: NotificationType.success,
message: `template ${!active ? "enabled" : "disabled"}!`,
});
} catch (message: any) {
notify({ type: NotificationType.error, message });
}
};

return (
<>
Expand Down Expand Up @@ -84,7 +84,7 @@ export default function TemplatesPage(pageProps: any) {
<span>Profile</span>
</AppLink>
</li>
{MULTI_ORGANIZATIONS && (
{metadata?.MULTI_ORGANIZATIONS && (
<li className={`is-capitalized has-text-weight-semibold`}>
<AppLink
href="/settings/organization"
Expand Down
6 changes: 3 additions & 3 deletions packages/hooks/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import {
} from "@tanstack/react-query";

const AuthenticatedContexts = bundleContexts([
CreateOrganizationModalProvider,
AcceptInvitationProvider,
ClientProvider,
OrganizationProvider,
APIMetadataProvider,
AppModeProvider,
LoadingProvider,
Notifier,
OrganizationProvider,
AcceptInvitationProvider,
CreateOrganizationModalProvider,
]);

function makeQueryClient() {
Expand Down
1 change: 1 addition & 0 deletions packages/types/graphql/ee/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2095,6 +2095,7 @@ export interface SendOrganizationInvitesMutationInput {
org_id: string;
emails: string[];
redirect_url: string;
roles?: UserRole[] | null;
}

// null
Expand Down
6 changes: 6 additions & 0 deletions packages/types/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4723,6 +4723,7 @@ export enum IncotermCodeEnum {
CIP = "CIP",
CPT = "CPT",
DAF = "DAF",
DAP = "DAP",
DDP = "DDP",
DDU = "DDU",
DEQ = "DEQ",
Expand Down Expand Up @@ -4973,6 +4974,7 @@ export enum LabelTypeEnum {
}

export enum TrackerStatusEnum {
cancelled = "cancelled",
delivered = "delivered",
delivery_delayed = "delivery_delayed",
delivery_failed = "delivery_failed",
Expand All @@ -4981,6 +4983,7 @@ export enum TrackerStatusEnum {
out_for_delivery = "out_for_delivery",
pending = "pending",
ready_for_pickup = "ready_for_pickup",
return_to_sender = "return_to_sender",
unknown = "unknown",
}

Expand Down Expand Up @@ -5535,6 +5538,7 @@ export interface CreateRateSheetMutationInput {
carrier_name: CarrierNameEnum;
services?: CreateServiceLevelInput[] | null;
carriers?: string[] | null;
metadata?: any | null;
}

// null
Expand Down Expand Up @@ -5582,6 +5586,8 @@ export interface UpdateRateSheetMutationInput {
name?: string | null;
services?: UpdateServiceLevelInput[] | null;
carriers?: string[] | null;
remove_missing_services?: boolean | null;
metadata?: any | null;
}

// null
Expand Down
4 changes: 2 additions & 2 deletions packages/types/rest/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
/* eslint-disable */
/**
* Karrio API
* Karrio is a multi-carrier shipping API that simplifies the integration of logistics carrier services. The Karrio API is organized around REST. Our API has predictable resource-oriented URLs, accepts JSON-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs. The Karrio API differs for every account as we release new versions. These docs are customized to your version of the API. ## Versioning When backwards-incompatible changes are made to the API, a new, dated version is released. The current version is `2024.12.2`. Read our API changelog to learn more about backwards compatibility. As a precaution, use API versioning to check a new API version before committing to an upgrade. ## Environments The Karrio API offer the possibility to create and retrieve certain objects in `test_mode`. In development, it is therefore possible to add carrier connections, get live rates, buy labels, create trackers and schedule pickups in `test_mode`. ## Pagination All top-level API resources have support for bulk fetches via \"list\" API methods. For instance, you can list addresses, list shipments, and list trackers. These list API methods share a common structure, taking at least these two parameters: limit, and offset. Karrio utilizes offset-based pagination via the offset and limit parameters. Both parameters take a number as value (see below) and return objects in reverse chronological order. The offset parameter returns objects listed after an index. The limit parameter take a limit on the number of objects to be returned from 1 to 100. ```json { \"count\": 100, \"next\": \"/v1/shipments?limit=25&offset=50\", \"previous\": \"/v1/shipments?limit=25&offset=25\", \"results\": [ { ... }, ] } ``` ## Metadata Updateable Karrio objects—including Shipment and Order have a metadata parameter. You can use this parameter to attach key-value data to these Karrio objects. Metadata is useful for storing additional, structured information on an object. As an example, you could store your user\'s full name and corresponding unique identifier from your system on a Karrio Order object. Do not store any sensitive information as metadata. ## Authentication API keys are used to authenticate requests. You can view and manage your API keys in the Dashboard. Your API keys carry many privileges, so be sure to keep them secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth. Authentication to the API is performed via HTTP Basic Auth. Provide your API token as the basic auth username value. You do not need to provide a password. ```shell $ curl https://instance.api.com/v1/shipments \\ -u key_xxxxxx: # The colon prevents curl from asking for a password. ``` If you need to authenticate via bearer auth (e.g., for a cross-origin request), use `-H \"Authorization: Token key_xxxxxx\"` instead of `-u key_xxxxxx`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). API requests without authentication will also fail.
* Karrio is a multi-carrier shipping API that simplifies the integration of logistics carrier services. The Karrio API is organized around REST. Our API has predictable resource-oriented URLs, accepts JSON-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs. The Karrio API differs for every account as we release new versions. These docs are customized to your version of the API. ## Versioning When backwards-incompatible changes are made to the API, a new, dated version is released. The current version is `2024.12.3`. Read our API changelog to learn more about backwards compatibility. As a precaution, use API versioning to check a new API version before committing to an upgrade. ## Environments The Karrio API offer the possibility to create and retrieve certain objects in `test_mode`. In development, it is therefore possible to add carrier connections, get live rates, buy labels, create trackers and schedule pickups in `test_mode`. ## Pagination All top-level API resources have support for bulk fetches via \"list\" API methods. For instance, you can list addresses, list shipments, and list trackers. These list API methods share a common structure, taking at least these two parameters: limit, and offset. Karrio utilizes offset-based pagination via the offset and limit parameters. Both parameters take a number as value (see below) and return objects in reverse chronological order. The offset parameter returns objects listed after an index. The limit parameter take a limit on the number of objects to be returned from 1 to 100. ```json { \"count\": 100, \"next\": \"/v1/shipments?limit=25&offset=50\", \"previous\": \"/v1/shipments?limit=25&offset=25\", \"results\": [ { ... }, ] } ``` ## Metadata Updateable Karrio objects—including Shipment and Order have a metadata parameter. You can use this parameter to attach key-value data to these Karrio objects. Metadata is useful for storing additional, structured information on an object. As an example, you could store your user\'s full name and corresponding unique identifier from your system on a Karrio Order object. Do not store any sensitive information as metadata. ## Authentication API keys are used to authenticate requests. You can view and manage your API keys in the Dashboard. Your API keys carry many privileges, so be sure to keep them secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth. Authentication to the API is performed via HTTP Basic Auth. Provide your API token as the basic auth username value. You do not need to provide a password. ```shell $ curl https://instance.api.com/v1/shipments \\ -u key_xxxxxx: # The colon prevents curl from asking for a password. ``` If you need to authenticate via bearer auth (e.g., for a cross-origin request), use `-H \"Authorization: Token key_xxxxxx\"` instead of `-u key_xxxxxx`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). API requests without authentication will also fail.
*
* The version of the OpenAPI document: 2024.12.2
* The version of the OpenAPI document: 2024.12.3
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/components/organization-dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Loading } from "./loader";
import { p } from "@karrio/lib";
import Image from "next/image";

export const OrganizationDropdown= (): JSX.Element => {
export const OrganizationDropdown = (): JSX.Element => {
const trigger = useRef<HTMLButtonElement>(null);
const searchParams = useSearchParams();
const { query } = useAPIToken();
Expand Down
Loading

0 comments on commit 0810c66

Please sign in to comment.