Skip to content

Commit

Permalink
Fix styling issues and removed unused components
Browse files Browse the repository at this point in the history
  • Loading branch information
prateek3255 committed Apr 12, 2024
1 parent a103a7e commit 47645b1
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 866 deletions.
200 changes: 0 additions & 200 deletions src/api/tenants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,6 @@ export const useTenantCreateService = () => {
}
| undefined
> => {
// TODO: Temporary mock data
// await new Promise((resolve) => setTimeout(resolve, 1000));

// const status = localStorage.getItem("create-tenant-status");
// if (status === "MULTITENANCY_NOT_ENABLED_IN_CORE_ERROR") {
// return {
// status: "MULTITENANCY_NOT_ENABLED_IN_CORE_ERROR",
// };
// }

// if (status === "INVALID_TENANT_ID_ERROR") {
// return {
// status: "INVALID_TENANT_ID_ERROR",
// message: "tenant id is invalid",
// };
// }

// return {
// status: "OK",
// createdNew: true,
// };

const response = await fetchData({
url: getApiUrl("/api/tenant"),
method: "PUT",
Expand Down Expand Up @@ -92,79 +70,6 @@ export const useTenantGetService = () => {
}
| undefined
> => {
// TODO: Temporary mock data
// await new Promise((resolve) => setTimeout(resolve, 10));

// const status = localStorage.getItem("get-tenant-status");
// if (status === "UNKNOWN_TENANT_ERROR") {
// return {
// status: "UNKNOWN_TENANT_ERROR",
// };
// }

// return {
// status: "OK",
// tenant: {
// tenantId,
// thirdParty: {
// providers: ["apple", "google"],
// },
// firstFactors: ["thirdparty"],
// requiredSecondaryFactors: [],
// userCount: 12,
// coreConfig: [
// {
// key: "password_reset_token_lifetime",
// valueType: "number",
// value: 3600000,
// description: "The time in milliseconds for which the password reset token is valid.",
// isSaaSProtected: false,
// isDifferentAcrossTenants: true,
// isModifyableOnlyViaConfigYaml: false,
// defaultValue: 3600000,
// isNullable: false,
// isPluginProperty: false,
// },
// {
// key: "access_token_blacklisting",
// valueType: "boolean",
// value: false,
// description: "Whether to blacklist access tokens or not.",
// isSaaSProtected: false,
// isDifferentAcrossTenants: true,
// isModifyableOnlyViaConfigYaml: false,
// defaultValue: false,
// isNullable: false,
// isPluginProperty: false,
// },
// {
// key: "ip_allow_regex",
// valueType: "string",
// value: null,
// description: "The regex to match the IP address of the user.",
// isSaaSProtected: false,
// isDifferentAcrossTenants: true,
// isModifyableOnlyViaConfigYaml: false,
// defaultValue: null,
// isNullable: true,
// isPluginProperty: false,
// },
// {
// key: "postgresql_emailpassword_users_table_name",
// valueType: "string",
// value: null,
// description: "The name of the table where the emailpassword users are stored.",
// isSaaSProtected: false,
// isDifferentAcrossTenants: true,
// isModifyableOnlyViaConfigYaml: false,
// defaultValue: 3600000,
// isNullable: true,
// isPluginProperty: true,
// },
// ],
// },
// };

const response = await fetchData({
url: getApiUrl("/api/tenant", tenantId),
method: "GET",
Expand All @@ -190,13 +95,6 @@ export const useTenantDeleteService = () => {
method: "DELETE",
});

// TODO: Temporary mock data
// await new Promise((resolve) => setTimeout(resolve, 1000));

// return {
// status: "OK",
// };

if (response.ok) {
return await response.json();
}
Expand All @@ -219,27 +117,6 @@ export const useUpdateFirstFactorsService = () => {
| { status: "RECIPE_NOT_CONFIGURED_ON_BACKEND_SDK_ERROR"; message: string }
| { status: "UNKNOWN_TENANT_ERROR" }
> => {
// TODO: Temporary mock data
// await new Promise((resolve) => setTimeout(resolve, 1000));

// const status = localStorage.getItem("update-first-factors-status");
// if (status === "RECIPE_NOT_CONFIGURED_ON_BACKEND_SDK_ERROR") {
// return {
// status: "RECIPE_NOT_CONFIGURED_ON_BACKEND_SDK_ERROR",
// message: "Recipe not configured",
// };
// }

// if (status === "UNKNOWN_TENANT_ERROR") {
// return {
// status: "UNKNOWN_TENANT_ERROR",
// };
// }

// return {
// status: "OK",
// };

const response = await fetchData({
url: getApiUrl("/api/tenant/first-factor", tenantId),
method: "PUT",
Expand Down Expand Up @@ -274,37 +151,6 @@ export const useUpdateSecondaryFactorsService = () => {
| { status: "MFA_NOT_INITIALIZED_ERROR" }
| { status: "UNKNOWN_TENANT_ERROR" }
> => {
// TODO: Temporary mock data
// await new Promise((resolve) => setTimeout(resolve, 1000));

// const status = localStorage.getItem("update-secondary-factors-status");
// if (status === "RECIPE_NOT_CONFIGURED_ON_BACKEND_SDK_ERROR") {
// return {
// status: "RECIPE_NOT_CONFIGURED_ON_BACKEND_SDK_ERROR",
// message: "Recipe not configured",
// };
// }

// if (status === "MFA_NOT_INITIALIZED_ERROR") {
// return {
// status: "MFA_NOT_INITIALIZED_ERROR",
// };
// }

// if (status === "UNKNOWN_TENANT_ERROR") {
// return {
// status: "UNKNOWN_TENANT_ERROR",
// };
// }

// const isMFARequirementsForAuthOverridden =
// localStorage.getItem("isMFARequirementsForAuthOverridden") === "true";

// return {
// status: "OK",
// isMFARequirementsForAuthOverridden: isMFARequirementsForAuthOverridden,
// };

const response = await fetchData({
url: getApiUrl("/api/tenant/secondary-factor", tenantId),
method: "PUT",
Expand Down Expand Up @@ -336,14 +182,6 @@ export const useUpdateCoreConfigService = () => {
): Promise<
{ status: "OK" } | { status: "UNKNOWN_TENANT_ERROR" } | { status: "INVALID_CONFIG_ERROR"; message: string }
> => {
// TODO: Temporary mock data
// await new Promise((resolve) => setTimeout(resolve, 1000));

// return {
// status: "INVALID_CONFIG_ERROR",
// message: "Invalid config",
// };

const response = await fetchData({
url: getApiUrl("/api/tenant/core-config", tenantId),
method: "PUT",
Expand Down Expand Up @@ -381,30 +219,6 @@ export const useGetThirdPartyProviderInfo = () => {
status: "UNKNOWN_TENANT_ERROR";
}
> => {
// TODO: Temporary mock data
// await new Promise((resolve) => setTimeout(resolve, 1000));

// return {
// status: "OK",
// providerConfig: {
// oidcDiscoveryEndpoint: "https://oidc.discovery.endpoint",
// thirdPartyId: providerId,
// name: "Provider Name",
// clients: [
// {
// clientId: "",
// clientSecret: "",
// scope: [""],
// forcePKCE: false,
// additionalConfig,
// },
// ],
// isGetAuthorisationRedirectUrlOverridden: false,
// isExchangeAuthCodeForOAuthTokensOverridden: false,
// isGetUserInfoOverridden: false,
// },
// };

const additionalConfigQueryParams = new URLSearchParams(additionalConfig).toString();

const response = await fetchData({
Expand Down Expand Up @@ -434,13 +248,6 @@ export const useCreateOrUpdateThirdPartyProvider = () => {
tenantId: string,
providerConfig: ProviderConfig
): Promise<{ status: "OK" } | { status: "UNKNOWN_TENANT_ERROR" }> => {
// TODO: Temporary mock data
// await new Promise((resolve) => setTimeout(resolve, 1000));

// return {
// status: "OK",
// };

const response = await fetchData({
url: getApiUrl("/api/thirdparty/config", tenantId),
method: "PUT",
Expand Down Expand Up @@ -469,13 +276,6 @@ export const useDeleteThirdPartyProvider = () => {
tenantId: string,
providerId: string
): Promise<{ status: "OK" } | { status: "UNKNOWN_TENANT_ERROR" }> => {
// TODO: Temporary mock data
// await new Promise((resolve) => setTimeout(resolve, 1000));

// return {
// status: "OK",
// };

const response = await fetchData({
url: getApiUrl(`/api/thirdparty/config?thirdPartyId=${providerId}`, tenantId),
method: "DELETE",
Expand Down
8 changes: 0 additions & 8 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,37 +112,31 @@ export const FIRST_FACTOR_IDS = [
label: "Email Password",
description: "Sign in/up using email and password (Requires the EmailPassword recipe to be initialized)",
id: "emailpassword",
loginMethod: "emailpassword",
},
{
label: "OTP - Email",
description: "Sign in/up using OTP sent to email (Requires the Passwordless recipe to be initialized)",
id: "otp-email",
loginMethod: "passwordless",
},
{
label: "OTP - Phone",
description: "Sign in/up using OTP sent to phone (Requires the Passwordless recipe to be initialized)",
id: "otp-phone",
loginMethod: "passwordless",
},
{
label: "Link - Email",
description: "Sign in/up using link sent to email (Requires the Passwordless recipe to be initialized)",
id: "link-email",
loginMethod: "passwordless",
},
{
label: "Link - Phone",
description: "Sign in/up using link sent to phone (Requires the Passwordless recipe to be initialized)",
id: "link-phone",
loginMethod: "passwordless",
},
{
label: "Third Party",
description: "Sign in/up using third party providers (Requires the ThirdParty recipe to be initialized)",
id: "thirdparty",
loginMethod: "thirdparty",
},
];

Expand All @@ -158,14 +152,12 @@ export const SECONDARY_FACTOR_IDS = [
description:
"Require OTP sent to email as a secondary factor for successful authentication (Requires the Passwordless recipe to be initialized)",
id: "otp-email",
loginMethod: "passwordless",
},
{
label: "OTP - Phone",
description:
"Require OTP sent to phone as a secondary factor for successful authentication (Requires the Passwordless recipe to be initialized)",
id: "otp-phone",
loginMethod: "passwordless",
},
];
export const FactorIds = {
Expand Down
6 changes: 3 additions & 3 deletions src/ui/components/tenants/tenantDetail/CoreConfigSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { ReactComponent as PencilIcon } from "../../../../assets/edit.svg";
import { ReactComponent as InfoIcon } from "../../../../assets/info-icon.svg";
import { ReactComponent as QuestionMarkIcon } from "../../../../assets/question-mark.svg";
import { PUBLIC_TENANT_ID } from "../../../../constants";
import { getImageUrl } from "../../../../utils";
import { getConnectionUri, getImageUrl } from "../../../../utils";
import { PopupContentContext } from "../../../contexts/PopupContentContext";
import Button from "../../button";
import { Checkbox } from "../../checkbox/Checkbox";
Expand Down Expand Up @@ -148,7 +148,7 @@ type CoreConfigTableRowProps = {
};

const isUsingSaaS = localStorage.getItem("isUsingSaaS") === "true";
const isUsingNonPublicApp = localStorage.getItem("isUsingNonPublicApp") === "true";
const isUsingNonPublicApp = /appid-.*$/.test(getConnectionUri());

const CoreConfigTableRow = ({
name,
Expand Down Expand Up @@ -278,7 +278,7 @@ const CoreConfigTableRow = ({

if ((isPublicTenant && !isUsingNonPublicApp) || isModifyableOnlyViaConfigYaml) {
return isUsingSaaS
? "You can modify this property via the SaaS dashboard."
? "To modify this property, please visit the dashboard on supertokens.com and click on the edit configuration button."
: "This property is modifyable only via the config.yaml file or via Docker env variables.";
}

Expand Down
Loading

0 comments on commit 47645b1

Please sign in to comment.