diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..9cace29 --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +NEXT_PUBLIC_API_URL=http://your.api/api \ No newline at end of file diff --git a/.yarn/install-state.gz b/.yarn/install-state.gz index 20c0c0e..65db638 100644 Binary files a/.yarn/install-state.gz and b/.yarn/install-state.gz differ diff --git a/src/app/consent/components/ConsentButton/ConsentButton.tsx b/src/app/consent/components/ConsentButton/ConsentButton.tsx index bd0989c..53c5a41 100644 --- a/src/app/consent/components/ConsentButton/ConsentButton.tsx +++ b/src/app/consent/components/ConsentButton/ConsentButton.tsx @@ -27,17 +27,7 @@ const ConsentButton: FC = () => { }; 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(() => { @@ -46,13 +36,21 @@ const ConsentButton: FC = () => { }, []); const confirmAccess = () => { + const phoneNumber = auth.phoneNumber; + if (!phoneNumber) { + console.error("Phone number is not set"); + return; + } const consentChallenge = searchParams.get("consent_challenge"); if (!consentChallenge) { console.error("Consent challenge is missing in the URL"); return; } Auth.postAuthConsentAccept({ - body: { consent_challenge: consentChallenge }, + body: { + consent_challenge: consentChallenge, + phone_number: phoneNumber, + }, }) .then(response => response.data) .then(response => { @@ -69,17 +67,7 @@ const ConsentButton: FC = () => { 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 ( diff --git a/src/app/services/components/ServicesList/ServicesList.tsx b/src/app/services/components/ServicesList/ServicesList.tsx index 7661072..3523174 100644 --- a/src/app/services/components/ServicesList/ServicesList.tsx +++ b/src/app/services/components/ServicesList/ServicesList.tsx @@ -9,8 +9,12 @@ import SCOPES from "@/constants/scopes"; import { Scopes } from "@/enums/Scopes"; import { setTargetService } from "@/lib/store/features/targetService/targetServiceSlice"; import { useAppDispatch } from "@/lib/store/store"; -import ServiceData from "@/types/ServiceData"; +type ServiceData = { + id: number; + code: Scopes; + name: string; +}; const ServicesList = () => { const dispatch = useAppDispatch(); const services = useMemo( @@ -56,7 +60,9 @@ const ServicesList = () => { - {services.map((service, i) => getServiceButton(service, i))} + {services.map((service, i) => + getServiceButton(service as unknown as ServiceData, i) + )} {getServiceInDevelopment("Analytics")} diff --git a/src/app/verify-phone/components/VerifyPhoneForm/VerifyPhoneForm.tsx b/src/app/verify-phone/components/VerifyPhoneForm/VerifyPhoneForm.tsx index bac1b4a..0b2d423 100644 --- a/src/app/verify-phone/components/VerifyPhoneForm/VerifyPhoneForm.tsx +++ b/src/app/verify-phone/components/VerifyPhoneForm/VerifyPhoneForm.tsx @@ -27,13 +27,13 @@ const VerifyPhoneForm: FC = () => { const authState = useSelector((state: RootState) => state.auth); const handleSubmit = (values: VerifyNumberForm) => { - + if (!authState.phoneNumber || !authState.loginChallenge) return; console.log(authState.phoneNumber.replace(/ /g, "")); Auth.postAuthOtpVerify({ body: { - phone_number: authState.phoneNumber.replace(" ", ""), + phone_number: authState.phoneNumber, login_challenge: authState.loginChallenge, otp: values.code, }, diff --git a/src/client/types.gen.ts b/src/client/types.gen.ts index dde33b2..5a79778 100644 --- a/src/client/types.gen.ts +++ b/src/client/types.gen.ts @@ -42,6 +42,10 @@ export type VerifyOtpResponse = { * Status of the verification */ ok: boolean; + /** + * Confirmation message + */ + message: string; }; export type AcceptConsentRequest = { @@ -49,6 +53,10 @@ export type AcceptConsentRequest = { * The consent challenge to accept */ consent_challenge: string; + /** + * Phone number associated with the consent + */ + phone_number: string; }; export type AcceptConsentResponse = { diff --git a/src/client/zod.gen.ts b/src/client/zod.gen.ts index 2ec8c3d..6acf14c 100644 --- a/src/client/zod.gen.ts +++ b/src/client/zod.gen.ts @@ -19,11 +19,13 @@ export const zVerifyOtpRequest = z.object({ export const zVerifyOtpResponse = z.object({ redirect_url: z.string(), - ok: z.boolean() + ok: z.boolean(), + message: z.string() }); export const zAcceptConsentRequest = z.object({ - consent_challenge: z.string() + consent_challenge: z.string(), + phone_number: z.string().max(15) }); export const zAcceptConsentResponse = z.object({ diff --git a/src/components/features/LoginForm/LoginForm.tsx b/src/components/features/LoginForm/LoginForm.tsx index f6d66a5..a698a71 100644 --- a/src/components/features/LoginForm/LoginForm.tsx +++ b/src/components/features/LoginForm/LoginForm.tsx @@ -62,19 +62,6 @@ const LoginForm: FC = ({ loginChallenge, isCreatingId = false }) => { 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"); diff --git a/src/components/ui/PhoneInput/PhoneInput.tsx b/src/components/ui/PhoneInput/PhoneInput.tsx index 38a6c31..3296e10 100644 --- a/src/components/ui/PhoneInput/PhoneInput.tsx +++ b/src/components/ui/PhoneInput/PhoneInput.tsx @@ -7,10 +7,8 @@ import { type InputBaseProps, type PolymorphicComponentProps, } from "@mantine/core"; -import CountrySelect from "@/components/ui/PhoneInput/components/CountrySelect"; import { Country } from "@/components/ui/PhoneInput/types"; import getInitialDataFromValue from "@/components/ui/PhoneInput/utils/getInitialDataFromValue"; -import getPhoneMask from "@/components/ui/PhoneInput/utils/getPhoneMask"; type AdditionalProps = { onChange: (value: string | null) => void; @@ -68,20 +66,21 @@ const PhoneInput = ({ component={IMaskInput} inputRef={inputRef} leftSection={ - { - setCountry(country); - setPhoneMask(getPhoneMask(country.code), country); - setValue(""); - if (inputRef.current) { - inputRef.current.focus(); - } - }} - leftSectionWidth={leftSectionWidth} - inputWidth={dropdownWidth} - /> + <> + // { + // setCountry(country); + // setPhoneMask(getPhoneMask(country.code), country); + // setValue(""); + // if (inputRef.current) { + // inputRef.current.focus(); + // } + // }} + // leftSectionWidth={leftSectionWidth} + // inputWidth={dropdownWidth} + // /> } leftSectionWidth={leftSectionWidth} styles={{ diff --git a/src/hey-api-config.ts b/src/hey-api-config.ts index 4327c35..b674476 100644 --- a/src/hey-api-config.ts +++ b/src/hey-api-config.ts @@ -2,5 +2,5 @@ import type { CreateClientConfig } from './client/client.gen'; export const createClientConfig: CreateClientConfig = (config) => ({ ...config, - baseUrl: 'http://id.logidex.ru/api', + baseUrl: process.env.NEXT_PUBLIC_API_URL, }); \ No newline at end of file