Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/choose-data-s…
Browse files Browse the repository at this point in the history
…ource-to-update-choropleth
  • Loading branch information
ev-sc committed Dec 11, 2024
2 parents 84e42e0 + a7f56e6 commit e06f1f8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 29 deletions.
5 changes: 2 additions & 3 deletions hub/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1596,11 +1596,10 @@ async def create_import_record(record):

async def create_import_record(record):
structured_data = get_update_data(record)
wards = Area.objects.filter(
ward = await Area.objects.filter(
area_type__code="WD23",
gss=self.get_record_field(record, self.geography_column),
)
ward = await sync_to_async(wards.first)()
).afirst()
coord = ward.point.centroid
postcode_data: PostcodesIOResult = await loaders[
"postcodesIOFromPoint"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ type FormInputs = CreateExternalDataSourceInput &
}

export default function Page({
params: { externalDataProviderType },
params: { externalDataSourceType },
}: {
params: { externalDataProviderType: keyof CreateExternalDataSourceInput }
params: { externalDataSourceType: keyof CreateExternalDataSourceInput }
}) {
const orgId = useAtomValue(currentOrganisationIdAtom)
const router = useRouter()
Expand Down Expand Up @@ -158,13 +158,6 @@ export default function Page({
const form = useForm<FormInputs>({
defaultValues: {
...defaultValues,
// REMOVE
airtable: {
baseId: 'appZ9UYXvsIrTbYQs',
tableId: 'tblGrH67nWM4ROgwf',
apiKey:
'patpg0NikxPjHb59O.8b72db8273cc25526b582e47efe0bba18882e679aec15ea3c854f59c8af3263c',
},
} as FormInputs,
})

Expand Down Expand Up @@ -436,13 +429,13 @@ export default function Page({
}, [airtableUrl])

async function submitTestConnection(formData: FormInputs) {
if (!formData[externalDataProviderType]) {
if (!formData[externalDataSourceType]) {
throw Error('Need some CRM connection details to proceed!')
}

// To avoid mutation of the form data
const genericCRMData = Object.assign({}, formData)
const CRMSpecificData = formData[externalDataProviderType]
const CRMSpecificData = formData[externalDataSourceType]

// Remove specific CRM data from the generic data
// TODO: make this less fragile. Currently it assumes any nested
Expand All @@ -454,7 +447,7 @@ export default function Page({
}

const input: TestDataSourceQueryVariables['input'] = {
[externalDataProviderType]: {
[externalDataSourceType]: {
...genericCRMData,
...CRMSpecificData,
},
Expand Down Expand Up @@ -484,12 +477,12 @@ export default function Page({
}

async function submitCreateSource(formData: FormInputs) {
if (!formData[externalDataProviderType]) {
if (!formData[externalDataSourceType]) {
throw Error('Need some CRM connection details to proceed!')
}
// To avoid mutation of the form data
const genericCRMData = Object.assign({}, formData)
let CRMSpecificData = formData[externalDataProviderType]
let CRMSpecificData = formData[externalDataSourceType]

// Remove specific CRM data from the generic data
// TODO: make this less fragile. Currently it assumes any nested
Expand All @@ -501,7 +494,7 @@ export default function Page({
}

let input: CreateExternalDataSourceInput = {
[externalDataProviderType]: {
[externalDataSourceType]: {
...genericCRMData,
...CRMSpecificData,
organisation: { set: orgId },
Expand Down Expand Up @@ -769,15 +762,15 @@ export default function Page({
<h1 className="text-hLg">Testing connection...</h1>
<p className="text-meepGray-400 max-w-lg">
Please wait whilst we try to connect to your{' '}
{formatCrmNames(externalDataProviderType || 'CRM')} using the
{formatCrmNames(externalDataSourceType || 'CRM')} using the
information you provided
</p>
<LoadingIcon />
</div>
)
}

if (externalDataProviderType === 'airtable') {
if (externalDataSourceType === 'airtable') {
return (
<div className="space-y-7">
<header>
Expand Down Expand Up @@ -926,7 +919,7 @@ export default function Page({
)
}

if (externalDataProviderType === 'mailchimp') {
if (externalDataSourceType === 'mailchimp') {
return (
<div className="space-y-7">
<header>
Expand Down Expand Up @@ -1017,7 +1010,7 @@ export default function Page({
</div>
)
}
if (externalDataProviderType === 'actionnetwork') {
if (externalDataSourceType === 'actionnetwork') {
const groupSlug = form.watch('actionnetwork.groupSlug')
const actionNetworkApiUrl = groupSlug
? `https://actionnetwork.org/groups/${groupSlug}/apis`
Expand Down Expand Up @@ -1116,7 +1109,7 @@ export default function Page({
</div>
)
}
if (externalDataProviderType === 'editablegooglesheets') {
if (externalDataSourceType === 'editablegooglesheets') {
const hasOauthParams = searchParams.get('state') && searchParams.get('code')
// The presence of the params and absence of an oauthCredentialsResult
// means the query has either not yet been sent, or is in progress.
Expand Down Expand Up @@ -1290,7 +1283,7 @@ export default function Page({
)
}

if (externalDataProviderType === 'tickettailor') {
if (externalDataSourceType === 'tickettailor') {
return (
<div className="space-y-7">
<header>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ const GET_UPDATE_CONFIG = gql`
`

export default function Page({
params: { externalDataProviderId },
params: { externalDataSourceId },
}: {
params: { externalDataProviderId: string }
params: { externalDataSourceId: string }
}) {
const router = useRouter()
const context = useContext(CreateAutoUpdateFormContext)
Expand All @@ -65,7 +65,7 @@ export default function Page({
AutoUpdateCreationReviewQueryVariables
>(GET_UPDATE_CONFIG, {
variables: {
ID: externalDataProviderId,
ID: externalDataSourceId,
},
})

Expand Down Expand Up @@ -145,7 +145,7 @@ export default function Page({
</div>
<div>
<TriggerUpdateButton
id={externalDataProviderId}
id={externalDataSourceId}
className="w-full"
variant="reverse"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function ReportSidebarLeft() {
Configuration
</TabsTrigger>
</HoverCardTrigger>
<HoverCardContent align="start">
<HoverCardContent align="start" className="font-normal">
Click on "Configuration" to visualise your data
</HoverCardContent>
</HoverCard>
Expand Down

0 comments on commit e06f1f8

Please sign in to comment.