Starting physical address lookups
This commit is contained in:
10
README.md
10
README.md
@@ -6,6 +6,12 @@ Install Node 19+
|
|||||||
|
|
||||||
npm install --legacy-peer-deps
|
npm install --legacy-peer-deps
|
||||||
|
|
||||||
|
create database trigger_database;
|
||||||
|
grant all privileges on trigger_database.* TO 'triggeradmin'@'localhost' identified by 'trigger';
|
||||||
|
flush privileges;
|
||||||
|
|
||||||
|
import defaultDatabase.sql into your database server
|
||||||
|
|
||||||
To run:
|
To run:
|
||||||
npm run dev
|
npm run dev
|
||||||
|
|
||||||
@@ -16,11 +22,9 @@ npm run build
|
|||||||
Run with pm2:
|
Run with pm2:
|
||||||
npm install -g pm2
|
npm install -g pm2
|
||||||
sudo pm2 serve ./dist --no-daemon --spa --port 3000
|
sudo pm2 serve ./dist --no-daemon --spa --port 3000
|
||||||
|
sudo pm2 start server.cjs
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
- Image uploads for backgrounds
|
- Image uploads for backgrounds
|
||||||
|
|
||||||
- Create actions section
|
|
||||||
|
|
||||||
- Improve mobile
|
- Improve mobile
|
||||||
|
|||||||
@@ -41,6 +41,18 @@ export function PersonalizationColumns() {
|
|||||||
Cell: ({ renderedCellValue }) => renderedCellValue,
|
Cell: ({ renderedCellValue }) => renderedCellValue,
|
||||||
Header: ({ column }) => column.columnDef.header,
|
Header: ({ column }) => column.columnDef.header,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row: any) => {
|
||||||
|
if (row.physicalAddress) {
|
||||||
|
return `${row.physicalAddress}`;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
id: 'physicalAddress',
|
||||||
|
header: 'Address',
|
||||||
|
Cell: ({ renderedCellValue }) => renderedCellValue,
|
||||||
|
Header: ({ column }) => column.columnDef.header,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
export { useQueryAPI, useWeatherAPI, useMutationAPI } from './useAPI';
|
export { useQueryAPI, useWeatherAPI, useMutationAPI, useCensusAPI } from './useAPI';
|
||||||
export { useCommonHooks } from './useCommonHooks';
|
export { useCommonHooks } from './useCommonHooks';
|
||||||
|
|||||||
@@ -142,6 +142,23 @@ export function useWeatherAPI({ endpoint }: { endpoint: string }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useCensusAPI({ address }: { address: string }) {
|
||||||
|
const url = `https://geocoding.geo.census.gov/geocoder/locations/onelineaddress?address=${address?.replaceAll(' ', '+').replaceAll(',', '%2C').replaceAll('#', '%23')}&benchmark=4&format=json`;
|
||||||
|
|
||||||
|
const callEndpoint = async () => {
|
||||||
|
const response = await fetch(url);
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`${response.status} ${response.statusText}`);
|
||||||
|
}
|
||||||
|
return await response.json();
|
||||||
|
};
|
||||||
|
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ['GET', url],
|
||||||
|
queryFn: () => callEndpoint(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export function useFileUploadAPI() {
|
export function useFileUploadAPI() {
|
||||||
const callEndpoint = async (
|
const callEndpoint = async (
|
||||||
method: string,
|
method: string,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { appTheme } from 'contexts';
|
|||||||
import { useAtom } from 'jotai';
|
import { useAtom } from 'jotai';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
import { useQueryAPI, useWeatherAPI } from './useAPI';
|
import { useCensusAPI, useQueryAPI, useWeatherAPI } from './useAPI';
|
||||||
|
|
||||||
export function useCommonHooks() {
|
export function useCommonHooks() {
|
||||||
const isMobile = window.matchMedia('(max-width: 600px)').matches;
|
const isMobile = window.matchMedia('(max-width: 600px)').matches;
|
||||||
@@ -161,6 +161,18 @@ export function useCommonHooks() {
|
|||||||
}
|
}
|
||||||
}, [wolClients, wolClientsIsFetched]);
|
}, [wolClients, wolClientsIsFetched]);
|
||||||
|
|
||||||
|
const { data: locationData } = useCensusAPI({
|
||||||
|
address: personalData?.[0]?.physicalAddress,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [location, setLocation] = useState<any>([]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (locationData) {
|
||||||
|
setLocation(locationData);
|
||||||
|
}
|
||||||
|
}, [locationData]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isMobile,
|
isMobile,
|
||||||
theme,
|
theme,
|
||||||
@@ -222,6 +234,7 @@ export function useCommonHooks() {
|
|||||||
wolClientsIsFetched,
|
wolClientsIsFetched,
|
||||||
wolClientsIsFetching,
|
wolClientsIsFetching,
|
||||||
wolClientsIsLoading,
|
wolClientsIsLoading,
|
||||||
|
location,
|
||||||
notify,
|
notify,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user