Skip to content

Commit

Permalink
Merge branch 'main' into fatima_addondup
Browse files Browse the repository at this point in the history
  • Loading branch information
ufumerfarooq67 authored Dec 5, 2024
2 parents b355fe4 + 02b3a0e commit 334525f
Show file tree
Hide file tree
Showing 22 changed files with 391 additions and 195 deletions.
149 changes: 70 additions & 79 deletions enatega-multivendor-admin/src/apollo/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,27 +608,32 @@ export const restaurantList = `query RestaurantList{
}
}`

export const restaurants = `query Restaurants{
restaurants{
_id
name
image
orderPrefix
slug
address
deliveryTime
minimumOrder
isActive
commissionRate
tax
owner{
_id
email
export const restaurants = `
query Restaurants($page: Int, $rowsPerPage: Int, $search: String) {
restaurants(page: $page, rowsPerPage: $rowsPerPage, search: $search) {
restaurants {
_id
name
image
orderPrefix
slug
address
deliveryTime
minimumOrder
isActive
commissionRate
tax
owner {
_id
email
}
shopType
}
totalCount
}
shopType
}
}
`
`;


export const getRestaurantProfile = `query Restaurant($id:String){
restaurant(id:$id)
Expand Down Expand Up @@ -746,31 +751,41 @@ query PageCount($restaurant:String!){
pageCount(restaurant:$restaurant)
}
`
export const getUsers = `query{
users{
_id
name
email
phone
addresses{
location{coordinates}
deliveryAddress
export const getUsers = `
query Users($page: Int, $rowsPerPage: Int, $search: String) {
users(page: $page, rowsPerPage: $rowsPerPage, search: $search) {
users {
_id
name
email
phone
addresses {
location {
coordinates
}
deliveryAddress
}
}
totalCount
}
}`
}
`;

export const getRiders = `query{
riders{
_id
name
username
password
phone
available
zone{
export const getRiders = `query Riders($page: Int, $rowsPerPage: Int, $search: String) {
riders(page: $page, rowsPerPage: $rowsPerPage, search: $search) {
riders {
_id
title
name
username
password
phone
available
zone {
_id
title
}
}
totalCount
}
}`

Expand All @@ -787,46 +802,22 @@ export const getAvailableRiders = `query{
}
}`

export const withdrawRequestQuery = `query GetWithdrawRequests($offset:Int){
getAllWithdrawRequests(offset:$offset){
success
message
data{
_id
requestId
requestAmount
requestTime
rider{
_id
name
currentWalletAmount
}
status
}
pagination{
total
}
}
}`

export const withdrawRequestQueryWithPagination = `query GetWithdrawRequests($offset:Int, $page: Int, $rowsPerPage: Int, $search: String){
getAllWithdrawRequests(offset:$offset, $page: Int, $rowsPerPage: Int, $search: String){
success
message
data{
export const withdrawRequestQuery = `
query GetWithdrawRequests($page: Int, $rowsPerPage: Int, $search: String) {
withdrawRequests(page: $page, rowsPerPage: $rowsPerPage, search: $search) {
requests {
_id
requestId
requestAmount
requestTime
rider {
_id
requestId
requestAmount
requestTime
rider{
_id
name
currentWalletAmount
}
status
}
pagination{
total
name
currentWalletAmount
}
status
}
totalCount
}
}`
}
`
4 changes: 2 additions & 2 deletions enatega-multivendor-admin/src/components/Rider/Rider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function Rider(props) {
const globalClasses = useGlobalStyles()

const handlePhoneInput = (e) => {
const value = e.target.value.replace(/[^0-9]/g, '');
const value = e.target.value.replace(/[^0-9]/g, '')?.slice(0, 15);
e.target.value = value;
};

Expand Down Expand Up @@ -304,7 +304,7 @@ function Rider(props) {
id="input-phone"
name="input-phone"
placeholder={t('PhoneNumber')}
type="number"
type="tel"
defaultValue={phone}
onInput={handlePhoneInput}
onBlur={event =>
Expand Down
17 changes: 17 additions & 0 deletions enatega-multivendor-admin/src/utils/debounce.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useState, useEffect } from 'react'

export function useDebounce(value, delay) {
const [debouncedValue, setDebouncedValue] = useState(value)

useEffect(() => {
const handler = setTimeout(() => {
setDebouncedValue(value)
}, delay || 500)

return () => {
clearTimeout(handler)
}
}, [value, delay])

return debouncedValue
}
6 changes: 4 additions & 2 deletions enatega-multivendor-admin/src/views/Commission.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ const Commission = () => {
const { data, error: errorQuery, loading: loadingQuery } = useQuery(
GET_RESTAURANTS
)
console.log(data)

console.log("🚀 ~ Commission ~ data:", data)

const globalClasses = useGlobalStyles()
const classes = useStyles()
const { t } = useTranslation()
Expand Down Expand Up @@ -90,7 +92,7 @@ const Commission = () => {
) : (
data && (
<>
{data.restaurants.map(restaurant => (
{data.restaurants.restaurants.map(restaurant => (
<Grid key={restaurant._id} container spacing={1}>
<Grid item sm={5} mt={3}>
{restaurant.name}
Expand Down
17 changes: 4 additions & 13 deletions enatega-multivendor-admin/src/views/Coupons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
} from '@mui/material'
import { ReactComponent as CouponsIcon } from '../assets/svg/svg/Coupons.svg'
import TableHeader from '../components/TableHeader'
import { useDebounce } from '../utils/debounce'


const GET_COUPONS_WITH_PAGINATION = gql`
Expand All @@ -44,6 +45,7 @@ const Coupon = props => {
const [editModal, setEditModal] = useState(false)
const [coupon, setCoupon] = useState(null)
const [searchQuery, setSearchQuery] = useState('')
const debouncedSearchQuery = useDebounce(searchQuery, 500) // Debounce search query
const onChangeSearch = e => setSearchQuery(e.target.value)
const [mutateEdit] = useMutation(EDIT_COUPON)
const [page, setPage] = useState(0)
Expand All @@ -61,18 +63,16 @@ const Coupon = props => {
variables: {
page: page,
rowsPerPage,
search: searchQuery.length > 2 ? searchQuery : null
search: debouncedSearchQuery.length > 3 ? debouncedSearchQuery : null
},
fetchPolicy: 'network-only',
}
)

console.log("🚀 ~ Coupon ~ data:", data)

const coupons = data?.coupons.coupons || []
console.log("🚀 ~ Coupon ~ coupons:", coupons)

const totalCount = data?.coupons.totalCount || 0
console.log("🚀 ~ Coupon ~ totalCount:", totalCount)

const toggleModal = coupon => {
setEditModal(!editModal)
Expand Down Expand Up @@ -121,15 +121,6 @@ const Coupon = props => {
cell: row => <>{actionButtons(row)}</>
}
]
const regex =
searchQuery.length > 2 ? new RegExp(searchQuery.toLowerCase(), 'g') : null
const filtered =
searchQuery.length < 3
? data && data.coupons
: data &&
data.coupons.filter(coupon => {
return coupon.title.toLowerCase().search(regex) > -1
})

const statusChanged = row => {
return (
Expand Down
4 changes: 3 additions & 1 deletion enatega-multivendor-admin/src/views/Dispatch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { ReactComponent as DispatchIcon } from '../assets/svg/svg/Dispatch.svg'
import TableHeader from '../components/TableHeader'
import { NotificationContainer, NotificationManager } from 'react-notifications'
import 'react-notifications/lib/notifications.css'
import { useDebounce } from '../utils/debounce'

const SUBSCRIPTION_ORDER = gql`
${subscriptionOrder}
Expand Down Expand Up @@ -50,6 +51,7 @@ const Orders = props => {
const [mutateAssign] = useMutation(ASSIGN_RIDER)
const [page, setPage] = useState(0)
const [rowsPerPage, setRowsPerPage] = useState(10)
const debouncedSearchQuery = useDebounce(searchQuery, 500) // Debounce search query

const riderFunc = row => {
const { data: dataZone } = useQuery(GET_RIDERS_BY_ZONE, {
Expand Down Expand Up @@ -109,7 +111,7 @@ const Orders = props => {
variables: {
page,
rowsPerPage,
search: searchQuery.length > 5 ? searchQuery : ''
search: debouncedSearchQuery.length > 3 ? debouncedSearchQuery : null
},
pollInterval: 100000
})
Expand Down
Loading

0 comments on commit 334525f

Please sign in to comment.