auto selecting currency if user has only one wallet

This commit was merged in pull request #687.
This commit is contained in:
victorAnumudu
2024-04-01 16:20:58 +01:00
parent f032ed21b5
commit 4b7c3beb53
5 changed files with 152 additions and 42 deletions
@@ -49,10 +49,14 @@ export default function AssignMediaTask({
family_uid
}) {
const {userDetails} = useSelector((state) => state?.userDetails); // CHECKS IF USER Details are avaliable, to determine if user is active
const { walletDetails } = useSelector((state) => state?.walletDetails); // WALLET STORE
// For form initial values
const initialValues = {
// initial values for formik
currency: "",
currency: walletDetails.data.length == 1 ? walletDetails.data[0].country : '',
amount: "",
job_description: "",
timeline_days: "",
@@ -62,9 +66,7 @@ export default function AssignMediaTask({
};
const {userDetails} = useSelector((state) => state?.userDetails); // CHECKS IF USER Details are avaliable, to determine if user is active
const { walletDetails } = useSelector((state) => state?.walletDetails); // WALLET STORE
// let imageSrc = (localStorage.getItem("session_token")
// ? `${userDetails?.session_image_server}${localStorage.getItem("session_token")}/job/${activeMedia.uid}` : ""); // FOR GETTING JOB IMAGE
@@ -144,7 +146,7 @@ export default function AssignMediaTask({
{/* Price */}
<div className="field w-full">
<label htmlFor="price" className="job-label flex gap-1">
Price
Reward
<span className='text-red-500 text-base'>{props.errors.amount && props.touched.amount && '*'}</span>
</label>
<InputCom
@@ -165,7 +167,7 @@ export default function AssignMediaTask({
<div className="field w-full">
<label
htmlFor="currency"
className="job-label flex gap-1"
className="job-label flex gap-1 invisible"
>
Currency
{props.errors.currency && props.touched.currency && <span className="text-base text-red-500">*</span>}
@@ -174,8 +176,9 @@ export default function AssignMediaTask({
id="currency"
name="currency"
value={props.values.currency}
className={`input-field w-full h-[42px] flex items-center px-2 mt-2 rounded-full placeholder:text-base text-dark-gray dark:text-white bg-slate-100 dark:bg-[#11131F] focus:ring-0 focus:outline-none`}
className={`input-field w-full h-[42px] flex items-center px-2 mt-2 rounded-full placeholder:text-base text-dark-gray dark:text-white bg-slate-100 dark:bg-[#11131F] focus:ring-0 focus:outline-none ${props.errors.currency && props.touched.currency && 'border border-red-500'}`}
onChange={props.handleChange}
disabled={walletDetails.data.length == 1}
>
{walletDetails?.loading ? (
<option className="text-slate-500 text-[13.975px]" value="">
@@ -183,18 +186,34 @@ export default function AssignMediaTask({
</option>
) : walletDetails.data.length ? (
<>
<option className="text-slate-500 text-[13.975px]" value="">
Select
</option>
{walletDetails.data?.map((item, index) => (
<option
key={index}
className="text-slate-500 text-lg"
value={item?.country}
>
{item?.code}
</option>
))}
{walletDetails.data.length == 1 ?
<>
{walletDetails.data?.map((item, index) => (
<option
key={index}
className="text-slate-500 text-lg"
value={item?.country}
>
{item?.code}
</option>
))}
</>
:
<>
<option className="text-slate-500 text-[13.975px]" value="">
Select
</option>
{walletDetails.data?.map((item, index) => (
<option
key={index}
className="text-slate-500 text-lg"
value={item?.country}
>
{item?.code}
</option>
))}
</>
}
</>
) : (
<option className="text-slate-500 text-lg" value="">
@@ -223,7 +242,7 @@ export default function AssignMediaTask({
{publicArray.length && (
<>
<option className="text-slate-500 text-[13.975px]" value="">
Duration
Select
</option>
{publicArray.map(({ name, duration }, idx) => (
<option
@@ -26,6 +26,9 @@ const AssignTaskPopout = ({
}) => {
const {parentAssignJobToKid} = SocketValues()
const { walletDetails } = useSelector((state) => state?.walletDetails); // WALLET STORE
const apiCall = new usersService();
let { pathname, state } = useLocation();
@@ -86,7 +89,7 @@ const AssignTaskPopout = ({
const [formState, setFormState] = useState({
// Initialize form state with desired fields
banner: details?.banner || "default.jpg",
country: details?.country || "",
country: details?.country ? details?.country : walletDetails.data.length == 1 ? walletDetails.data[0].country : '',
price: details?.price || "",
title: details?.title || "",
description: details?.description || "",
@@ -102,7 +102,7 @@ export default function NewTasks({ formState, setFormState }) {
htmlFor="Job Delivery Details"
className='job-label'
>
Job Delivery Details
Delivery Detail
{/* {props.errors.job_detail && props.touched.job_detail && <span className="text-[12px] text-red-500">{props.errors.job_detail}</span>} */}
</label>
<textarea
@@ -144,7 +144,7 @@ export default function NewTasks({ formState, setFormState }) {
<div className="field w-full">
<label
htmlFor="country"
className="job-label"
className="job-label invisible"
>
Currency
{/* {props.errors.country && props.touched.country && <span className="text-[12px] text-red-500">{props.errors.country}</span>} */}
@@ -155,6 +155,7 @@ export default function NewTasks({ formState, setFormState }) {
value={formState.country}
className={`input-field w-full h-[42px] flex items-center px-2 mt-2 rounded-full placeholder:text-base text-dark-gray dark:text-white bg-slate-100 dark:bg-[#11131F] focus:ring-0 focus:outline-none`}
onChange={handleInputChange}
disabled={walletDetails.data.length == 1}
// onBlur={props.handleBlur}
>
{walletDetails?.loading ? (
@@ -163,18 +164,34 @@ export default function NewTasks({ formState, setFormState }) {
</option>
) : walletDetails.data.length ? (
<>
<option className="text-slate-500 text-[13.975px]" value="">
Select
</option>
{walletDetails.data?.map((item, index) => (
<option
key={index}
className="text-slate-500 text-lg"
value={item?.country}
>
{item?.code}
</option>
))}
{walletDetails.data.length == 1 ?
<>
{walletDetails.data?.map((item, index) => (
<option
key={index}
className="text-slate-500 text-lg"
value={item?.country}
>
{item?.code}
</option>
))}
</>
:
<>
<option className="text-slate-500 text-[13.975px]" value="">
Select
</option>
{walletDetails.data?.map((item, index) => (
<option
key={index}
className="text-slate-500 text-lg"
value={item?.country}
>
{item?.code}
</option>
))}
</>
}
</>
) : (
<option className="text-slate-500 text-lg" value="">
@@ -205,7 +222,7 @@ export default function NewTasks({ formState, setFormState }) {
{publicArray.length && (
<>
<option className="text-slate-500 text-[13.975px]" value="">
Duration
Select
</option>
{publicArray.map(({ name, duration }, idx) => (
<option