hide sites inputs on clients

This commit is contained in:
miloschwartz
2025-11-05 10:37:52 -08:00
parent 2274404324
commit c73f8c88f7
2 changed files with 70 additions and 106 deletions

View File

@@ -75,14 +75,14 @@ export default function GeneralPage() {
const res = await api.get<AxiosResponse<ListSitesResponse>>(
`/org/${client?.orgId}/sites/`
);
const availableSites = res.data.data.sites
.filter((s) => s.type === "newt" && s.subnet)
.map((site) => ({
id: site.siteId.toString(),
text: site.name
}));
setSites(availableSites);
// Filter sites to only include those assigned to the client
@@ -173,39 +173,6 @@ export default function GeneralPage() {
</FormItem>
)}
/>
<FormField
control={form.control}
name="siteIds"
render={(field) => (
<FormItem className="flex flex-col">
<FormLabel>{t("sites")}</FormLabel>
<TagInput
{...field}
activeTagIndex={activeSitesTagIndex}
setActiveTagIndex={setActiveSitesTagIndex}
placeholder={t("selectSites")}
size="sm"
tags={form.getValues().siteIds}
setTags={(newTags) => {
form.setValue(
"siteIds",
newTags as [Tag, ...Tag[]]
);
}}
enableAutocomplete={true}
autocompleteOptions={sites}
allowDuplicates={false}
restrictTagsToAutocompleteOptions={true}
sortTags={true}
/>
<FormDescription>
{t("sitesDescription")}
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
</form>
</Form>
</SettingsSectionForm>
@@ -224,4 +191,4 @@ export default function GeneralPage() {
</SettingsSection>
</SettingsContainer>
);
}
}

View File

@@ -99,10 +99,7 @@ export default function Page() {
id: z.string(),
text: z.string()
})
)
.refine((val) => val.length > 0, {
message: t("siteRequired")
}),
),
subnet: z.string().ip().min(1, {
message: t("subnetRequired")
})
@@ -293,18 +290,18 @@ export default function Page() {
// Fetch available sites
const res = await api.get<AxiosResponse<ListSitesResponse>>(
`/org/${orgId}/sites/`
);
const sites = res.data.data.sites.filter(
(s) => s.type === "newt" && s.subnet
);
setSites(
sites.map((site) => ({
id: site.siteId.toString(),
text: site.name
}))
);
// const res = await api.get<AxiosResponse<ListSitesResponse>>(
// `/org/${orgId}/sites/`
// );
// const sites = res.data.data.sites.filter(
// (s) => s.type === "newt" && s.subnet
// );
// setSites(
// sites.map((site) => ({
// id: site.siteId.toString(),
// text: site.name
// }))
// );
let olmVersion = "latest";
@@ -468,60 +465,60 @@ export default function Page() {
)}
/>
<FormField
control={form.control}
name="siteIds"
render={(field) => (
<FormItem className="flex flex-col">
<FormLabel>
{t("sites")}
</FormLabel>
<TagInput
{...field}
activeTagIndex={
activeSitesTagIndex
}
setActiveTagIndex={
setActiveSitesTagIndex
}
placeholder={t("selectSites")}
size="sm"
tags={
form.getValues()
.siteIds
}
setTags={(
olmags
) => {
form.setValue(
"siteIds",
olmags as [
Tag,
...Tag[]
]
);
}}
enableAutocomplete={
true
}
autocompleteOptions={
sites
}
allowDuplicates={
false
}
restrictTagsToAutocompleteOptions={
true
}
sortTags={true}
/>
<FormDescription>
{t("sitesDescription")}
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
{/* <FormField */}
{/* control={form.control} */}
{/* name="siteIds" */}
{/* render={(field) => ( */}
{/* <FormItem className="flex flex-col"> */}
{/* <FormLabel> */}
{/* {t("sites")} */}
{/* </FormLabel> */}
{/* <TagInput */}
{/* {...field} */}
{/* activeTagIndex={ */}
{/* activeSitesTagIndex */}
{/* } */}
{/* setActiveTagIndex={ */}
{/* setActiveSitesTagIndex */}
{/* } */}
{/* placeholder={t("selectSites")} */}
{/* size="sm" */}
{/* tags={ */}
{/* form.getValues() */}
{/* .siteIds */}
{/* } */}
{/* setTags={( */}
{/* olmags */}
{/* ) => { */}
{/* form.setValue( */}
{/* "siteIds", */}
{/* olmags as [ */}
{/* Tag, */}
{/* ...Tag[] */}
{/* ] */}
{/* ); */}
{/* }} */}
{/* enableAutocomplete={ */}
{/* true */}
{/* } */}
{/* autocompleteOptions={ */}
{/* sites */}
{/* } */}
{/* allowDuplicates={ */}
{/* false */}
{/* } */}
{/* restrictTagsToAutocompleteOptions={ */}
{/* true */}
{/* } */}
{/* sortTags={true} */}
{/* /> */}
{/* <FormDescription> */}
{/* {t("sitesDescription")} */}
{/* </FormDescription> */}
{/* <FormMessage /> */}
{/* </FormItem> */}
{/* )} */}
{/* /> */}
</form>
</Form>
</SettingsSectionForm>