update .gitignore, add example environment file, and modify consent handling in components
This commit is contained in:
1
.env.example
Normal file
1
.env.example
Normal file
@ -0,0 +1 @@
|
|||||||
|
NEXT_PUBLIC_API_URL=http://your.api/api
|
||||||
Binary file not shown.
@ -27,17 +27,7 @@ const ConsentButton: FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const requestConsent = () => {
|
const requestConsent = () => {
|
||||||
// if (!auth.loginChallenge || auth.scope.length === 0) return;
|
|
||||||
// new AuthService()
|
|
||||||
// .requestConsent(auth.loginChallenge)
|
|
||||||
// .then(response => response.data)
|
|
||||||
// .then(({ clientName }) => {
|
|
||||||
// setClientName(clientName);
|
|
||||||
// })
|
|
||||||
// .catch(error => {
|
|
||||||
// console.error(error);
|
|
||||||
// notifications.error({ message: error.toString() });
|
|
||||||
// });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -46,13 +36,21 @@ const ConsentButton: FC = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const confirmAccess = () => {
|
const confirmAccess = () => {
|
||||||
|
const phoneNumber = auth.phoneNumber;
|
||||||
|
if (!phoneNumber) {
|
||||||
|
console.error("Phone number is not set");
|
||||||
|
return;
|
||||||
|
}
|
||||||
const consentChallenge = searchParams.get("consent_challenge");
|
const consentChallenge = searchParams.get("consent_challenge");
|
||||||
if (!consentChallenge) {
|
if (!consentChallenge) {
|
||||||
console.error("Consent challenge is missing in the URL");
|
console.error("Consent challenge is missing in the URL");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Auth.postAuthConsentAccept({
|
Auth.postAuthConsentAccept({
|
||||||
body: { consent_challenge: consentChallenge },
|
body: {
|
||||||
|
consent_challenge: consentChallenge,
|
||||||
|
phone_number: phoneNumber,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
.then(response => response.data)
|
.then(response => response.data)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
@ -69,17 +67,7 @@ const ConsentButton: FC = () => {
|
|||||||
console.error("Redirect URL is missing in the response");
|
console.error("Redirect URL is missing in the response");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// if (!auth.loginChallenge) return;
|
|
||||||
// new AuthService()
|
|
||||||
// .approveConsent(auth.loginChallenge)
|
|
||||||
// .then(response => response.data)
|
|
||||||
// .then(({ redirectUrl }) => {
|
|
||||||
// window.location.href = redirectUrl;
|
|
||||||
// })
|
|
||||||
// .catch(error => {
|
|
||||||
// console.error(error);
|
|
||||||
// notifications.error({ message: error.toString() });
|
|
||||||
// });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -9,8 +9,12 @@ import SCOPES from "@/constants/scopes";
|
|||||||
import { Scopes } from "@/enums/Scopes";
|
import { Scopes } from "@/enums/Scopes";
|
||||||
import { setTargetService } from "@/lib/store/features/targetService/targetServiceSlice";
|
import { setTargetService } from "@/lib/store/features/targetService/targetServiceSlice";
|
||||||
import { useAppDispatch } from "@/lib/store/store";
|
import { useAppDispatch } from "@/lib/store/store";
|
||||||
import ServiceData from "@/types/ServiceData";
|
|
||||||
|
|
||||||
|
type ServiceData = {
|
||||||
|
id: number;
|
||||||
|
code: Scopes;
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
const ServicesList = () => {
|
const ServicesList = () => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const services = useMemo(
|
const services = useMemo(
|
||||||
@ -56,7 +60,9 @@ const ServicesList = () => {
|
|||||||
<Stack
|
<Stack
|
||||||
className={styles.container}
|
className={styles.container}
|
||||||
gap={"lg"}>
|
gap={"lg"}>
|
||||||
{services.map((service, i) => getServiceButton(service, i))}
|
{services.map((service, i) =>
|
||||||
|
getServiceButton(service as unknown as ServiceData, i)
|
||||||
|
)}
|
||||||
<TitleWithLines title="Скоро будет" />
|
<TitleWithLines title="Скоро будет" />
|
||||||
{getServiceInDevelopment("Analytics")}
|
{getServiceInDevelopment("Analytics")}
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@ -27,13 +27,13 @@ const VerifyPhoneForm: FC = () => {
|
|||||||
const authState = useSelector((state: RootState) => state.auth);
|
const authState = useSelector((state: RootState) => state.auth);
|
||||||
|
|
||||||
const handleSubmit = (values: VerifyNumberForm) => {
|
const handleSubmit = (values: VerifyNumberForm) => {
|
||||||
|
|
||||||
if (!authState.phoneNumber || !authState.loginChallenge) return;
|
if (!authState.phoneNumber || !authState.loginChallenge) return;
|
||||||
console.log(authState.phoneNumber.replace(/ /g, ""));
|
console.log(authState.phoneNumber.replace(/ /g, ""));
|
||||||
|
|
||||||
Auth.postAuthOtpVerify({
|
Auth.postAuthOtpVerify({
|
||||||
body: {
|
body: {
|
||||||
phone_number: authState.phoneNumber.replace(" ", ""),
|
phone_number: authState.phoneNumber,
|
||||||
login_challenge: authState.loginChallenge,
|
login_challenge: authState.loginChallenge,
|
||||||
otp: values.code,
|
otp: values.code,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -42,6 +42,10 @@ export type VerifyOtpResponse = {
|
|||||||
* Status of the verification
|
* Status of the verification
|
||||||
*/
|
*/
|
||||||
ok: boolean;
|
ok: boolean;
|
||||||
|
/**
|
||||||
|
* Confirmation message
|
||||||
|
*/
|
||||||
|
message: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type AcceptConsentRequest = {
|
export type AcceptConsentRequest = {
|
||||||
@ -49,6 +53,10 @@ export type AcceptConsentRequest = {
|
|||||||
* The consent challenge to accept
|
* The consent challenge to accept
|
||||||
*/
|
*/
|
||||||
consent_challenge: string;
|
consent_challenge: string;
|
||||||
|
/**
|
||||||
|
* Phone number associated with the consent
|
||||||
|
*/
|
||||||
|
phone_number: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type AcceptConsentResponse = {
|
export type AcceptConsentResponse = {
|
||||||
|
|||||||
@ -19,11 +19,13 @@ export const zVerifyOtpRequest = z.object({
|
|||||||
|
|
||||||
export const zVerifyOtpResponse = z.object({
|
export const zVerifyOtpResponse = z.object({
|
||||||
redirect_url: z.string(),
|
redirect_url: z.string(),
|
||||||
ok: z.boolean()
|
ok: z.boolean(),
|
||||||
|
message: z.string()
|
||||||
});
|
});
|
||||||
|
|
||||||
export const zAcceptConsentRequest = z.object({
|
export const zAcceptConsentRequest = z.object({
|
||||||
consent_challenge: z.string()
|
consent_challenge: z.string(),
|
||||||
|
phone_number: z.string().max(15)
|
||||||
});
|
});
|
||||||
|
|
||||||
export const zAcceptConsentResponse = z.object({
|
export const zAcceptConsentResponse = z.object({
|
||||||
|
|||||||
@ -62,19 +62,6 @@ const LoginForm: FC<Props> = ({ loginChallenge, isCreatingId = false }) => {
|
|||||||
router.push("/verify-phone");
|
router.push("/verify-phone");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// new AuthService().requestLogin(values.phoneNumber)
|
|
||||||
// .then(response => response.data)
|
|
||||||
// .then(({ ok, message }) => {
|
|
||||||
// if (!ok) {
|
|
||||||
// notifications.error({ message });
|
|
||||||
// } else {
|
|
||||||
// router.push("/verify-phone");
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// .catch(error => {
|
|
||||||
// console.error(error);
|
|
||||||
// notifications.error({ message: error.toString() });
|
|
||||||
// })
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const navigateToCreateId = () => router.push("/create-id");
|
const navigateToCreateId = () => router.push("/create-id");
|
||||||
|
|||||||
@ -7,10 +7,8 @@ import {
|
|||||||
type InputBaseProps,
|
type InputBaseProps,
|
||||||
type PolymorphicComponentProps,
|
type PolymorphicComponentProps,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import CountrySelect from "@/components/ui/PhoneInput/components/CountrySelect";
|
|
||||||
import { Country } from "@/components/ui/PhoneInput/types";
|
import { Country } from "@/components/ui/PhoneInput/types";
|
||||||
import getInitialDataFromValue from "@/components/ui/PhoneInput/utils/getInitialDataFromValue";
|
import getInitialDataFromValue from "@/components/ui/PhoneInput/utils/getInitialDataFromValue";
|
||||||
import getPhoneMask from "@/components/ui/PhoneInput/utils/getPhoneMask";
|
|
||||||
|
|
||||||
type AdditionalProps = {
|
type AdditionalProps = {
|
||||||
onChange: (value: string | null) => void;
|
onChange: (value: string | null) => void;
|
||||||
@ -68,20 +66,21 @@ const PhoneInput = ({
|
|||||||
component={IMaskInput}
|
component={IMaskInput}
|
||||||
inputRef={inputRef}
|
inputRef={inputRef}
|
||||||
leftSection={
|
leftSection={
|
||||||
<CountrySelect
|
<></>
|
||||||
disabled={disabled || readOnly}
|
// <CountrySelect
|
||||||
country={country}
|
// disabled={disabled || readOnly}
|
||||||
setCountry={country => {
|
// country={country}
|
||||||
setCountry(country);
|
// setCountry={country => {
|
||||||
setPhoneMask(getPhoneMask(country.code), country);
|
// setCountry(country);
|
||||||
setValue("");
|
// setPhoneMask(getPhoneMask(country.code), country);
|
||||||
if (inputRef.current) {
|
// setValue("");
|
||||||
inputRef.current.focus();
|
// if (inputRef.current) {
|
||||||
}
|
// inputRef.current.focus();
|
||||||
}}
|
// }
|
||||||
leftSectionWidth={leftSectionWidth}
|
// }}
|
||||||
inputWidth={dropdownWidth}
|
// leftSectionWidth={leftSectionWidth}
|
||||||
/>
|
// inputWidth={dropdownWidth}
|
||||||
|
// />
|
||||||
}
|
}
|
||||||
leftSectionWidth={leftSectionWidth}
|
leftSectionWidth={leftSectionWidth}
|
||||||
styles={{
|
styles={{
|
||||||
|
|||||||
@ -2,5 +2,5 @@ import type { CreateClientConfig } from './client/client.gen';
|
|||||||
|
|
||||||
export const createClientConfig: CreateClientConfig = (config) => ({
|
export const createClientConfig: CreateClientConfig = (config) => ({
|
||||||
...config,
|
...config,
|
||||||
baseUrl: 'http://id.logidex.ru/api',
|
baseUrl: process.env.NEXT_PUBLIC_API_URL,
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user