Skip to content

Commit

Permalink
Feat: added support for strapi native API response (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-sumi-k authored May 20, 2024
1 parent ba02f4e commit c4e0070
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
27 changes: 19 additions & 8 deletions admin/src/components/Input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,25 @@ const Tags = ({
const inputValue = (props.value && props.value.trim().toLowerCase()) || "";
const inputLength = inputValue.length;

let s = suggestions;

if (suggestions.length <= 0) {
let s = suggestions.data ? suggestions.data : suggestions;
if (suggestions <= 0) {
getSuggestions();
}

if (inputLength > 0) {
s = suggestions.filter((state) => {
return state.name.toLowerCase().slice(0, inputLength) === inputValue;
});
s = s.map((state) => {
const suggestionName = state.attributes
? state.attributes.name.toLowerCase()
: state.name.toLowerCase();

if (suggestionName.slice(0, inputLength) === inputValue) {
return {
id: state.id,
name: suggestionName,
};
}
return null
}).filter((ele) => ele !== null || ele != undefined);
}

return (
Expand All @@ -130,15 +139,17 @@ const Tags = ({
// GenericInput calls formatMessage and returns a string for the error
error={error}
hint={description && formatMessage(description)}
required={required}>
required={required}
>
<Flex
direction="column"
alignItems="stretch"
gap={1}
style={{
position: `relative`,
}}
ref={inputEle}>
ref={inputEle}
>
<FieldLabel action={labelAction}>{formatMessage(intlLabel)}</FieldLabel>
<Flex direction="column">
<TagsInput
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "strapi-plugin-tagsinput",
"version": "1.0.4",
"version": "1.0.5",
"description": "Tagsinput plugin for your strapi project",
"strapi": {
"name": "tagsinput",
Expand Down

0 comments on commit c4e0070

Please sign in to comment.