From 5015baf19baa9fd94c295ab6d9598b06dd72062c Mon Sep 17 00:00:00 2001 From: mbappai Date: Tue, 26 Sep 2023 20:57:01 +0100 Subject: [PATCH] refactor: remove all dynamic APIs --- components/Manager/Banks/BanksView.tsx | 45 ++++++++----- .../Manager/Organizations/EditOrg/index.tsx | 12 ++-- .../ManagerOrgsView/ManagerOrgsView.tsx | 62 ++++++++--------- .../Manager/Platform/serviceItemTypesView.tsx | 4 +- components/Manager/Users/UsersView.tsx | 4 +- .../OrganizationList/OrganizationView.tsx | 51 +++++++------- .../Availability/Availability.tsx | 6 +- .../EditServiceItemForm.tsx | 16 ++--- components/ServiceItemsPage/index.tsx | 67 ++++++++++--------- .../EditServiceForm/EditServiceForm.tsx | 20 +++--- .../ServicesView/ServicesView.tsx | 52 +++++++------- components/StaffPage/index.tsx | 42 ++++++------ hooks/useFetchUserOrgs.ts | 2 +- pages/manager/bookings/communities.tsx | 2 +- pages/manager/organizations/new.tsx | 4 +- pages/organizations/communities/index.tsx | 20 +++--- pages/organizations/events/index.tsx | 40 +++++------ pages/organizations/events/staff/index.tsx | 4 +- 18 files changed, 237 insertions(+), 216 deletions(-) diff --git a/components/Manager/Banks/BanksView.tsx b/components/Manager/Banks/BanksView.tsx index 0621c169..78eafb6f 100644 --- a/components/Manager/Banks/BanksView.tsx +++ b/components/Manager/Banks/BanksView.tsx @@ -12,6 +12,7 @@ import dayjs from 'dayjs' import { ColumnsType, ColumnType, TableProps } from 'antd/lib/table'; import { Bank } from "./Banks.types"; import { usePlacesWidget } from "react-google-autocomplete"; +import useUrlPrefix from "../../../hooks/useUrlPrefix"; const {TextArea} = Input @@ -31,10 +32,12 @@ export default function BankView(){ const [selectedBank, setSelelectedOrg] = useState({}) const [currentFilter, setCurrentStatus] = useState({id:'1',name: 'Verified'}) + const urlPrefix = useUrlPrefix() + async function fetchBanks(){ const res = await axios({ method:'get', - url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/manager/org-bank?key=status&value=${currentFilter.id}&pageNumber=${pageNumber}&pageSize=${pageSize}`, + url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/org-bank?status=${currentFilter.id}&pageNumber=${pageNumber}&pageSize=${pageSize}`, headers:{ "Authorization": paseto } @@ -47,10 +50,10 @@ export default function BankView(){ async function changeOrgStatus({bankId, statusNumber}:{bankId:string, statusNumber: string}){ const res = await axios({ method:'patch', - url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/manager/org-bank`, + url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/org-bank`, data:{ - key:'status', - value: statusNumber, // 0 means de-activated in db + // key:'status', + status: statusNumber, // 0 means de-activated in db id: bankId }, headers:{ @@ -291,10 +294,11 @@ function EditableName({selectedBank}:EditableProp){ setIsEditMode(!isEditMode) } + const urlPrefix = useUrlPrefix() const mutationHandler = async(updatedItem:any)=>{ - const {data} = await axios.patch(`${process.env.NEXT_PUBLIC_NEW_API_URL}/manager/org-bank`,updatedItem,{ + const {data} = await axios.patch(`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/org-bank`,updatedItem,{ headers:{ //@ts-ignore "Authorization": paseto @@ -312,8 +316,8 @@ function EditableName({selectedBank}:EditableProp){ function onFinish(updatedItem:Bank){ const payload = { - key:'bank_name', - value: updatedItem.bankName, + // key:'bank_name', + bankName: updatedItem.bankName, id: selectedBank.id } const updatedRecord = { @@ -386,10 +390,12 @@ function EditableAccountNo({selectedBank}:EditableProp){ setIsEditMode(!isEditMode) } + const urlPrefix = useUrlPrefix() + const mutationHandler = async(updatedItem:any)=>{ - const {data} = await axios.patch(`${process.env.NEXT_PUBLIC_NEW_API_URL}/manager/org-bank`,updatedItem,{ + const {data} = await axios.patch(`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/org-bank`,updatedItem,{ headers:{ //@ts-ignore "Authorization": paseto @@ -407,8 +413,8 @@ function EditableAccountNo({selectedBank}:EditableProp){ function onFinish(updatedItem:Bank){ const payload = { - key:'account_no', - value: updatedItem.accountNo, + // key:'account_no', + acountNo: updatedItem.accountNo, id: selectedBank.id } const updatedRecord = { @@ -502,8 +508,8 @@ function EditableCurrency({selectedBank}:EditableProp){ function onFinish(updatedItem:Bank){ const payload = { - key:'currency', - value: updatedItem.currency, + // key:'currency', + currency: updatedItem.currency, id: selectedBank.id } const updatedRecord = { @@ -621,9 +627,10 @@ function EditableAddress({selectedBank}:EditableProp){ }, }); + const urlPrefix = useUrlPrefix() const mutationHandler = async(updatedItem:any)=>{ - const {data} = await axios.patch(`${process.env.NEXT_PUBLIC_NEW_API_URL}/manager/org`,updatedItem,{ + const {data} = await axios.patch(`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/org`,updatedItem,{ headers:{ //@ts-ignore "Authorization": paseto @@ -641,8 +648,8 @@ function EditableAddress({selectedBank}:EditableProp){ function onFinish(updatedItem:any){ const payload = { - key:'country', - value: updatedItem.country, + // key:'country', + country: updatedItem.country, orgId: selectedBank.id } const updatedRecord = { @@ -731,8 +738,10 @@ function EditableAccountType({selectedBank}:EditableProp){ ) + const urlPrefix = useUrlPrefix() + const mutationHandler = async(updatedItem:any)=>{ - const {data} = await axios.patch(`${process.env.NEXT_PUBLIC_NEW_API_URL}/manager/org-bank`,updatedItem,{ + const {data} = await axios.patch(`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/org-bank`,updatedItem,{ headers:{ //@ts-ignore "Authorization": paseto @@ -751,8 +760,8 @@ function EditableAccountType({selectedBank}:EditableProp){ function onFinish(field:any){ const payload = { - key:'account_type', - value: field.accountType, + // key:'account_type', + accountType: field.accountType, id: selectedBank.id } mutation.mutate(payload) diff --git a/components/Manager/Organizations/EditOrg/index.tsx b/components/Manager/Organizations/EditOrg/index.tsx index 4545e911..1ee53e82 100644 --- a/components/Manager/Organizations/EditOrg/index.tsx +++ b/components/Manager/Organizations/EditOrg/index.tsx @@ -50,8 +50,8 @@ interface EditableProp{ function onFinish(updatedItem:any){ const payload = { - key:'name', - value: updatedItem.name, + // key:'name', + name: updatedItem.name, //@ts-ignore id: selectedOrg.orgId } @@ -342,8 +342,8 @@ interface EditableProp{ function onFinish(field:any){ const payload = { - key:'contact_number', - value: field.contactNumber, + // key:'contact_number', + contactNumber: field.contactNumber, id: selectedOrg.id } console.log(payload) @@ -433,8 +433,8 @@ interface EditableProp{ function onFinish(field:any){ const payload = { - key:'zip_code', - value: field.zipCode, + // key:'zip_code', + zipCode: field.zipCode, id: selectedOrg.id } mutation.mutate(payload) diff --git a/components/Manager/Organizations/ManagerOrgsView/ManagerOrgsView.tsx b/components/Manager/Organizations/ManagerOrgsView/ManagerOrgsView.tsx index 743a9a6e..77bb7092 100644 --- a/components/Manager/Organizations/ManagerOrgsView/ManagerOrgsView.tsx +++ b/components/Manager/Organizations/ManagerOrgsView/ManagerOrgsView.tsx @@ -16,8 +16,6 @@ import { useAuthContext } from '../../../../context/AuthContext'; import dayjs from 'dayjs' import { ColumnsType, ColumnType, TableProps } from 'antd/lib/table'; import { useOrgContext } from "../../../../context/OrgContext"; -import { asyncStore } from "../../../../utils/nftStorage"; -import { usePlacesWidget } from "react-google-autocomplete"; import { EditableName, EditableAddress, EditablePhone, EditableZipCode, EditableLogoImage, EditableCoverImage } from "../EditOrg"; import { convertToAmericanFormat } from "../../../../utils/phoneNumberFormatter"; import { EditableText } from "../../../shared/Editables"; @@ -57,18 +55,18 @@ export default function ManagerOrgsView(){ const [selectedOrg, setSelelectedOrg] = useState({}) const [currentStatus, setCurrentStatus] = useState({id:'1',name: 'Approved'}) - async function fetchAllOrgs(){ - const res = await axios({ - method:'get', - url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/orgs?pageNumber=${pageNumber}&pageSize=10`, - headers:{ - "Authorization": paseto - } - }) + // async function fetchAllOrgs(){ + // const res = await axios({ + // method:'get', + // url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/orgs?pageNumber=${pageNumber}&pageSize=10`, + // headers:{ + // "Authorization": paseto + // } + // }) - return res.data; + // return res.data; - } + // } async function fetchOrgs(){ const res = await axios({ @@ -90,8 +88,8 @@ export default function ManagerOrgsView(){ method:'patch', url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/org`, data:{ - key:'status', - value: statusNumber, // 0 means de-activated in db + // key:'status', + status: statusNumber, // 0 means de-activated in db id: orgId }, headers:{ @@ -105,8 +103,8 @@ export default function ManagerOrgsView(){ method:'patch', url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/users-role`, data:{ - key:'role', - value: '2', // 2 is for admin + // key:'role', + role: '2', // 2 is for admin targetUserId: userId }, headers:{ @@ -189,8 +187,8 @@ export default function ManagerOrgsView(){ const orgs = orgQuery.data && orgQuery.data.data const totalLength = orgQuery.data && orgQuery.data.dataLength; - const allOrgsQuery = useQuery({queryKey:['all-orgs'], queryFn:fetchAllOrgs, enabled:paseto !== '',staleTime:Infinity}) - const allOrgsTotal = allOrgsQuery.data && allOrgsQuery.data.dataLength; + // const allOrgsQuery = useQuery({queryKey:['all-orgs'], queryFn:fetchAllOrgs, enabled:paseto !== '',staleTime:Infinity}) + // const allOrgsTotal = allOrgsQuery.data && allOrgsQuery.data.dataLength; @@ -431,8 +429,8 @@ export default function ManagerOrgsView(){ method:'patch', url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/org`, data:{ - key:'status', - value: '1', + // key:'status', + status: '1', //@ts-ignore id: record.orgId }, @@ -546,9 +544,10 @@ export default function ManagerOrgsView(){ - { allOrgsQuery && allOrgsTotal === 0 + {/* { allOrgsQuery && allOrgsTotal === 0 ? null - :
+ : */} +
Organizations
@@ -564,11 +563,12 @@ export default function ManagerOrgsView(){
- } + {/* } */} - { allOrgsQuery && allOrgsTotal === 0 + {/* { allOrgsQuery && allOrgsTotal === 0 ? - : `Total: ${total} items`, }} - />} + /> + + {/* } */} { isDrawerOpen ? @@ -659,8 +661,8 @@ async function reActivateOrgHandler(record:NewOrg){ method:'patch', url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/org`, data:{ - key:'status', - value: '1', + // key:'status', + status: '1', //@ts-ignore id: record.orgId }, @@ -686,8 +688,8 @@ const deleteDataHandler = async(record:NewOrg)=>{ data: { //@ts-ignore id:record.orgId, - key:'status', - value: '0' + // key:'status', + status: '0' }, headers:{ "Authorization": paseto diff --git a/components/Manager/Platform/serviceItemTypesView.tsx b/components/Manager/Platform/serviceItemTypesView.tsx index 7287dea6..b12c01aa 100644 --- a/components/Manager/Platform/serviceItemTypesView.tsx +++ b/components/Manager/Platform/serviceItemTypesView.tsx @@ -471,8 +471,8 @@ function EditableRole({selectedServiceItemType}:EditableProp){ function onFinish(updatedItem:any){ console.log(updatedItem) const payload = { - key:'name', - value: String(updatedItem.name), + // key:'name', + name: String(updatedItem.name), id: selectedServiceItemType.id } const updatedRecord = { diff --git a/components/Manager/Users/UsersView.tsx b/components/Manager/Users/UsersView.tsx index ed90e510..17782ebf 100644 --- a/components/Manager/Users/UsersView.tsx +++ b/components/Manager/Users/UsersView.tsx @@ -337,8 +337,8 @@ const deleteDataHandler = async(record:User)=>{ url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/users-role`, data: { targetUserId:record.id, - key:'status', - value: "0" + // key:'status', + status: "0" }, headers:{ "Authorization": paseto diff --git a/components/OrganizationsPage/OrganizationList/OrganizationView.tsx b/components/OrganizationsPage/OrganizationList/OrganizationView.tsx index 503cbbe2..cc9b769c 100644 --- a/components/OrganizationsPage/OrganizationList/OrganizationView.tsx +++ b/components/OrganizationsPage/OrganizationList/OrganizationView.tsx @@ -58,18 +58,18 @@ export default function AdminOrgsView(){ const urlPrefix = useUrlPrefix() - async function fetchAllOrgs(){ - const res = await axios({ - method:'get', - url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/orgs?pageNumber=${pageNumber}&pageSize=10&status=1`, - headers:{ - "Authorization": paseto - } - }) + // async function fetchAllOrgs(){ + // const res = await axios({ + // method:'get', + // url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/orgs?pageNumber=${pageNumber}&pageSize=10&status=1`, + // headers:{ + // "Authorization": paseto + // } + // }) - return res.data; + // return res.data; - } + // } async function fetchOrgs(){ const res = await axios({ @@ -89,8 +89,8 @@ export default function AdminOrgsView(){ method:'patch', url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/org`, data:{ - key:'status', - value: statusNumber, // 0 means de-activated in db + // key:'status', + status: statusNumber, // 0 means de-activated in db id: orgId }, headers:{ @@ -126,8 +126,8 @@ export default function AdminOrgsView(){ // const data = servicesQuery.data && servicesQuery.data.data const totalLength = orgQuery.data && orgQuery.data.dataLength; - const allOrgsQuery = useQuery({queryKey:['all-orgs'], queryFn:fetchAllOrgs, enabled:paseto !== '',staleTime:Infinity}) - const allOrgsTotal = allOrgsQuery.data && allOrgsQuery.data.dataLength; + // const allOrgsQuery = useQuery({queryKey:['all-orgs'], queryFn:fetchAllOrgs, enabled:paseto !== '',staleTime:Infinity}) + // const allOrgsTotal = allOrgsQuery.data && allOrgsQuery.data.dataLength; @@ -434,8 +434,8 @@ export default function AdminOrgsView(){ method:'patch', url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/org`, data:{ - key:'status', - value: '1', + // key:'status', + status: '1', //@ts-ignore id: record.orgId }, @@ -466,9 +466,10 @@ export default function AdminOrgsView(){ banner closable />:null} */} - {allOrgsQuery && allOrgsTotal === 0 + {/* {allOrgsQuery && allOrgsTotal === 0 ? null - :
+ : */} +
Organizations
@@ -485,11 +486,12 @@ export default function AdminOrgsView(){
- } + {/* } */} - {allOrgsQuery && allOrgsTotal === 0 + {/* {allOrgsQuery && allOrgsTotal === 0 ? - :
record.id} size="middle" @@ -504,7 +506,8 @@ export default function AdminOrgsView(){ total:totalLength, showTotal:(total) => `Total: ${total} items`, }} - />} + /> + {/* } */} {/* { isDrawerOpen && currentStatus.name === 'Approved' ? @@ -586,8 +589,8 @@ const deleteDataHandler = async(record:NewOrg)=>{ data: { //@ts-ignore id:record.orgId, - key:'status', - value: '0' + // key:'status', + status: '0' }, headers:{ "Authorization": paseto diff --git a/components/ServiceItemsPage/Availability/Availability.tsx b/components/ServiceItemsPage/Availability/Availability.tsx index fced3f56..cf94d340 100644 --- a/components/ServiceItemsPage/Availability/Availability.tsx +++ b/components/ServiceItemsPage/Availability/Availability.tsx @@ -20,7 +20,7 @@ export default function AvailabilitySection({selectedServiceItem}:Props){ const urlPrefix = useUrlPrefix() async function fetchItemAvailability(){ - const res = await axios.get(`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/service-items/availability?key=service_item_id&value=${selectedServiceItem.id}&pageNumber=1&pageSize=50`,{ + const res = await axios.get(`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/service-items/availability?serviceItemId=${selectedServiceItem.id}&pageNumber=1&pageSize=50`,{ headers:{ "Authorization":paseto } @@ -29,12 +29,11 @@ export default function AvailabilitySection({selectedServiceItem}:Props){ } const {data, isLoading} = useQuery({queryKey:['availability',selectedServiceItem.id], queryFn:fetchItemAvailability}) - console.log(data) + const availabilityData = data && data; const isAvailabilityEmpty = data && data.length == 0 - console.log(availabilityData) return( @@ -327,7 +326,6 @@ export function NewAvailability({selectedServiceItem}:NewAvailabilityProps){ serviceItemId: selectedServiceItem.id, availability: [transformedItem] } - console.log(payload) // const updatedRecord = { // ...selectedRecord, diff --git a/components/ServiceItemsPage/EditServiceItemForm/EditServiceItemForm.tsx b/components/ServiceItemsPage/EditServiceItemForm/EditServiceItemForm.tsx index 8fbdf55e..2d96c22d 100644 --- a/components/ServiceItemsPage/EditServiceItemForm/EditServiceItemForm.tsx +++ b/components/ServiceItemsPage/EditServiceItemForm/EditServiceItemForm.tsx @@ -154,8 +154,8 @@ interface EditableProp{ function onFinish(updatedItem:any){ const payload = { - key:'price', - value: String(updatedItem.price*100), + // key:'price', + price: String(updatedItem.price*100), id: selectedRecord.id } recordMutation.mutate(payload) @@ -245,8 +245,8 @@ interface EditableProp{ function onFinish(updatedItem:any){ const payload = { - key:'tickets_per_day', - value: updatedItem.ticketsPerDay, + // key:'tickets_per_day', + ticketsPerDay: updatedItem.ticketsPerDay, id: selectedRecord.id } const updatedRecord = { @@ -343,8 +343,8 @@ interface EditableProp{ function onFinish(updatedItem:any){ const payload = { - key:'description', - value: updatedItem.description, + // key:'description', + description: updatedItem.description, id: selectedRecord.id } const updatedRecord = { @@ -460,8 +460,8 @@ interface EditableProp{ const payload = { - key:'logo_image_hash', - value: artwork, + // key:'logo_image_hash', + logoImageHash: artwork, id: selectedRecord.id } // setUpdatedCoverImageHash(coverImageHash) diff --git a/components/ServiceItemsPage/index.tsx b/components/ServiceItemsPage/index.tsx index 10e22fe5..120ff5fb 100644 --- a/components/ServiceItemsPage/index.tsx +++ b/components/ServiceItemsPage/index.tsx @@ -74,18 +74,19 @@ export default function ServiceItemsView(){ const items = serviceItemTypes && serviceItemTypes.map((item:any)=>({label:item.label, key:item.value})) - async function fetchAllServiceItems(){ - const res = await axios({ - method:'get', - url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/service-items?serviceId=${currentService.id}&pageNumber=${pageNumber}&pageSize=10`, - headers:{ - "Authorization": paseto - } - }) - - return res.data; + // async function fetchAllServiceItems(){ + // const res = await axios({ + // method:'get', + // url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/service-items?serviceId=${currentService.id}&pageNumber=${pageNumber}&pageSize=10`, + // headers:{ + // "Authorization": paseto + // } + // }) + + // return res.data; - } + // } + async function fetchServiceItems(){ const res = await axios({ method:'get', @@ -105,8 +106,8 @@ export default function ServiceItemsView(){ method:'patch', url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/service-items`, data:{ - key:'status', - value: statusNumber, // 0 means de-activated in db + // key:'status', + status: statusNumber, // 0 means de-activated in db serviceItemId: serviceItemId }, headers:{ @@ -138,11 +139,11 @@ export default function ServiceItemsView(){ const serviceItemsQuery = useQuery({queryKey:['serviceItems', {currentSerive:currentService.id, filter:currentFilter.id,pageNumber:pageNumber}], queryFn:fetchServiceItems, enabled:paseto !== ''}) const res = serviceItemsQuery.data && serviceItemsQuery.data; - const servicesData = res && res.data - const totalLength = res && res.dataLength; + const servicesData = res?.data + const totalLength = res?.dataLength; - const allServiceItemsQuery = useQuery({queryKey:['all-serviceItems',{currentService: currentService.id}], queryFn:fetchAllServiceItems, enabled:paseto !== '', staleTime:Infinity}) - const allServiceItemsLength = allServiceItemsQuery.data && allServiceItemsQuery.data.dataLength; + // const allServiceItemsQuery = useQuery({queryKey:['all-serviceItems',{currentService: currentService.id}], queryFn:fetchAllServiceItems, enabled:paseto !== '', staleTime:Infinity}) + // const allServiceItemsLength = allServiceItemsQuery.data && allServiceItemsQuery.data.dataLength; @@ -167,8 +168,8 @@ export default function ServiceItemsView(){ method:'patch', url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/service-items`, data:{ - key:'status', - value: '1', + // key:'status', + status: '1', id: record.id }, headers:{ @@ -201,7 +202,7 @@ export default function ServiceItemsView(){
- {record.name} + {record?.name}
) @@ -214,7 +215,7 @@ export default function ServiceItemsView(){ width:'120px', render:(_,record)=>{ const type = record.serviceItemType[0] - return {type.name} + return {type?.name} } }, { @@ -249,7 +250,7 @@ export default function ServiceItemsView(){ key: 'customDates', width:'150px', render: (_,record)=>{ - const customDatesLength = record.availability.length + const customDatesLength = record?.availability?.length return {`${customDatesLength}`} } }, @@ -259,7 +260,7 @@ export default function ServiceItemsView(){ key: 'createdAt', width:'120px', render: (_,record)=>{ - const date = dayjs(record.createdAt).format('MMM DD, YYYY') + const date = dayjs(record?.createdAt).format('MMM DD, YYYY') return( {date} ) @@ -284,9 +285,10 @@ export default function ServiceItemsView(){ return (
- { servicesData && allServiceItemsLength === 0 + { servicesData ? null - :
+ : +
@@ -307,13 +309,16 @@ export default function ServiceItemsView(){ {/* } menu={{ items, onClick: (item)=>onLaunchButtonClick(item) }}>Launch New ... */}
-
} - { +
+ } + + {/* { servicesData && allServiceItemsLength === 0 ? } menu={{ items, onClick: (item)=>onLaunchButtonClick(item) }}>Launch New ... - :
record.id} @@ -328,7 +333,7 @@ export default function ServiceItemsView(){ onChange={handleChange} dataSource={servicesData} /> - } + {/* } */} { isDrawerOpen @@ -402,8 +407,8 @@ const deleteDataHandler = async(record:ServiceItem)=>{ url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/service-items`, data: { id:record.id, - key:'status', - value: '0' + // key:'status', + status: '0' }, headers:{ "Authorization": paseto diff --git a/components/ServicesPage/EditServiceForm/EditServiceForm.tsx b/components/ServicesPage/EditServiceForm/EditServiceForm.tsx index 3bd75cf7..a1bf9285 100644 --- a/components/ServicesPage/EditServiceForm/EditServiceForm.tsx +++ b/components/ServicesPage/EditServiceForm/EditServiceForm.tsx @@ -50,8 +50,8 @@ interface EditableProp{ function onFinish(updatedItem:Service){ const payload = { - key:'name', - value: updatedItem.name, + // key:'name', + name: updatedItem.name, id: selectedRecord.id } const updatedRecord = { @@ -349,8 +349,8 @@ interface EditableProp{ function onFinish(field:any){ const payload = { - key:'contact_number', - value: field.contactNumber, + // key:'contact_number', + contactNumber: field.contactNumber, id: selectedRecord.id } console.log(payload) @@ -435,8 +435,8 @@ interface EditableProp{ function onFinish(updatedItem:Service){ const payload = { - key:'currency', - value: updatedItem.currency, + // key:'currency', + currency: updatedItem.currency, id: selectedRecord.id } const updatedRecord = { @@ -561,8 +561,8 @@ interface EditableProp{ console.log(logoHash) const payload = { - key:'logo_image_hash', - value: logoHash, + // key:'logo_image_hash', + logoImageHash: logoHash, id: selectedRecord.id } mutation.mutate(payload) @@ -679,8 +679,8 @@ interface EditableProp{ console.log(coverImageHash) const payload = { - key:'cover_image_hash', - value: coverImageHash, + // key:'cover_image_hash', + coverImageHash: coverImageHash, orgId: selectedRecord.id } setUpdatedCoverImageHash(coverImageHash) diff --git a/components/ServicesPage/ServicesView/ServicesView.tsx b/components/ServicesPage/ServicesView/ServicesView.tsx index 109c83dc..9730d85c 100644 --- a/components/ServicesPage/ServicesView/ServicesView.tsx +++ b/components/ServicesPage/ServicesView/ServicesView.tsx @@ -58,20 +58,20 @@ function VenuesTable(){ const urlPrefix = useUrlPrefix() - async function fetchAllServices(){ - const res = await axios({ - method:'get', - //@ts-ignore - url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/services?orgId=${currentOrg.orgId}&pageNumber=${pageNumber}&pageSize=10`, - - headers:{ - "Authorization": paseto - } - }) - - return res.data; + // async function fetchAllServices(){ + // const res = await axios({ + // method:'get', + // //@ts-ignore + // url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/services?orgId=${currentOrg.orgId}&pageNumber=${pageNumber}&pageSize=10`, + + // headers:{ + // "Authorization": paseto + // } + // }) + + // return res.data; - } + // } async function fetchServices(){ const res = await axios({ @@ -93,8 +93,8 @@ function VenuesTable(){ method:'patch', url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/services`, data:{ - key:'status', - value: '1', + // key:'status', + status: '1', id: record.id }, headers:{ @@ -124,8 +124,8 @@ function VenuesTable(){ const totalLength = servicesQuery.data && servicesQuery.data.dataLength; // @ts-ignore - const allServicesQuery = useQuery({queryKey:['all-services',{currentOrg: currentOrg.orgId}], queryFn:fetchAllServices, enabled: paseto !== '', staleTime:Infinity}) - const allServicesLength = allServicesQuery.data && allServicesQuery.data.dataLength; + // const allServicesQuery = useQuery({queryKey:['all-services',{currentOrg: currentOrg.orgId}], queryFn:fetchAllServices, enabled: paseto !== '', staleTime:Infinity}) + // const allServicesLength = allServicesQuery.data && allServicesQuery.data.dataLength; @@ -282,9 +282,10 @@ function gotoServiceItemsPage(service:Service){
Venues
- {allServicesQuery.data && allServicesLength === 0 + {/* {allServicesQuery.data && allServicesLength === 0 ? null - :
+ : */} +
{/* filters */} @@ -304,14 +305,15 @@ function gotoServiceItemsPage(service:Service){
- } + {/* } */} - { + {/* { allServicesQuery.data && allServicesLength === 0 ? } menu={{ items, onClick: (item)=>onLaunchButtonClick(item) }}>Launch New ... - :
`Total: ${total} items`, }} /> - } + {/* } */} { isDrawerOpen @@ -405,8 +407,8 @@ const deleteDataHandler = async(record:Service)=>{ url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/services`, data: { id:record.id, - key:'status', - value: "0" + // key:'status', + status: "0" }, headers:{ "Authorization": paseto diff --git a/components/StaffPage/index.tsx b/components/StaffPage/index.tsx index 435f8d2f..f89486f0 100644 --- a/components/StaffPage/index.tsx +++ b/components/StaffPage/index.tsx @@ -43,17 +43,17 @@ export default function StaffView(){ const urlPrefix = useUrlPrefix() - async function fetchAllStaff(){ - const res = await axios({ - method:'get', - url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/staff/service?serviceId=${currentService.id}&pageNumber=${pageNumber}&pageSize=10`, - headers:{ - "Authorization": paseto - } - }) + // async function fetchAllStaff(){ + // const res = await axios({ + // method:'get', + // url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/staff/service?serviceId=${currentService.id}&pageNumber=${pageNumber}&pageSize=10`, + // headers:{ + // "Authorization": paseto + // } + // }) - return res.data; - } + // return res.data; + // } async function fetchStaff(){ const res = await axios({ method:'get', @@ -104,8 +104,8 @@ export default function StaffView(){ const data = staffQuery.data && staffQuery.data.data const totalLength = staffQuery.data && staffQuery.data.dataLength; - const allStaffQuery = useQuery({queryKey:['all-staff'], queryFn:fetchAllStaff, enabled:paseto !== '', staleTime:Infinity}) - const allStaffLength = allStaffQuery.data && allStaffQuery.data.dataLength + // const allStaffQuery = useQuery({queryKey:['all-staff'], queryFn:fetchAllStaff, enabled:paseto !== '', staleTime:Infinity}) + // const allStaffLength = allStaffQuery.data && allStaffQuery.data.dataLength @@ -212,7 +212,8 @@ export default function StaffView(){ return (
- {data && allStaffLength === 0 ? null : + {/* {data && allStaffLength === 0 ? null : */} +
@@ -236,12 +237,13 @@ export default function StaffView(){
- } + {/* } */} - { + {/* { data && allStaffLength === 0 ? setShowForm(true)}/> - :
record.id} @@ -256,7 +258,7 @@ export default function StaffView(){ showTotal:(total) => `Total: ${total} items`, }} /> - } + {/* } */} { @@ -330,7 +332,7 @@ const createData = useMutation(createDataHandler,{ }, onSettled:()=>{ queryClient.invalidateQueries(['staff',currentService.id]) - queryClient.invalidateQueries(['all-staff']) + // queryClient.invalidateQueries(['all-staff']) } }) @@ -546,8 +548,8 @@ export function EditableRadio({id, options, selectedItem, fieldName, currentFiel function onFinish(formData:any){ const payload = { - key:fieldKey, - value: formData[fieldName], + // key:fieldKey, + fieldKey: formData[fieldName], id: id } mutation.mutate(payload) diff --git a/hooks/useFetchUserOrgs.ts b/hooks/useFetchUserOrgs.ts index 78dde2b6..6b6938d5 100644 --- a/hooks/useFetchUserOrgs.ts +++ b/hooks/useFetchUserOrgs.ts @@ -23,7 +23,7 @@ export default function useFetchUserOrgs(){ }, []) const orgsQuery = useQuery(['orgs'],async()=>{ - const {data} = await axios.get(`${process.env.NEXT_PUBLIC_NEW_API_URL}/admin/orgs?key=status&value=1&pageNumber=1&pageSize=30&key2=created_by`,{ + const {data} = await axios.get(`${process.env.NEXT_PUBLIC_NEW_API_URL}/admin/orgs?tatus=1&pageNumber=1&pageSize=30&key2=created_by`,{ headers:{ //@ts-ignore "Authorization": paseto diff --git a/pages/manager/bookings/communities.tsx b/pages/manager/bookings/communities.tsx index f762f5fe..5a619390 100644 --- a/pages/manager/bookings/communities.tsx +++ b/pages/manager/bookings/communities.tsx @@ -45,7 +45,7 @@ export default function CommunityBookings(){ async function fetchBookings(){ const res = await axios({ method:'get', - url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/bookings/communities?pageNumber=${pageNumber}&pageSize=${pageSize}&key='id'&value=${''}`, + url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/bookings/communities?pageNumber=${pageNumber}&pageSize=${pageSize}`, headers:{ "Authorization": paseto } diff --git a/pages/manager/organizations/new.tsx b/pages/manager/organizations/new.tsx index 15ff6543..4ec502b1 100644 --- a/pages/manager/organizations/new.tsx +++ b/pages/manager/organizations/new.tsx @@ -197,8 +197,8 @@ export default function NewOrgForm(){ }) // change status const orgStatusPayload = { - key:'status', - value: '1', // 0 means de-activated in db + // key:'status', + status: '1', // 0 means de-activated in db id: orgId } orgStatusMutation.mutate(orgStatusPayload) diff --git a/pages/organizations/communities/index.tsx b/pages/organizations/communities/index.tsx index 984df92a..1c7683d2 100644 --- a/pages/organizations/communities/index.tsx +++ b/pages/organizations/communities/index.tsx @@ -88,8 +88,8 @@ function Communities(){ method:'patch', url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/community`, data:{ - key:'status', - value: '1', + // key:'status', + status: '1', id: record.id }, headers:{ @@ -372,8 +372,8 @@ const deleteDataHandler = async(record:Community)=>{ url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/community`, data: { id:record.id, - key:'status', - value: "0" + // key:'status', + status: "0" }, headers:{ "Authorization": paseto @@ -469,8 +469,8 @@ export function EditableDescription({selectedRecord}:EditableProp){ function onFinish(updatedItem:any){ const payload = { - key:'description', - value: updatedItem.description, + // key:'description', + description: updatedItem.description, id: selectedRecord.id } const updatedRecord = { @@ -577,8 +577,8 @@ export function EditablePrice({selectedRecord}:EditableProp){ function onFinish(updatedItem:any){ const payload = { - key:'price', - value: String(updatedItem.price*100), + // key:'price', + price: String(updatedItem.price*100), id: selectedRecord.id } recordMutation.mutate(payload) @@ -680,8 +680,8 @@ export function EditableName({selectedRecord}:EditableProp){ function onFinish(updatedItem:any){ const payload = { - key:'name', - value: `Key to: ${updatedItem.name}`, + // key:'name', + name: `Key to: ${updatedItem.name}`, id: selectedRecord.id } diff --git a/pages/organizations/events/index.tsx b/pages/organizations/events/index.tsx index ef205780..bd23f5d1 100644 --- a/pages/organizations/events/index.tsx +++ b/pages/organizations/events/index.tsx @@ -96,8 +96,8 @@ function Events(){ method:'patch', url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/events`, data:{ - key:'status', - value: '1', + // key:'status', + status: '1', id: record.id }, headers:{ @@ -431,8 +431,8 @@ const deleteDataHandler = async(record:Event)=>{ url:`${process.env.NEXT_PUBLIC_NEW_API_URL}/${urlPrefix}/events`, data: { id:record.id, - key:'status', - value: "0" + // key:'status', + status: "0" }, headers:{ "Authorization": paseto @@ -553,8 +553,8 @@ export function EditableDescription({selectedRecord}:EditableProp){ function onFinish(updatedItem:any){ const payload = { - key:'description', - value: updatedItem.description, + // key:'description', + description: updatedItem.description, id: selectedRecord.id } const updatedRecord = { @@ -662,8 +662,8 @@ export function EditablePrice({selectedRecord}:EditableProp){ function onFinish(updatedItem:any){ const payload = { - key:'price', - value: String(updatedItem.price*100), + // key:'price', + price: String(updatedItem.price*100), id: selectedRecord.id } recordMutation.mutate(payload) @@ -763,8 +763,8 @@ export function EditableName({selectedRecord}:EditableProp){ function onFinish(updatedItem:any){ const payload = { - key:'name', - value: updatedItem.name, + // key:'name', + name: updatedItem.name, id: selectedRecord.id } @@ -881,8 +881,8 @@ export function EditableLogoImage({selectedRecord}:EditableProp){ const payload = { - key:'cover_image_hash', - value: logoHash, + // key:'cover_image_hash', + coverImageHash: logoHash, id: selectedRecord.id } mutation.mutate(payload) @@ -992,8 +992,8 @@ export function EditableDate({selectedRecord}:EditableProp){ function onFinish(updatedItem:any){ const payload = { - key:'start_time', - value: updatedItem.startTime, + // key:'start_time', + startTime: updatedItem.startTime, id: selectedRecord.id } @@ -1102,8 +1102,8 @@ export function EditableTimeZone({selectedRecord}:EditableProp){ function onFinish(updatedItem:any){ const payload = { - key:'timeZone', - value: updatedItem.timeZone, + // key:'timeZone', + timeZone: updatedItem.timeZone, id: selectedRecord.id } @@ -1223,8 +1223,8 @@ export function EditableTickets({selectedRecord}:EditableProp){ function onFinish(updatedItem:any){ const payload = { - key:'totalTickets', - value: updatedItem.totalTickets, + // key:'totalTickets', + totalTickets: updatedItem.totalTickets, id: selectedRecord.id } @@ -1328,8 +1328,8 @@ export function EditableDuration({selectedRecord}:EditableProp){ function onFinish(updatedItem:any){ const payload = { - key:'duration', - value: String(updatedItem.duration*60), + // key:'duration', + duration: String(updatedItem.duration*60), id: selectedRecord.id } diff --git a/pages/organizations/events/staff/index.tsx b/pages/organizations/events/staff/index.tsx index d470b9d1..42ea9db8 100644 --- a/pages/organizations/events/staff/index.tsx +++ b/pages/organizations/events/staff/index.tsx @@ -544,8 +544,8 @@ export function EditableRadio({id, options, selectedItem, fieldName, currentFiel function onFinish(formData:any){ const payload = { - key:fieldKey, - value: formData[fieldName], + // key:fieldKey, + fieldKey: formData[fieldName], id: id } mutation.mutate(payload)