first commit

This commit is contained in:
javad committed 2024-02-07 14:37:21 +03:30
1 parent b27f4f2f23
commit db10146ecd
58 files changed
+3684 -202

No files matched your search

+45 -2
View File
@@ -1,6 +1,48 @@
import { Fragment } from "react"
'use client'
import { Fragment, useState } from "react"
import { useRouter } from 'next/navigation'
import { useDispatch } from 'react-redux'
import { addMobile } from "@/app/redux/features/mobileoptSlice"
const Page = ()=>{
const [username, setUserName] = useState()
const [password, setPassword] = useState()
const router = useRouter()
const dispatch = useDispatch()
const onChangeMobile = (e:any)=>{
setUserName(e.target.value)
}
const login = async ()=>{
const res = await fetch('http://127.0.0.1:8000/auth/login/mobile/', {
method: "POST",
cache: 'no-store',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
mobile: username
})
},)
console.log(res)
const data = await res.json();
console.log(data)
dispatch( addMobile(data.result.mobile) )
if (data.result.message == 'opt code send'){
router.push('/login/verify/')
}
}
return (
<Fragment>
<div className="mx-auto w-full sm:w-[30rem] mt-[-10rem]">
@@ -17,11 +59,12 @@ const Page = ()=>{
type="email"
id="UserEmail"
placeholder="شماره موبایل را وارد کنید"
onChange={(e)=>{ onChangeMobile(e) }}
className="mt-1 w-full h-[45px] p-5 rounded-md border-gray-200 shadow-sm sm:text-sm"
/>
</div>
<input type="submit" className="bg-slate-900 text-white rounded p-2" value={"ورود"} />
<input onClick={()=>{ login() }} type="submit" className="bg-slate-900 text-white rounded p-2" value={"ورود"} />
</div>
</div>