Skip to content

Commit

Permalink
fix: remove hardcoded locales
Browse files Browse the repository at this point in the history
  • Loading branch information
onehassan committed Aug 29, 2023
1 parent 1b7dcf2 commit 6d0a126
Show file tree
Hide file tree
Showing 4 changed files with 396 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ query GetAuthenticationSettings($appId: uuid!) {
default
rating
}
locale {
allowed
default
}
}
version
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { copy } from '@/utils/copy';
import { getServerError } from '@/utils/getServerError';
import {
RemoteAppGetUsersDocument,
useGetProjectLocalesQuery,
useGetRolesPermissionsQuery,
useUpdateRemoteAppUserMutation,
} from '@/utils/__generated__/graphql';
Expand Down Expand Up @@ -146,6 +147,14 @@ export default function EditUserForm({
dataRoles?.config?.auth?.user?.roles?.allowed,
);

const { data } = useGetProjectLocalesQuery({
variables: {
appId: currentProject?.id,
},
});

const allowedLocales = data?.config?.auth?.user?.locale?.allowed || [];

/**
* This will change the `disabled` field in the user to its opposite.
* If the user is disabled, it will be enabled and vice versa.
Expand Down Expand Up @@ -374,12 +383,11 @@ export default function EditUserForm({
error={!!errors.locale}
helperText={errors?.locale?.message}
>
<Option key="en" value="en">
en
</Option>
<Option key="fr" value="fr">
fr
</Option>
{allowedLocales.map((locale) => (
<Option key={locale} value={locale}>
{locale}
</Option>
))}
</ControlledSelect>
</Box>
<Box
Expand Down
12 changes: 12 additions & 0 deletions dashboard/src/gql/app/getProjectLocales.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
query getProjectLocales($appId: uuid!) {
config(appID: $appId, resolve: true) {
auth {
user {
locale {
allowed
default
}
}
}
}
}
Loading

0 comments on commit 6d0a126

Please sign in to comment.