Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
chore: follow GraphQL schema updates (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
rot1024 committed Apr 20, 2022
1 parent 7182521 commit 8d9e75d
Show file tree
Hide file tree
Showing 14 changed files with 522 additions and 711 deletions.
8 changes: 1 addition & 7 deletions codegen.yml
Expand Up @@ -19,13 +19,7 @@ generates:
Cursor: string
URL: string
Lang: string
TranslatedString: '{ [lang in string]?: string } | null'
PluginID: string
PluginExtensionID: string
PropertySchemaID: string
PropertySchemaGroupID: string
PropertySchemaFieldID: string
DatasetSchemaFieldID: string
TranslatedString: "{ [lang in string]?: string } | null"
./src/gql/graphql.schema.json:
plugins:
- introspection
Expand Down
Expand Up @@ -8,18 +8,18 @@ import Text from "@reearth/components/atoms/Text";
import TextBox from "@reearth/components/atoms/TextBox";
import { styled, useTheme } from "@reearth/theme";

type Props = {
export type User = {
id: string;
name: string;
email: string;
};

export type Props = {
active: boolean;
close: () => void;
searchedUser?: {
userId: string;
userName: string;
userEmail: string;
};
searchedUser?: User;
searchUser: (nameOrEmail: string) => void;
changeSearchedUser: (
user: { userId: string; userName: string; userEmail: string } | undefined,
) => void;
changeSearchedUser: (user: User | undefined) => void;
addMembersToTeam?: (userIds: string[]) => Promise<void>;
};

Expand All @@ -34,7 +34,7 @@ const AddMemberModal: React.FC<Props> = ({
const intl = useIntl();
const theme = useTheme();

const [users, setUsers] = useState<{ userId: string; userName: string; userEmail: string }[]>([]);
const [users, setUsers] = useState<User[]>([]);
const [nameOrEmail, setNameOrEmail] = useState("");

const handleChange = useCallback(
Expand All @@ -46,7 +46,7 @@ const AddMemberModal: React.FC<Props> = ({
);

useEffect(() => {
if (searchedUser && !users.find(user => user.userId === searchedUser.userId)) {
if (searchedUser && !users.find(user => user.id === searchedUser.id)) {
setUsers([...users, searchedUser]);
setNameOrEmail("");
searchUser("");
Expand All @@ -56,7 +56,7 @@ const AddMemberModal: React.FC<Props> = ({
const removeUser = useCallback(
(userId: string) => {
changeSearchedUser(undefined);
setUsers(users => users.filter(user => user.userId !== userId));
setUsers(users => users.filter(user => user.id !== userId));
},
[setUsers, changeSearchedUser],
);
Expand All @@ -69,7 +69,7 @@ const AddMemberModal: React.FC<Props> = ({
}, [setUsers, setNameOrEmail, changeSearchedUser, close]);

const add = useCallback(async () => {
await addMembersToTeam?.(users.map(({ userId }) => userId));
await addMembersToTeam?.(users.map(({ id }) => id));
changeSearchedUser(undefined);
setUsers([]);
setNameOrEmail("");
Expand Down Expand Up @@ -107,15 +107,15 @@ const AddMemberModal: React.FC<Props> = ({
onChange={handleChange}
/>
<UserList>
{users.map(({ userId, userName, userEmail }) => (
<UserListItem key={userId}>
{users.map(({ id, name, email }) => (
<UserListItem key={id}>
<UserIdentity>
<Text size="m">{userName}</Text>
<Text size="m">{name}</Text>
<Text size="s" color={theme.infoBox.weakText}>
{userEmail}
{email}
</Text>
</UserIdentity>
<RemoveIcon icon="cancel" onClick={() => removeUser(userId)} />
<RemoveIcon icon="cancel" onClick={() => removeUser(id)} />
</UserListItem>
))}
</UserList>
Expand Down
Expand Up @@ -3,23 +3,23 @@ import { useIntl } from "react-intl";

import Button from "@reearth/components/atoms/Button";
import Section from "@reearth/components/molecules/Settings/Section";
import AddMemberModal from "@reearth/components/molecules/Settings/Workspace/AddMemberModal";
import AddMemberModal, {
User as UserType,
} from "@reearth/components/molecules/Settings/Workspace/AddMemberModal";
import MemberList from "@reearth/components/molecules/Settings/Workspace/MemberList";
import MemberListItem, {
Role,
} from "@reearth/components/molecules/Settings/Workspace/MemberListItem";
import { styled } from "@reearth/theme";

type Me = {
export type Me = {
id?: string;
};

export type User = UserType;

type TeamMember = {
user?: {
id: string;
name: string;
email: string;
} | null;
user?: User;
userId: string;
role: Role;
};
Expand All @@ -28,16 +28,10 @@ type Props = {
me?: Me;
owner?: boolean;
members?: TeamMember[];
searchedUser?: {
userId: string;
userName: string;
userEmail: string;
};
searchedUser?: User;
personal?: boolean;
searchUser: (nameOrEmail: string) => void;
changeSearchedUser: (
user: { userId: string; userName: string; userEmail: string } | undefined,
) => void;
changeSearchedUser: (user: User | undefined) => void;
addMembersToTeam: (userIds: string[]) => Promise<void>;
updateMemberOfTeam: (userId: string, role: Role) => void;
removeMemberFromTeam: (userId: string) => void;
Expand Down
16 changes: 8 additions & 8 deletions src/components/organisms/EarthEditor/CanvasArea/queries.ts
Expand Up @@ -163,7 +163,7 @@ const fragments = gql`
`;

export const GET_LAYERS = gql`
query GetLayers($sceneId: ID!, $lang: String) {
query GetLayers($sceneId: ID!, $lang: Lang) {
node(id: $sceneId, type: SCENE) {
id
... on Scene {
Expand All @@ -179,7 +179,7 @@ export const GET_LAYERS = gql`
`;

export const GET_EARTH_WIDGETS = gql`
query GetEarthWidgets($sceneId: ID!, $lang: String) {
query GetEarthWidgets($sceneId: ID!, $lang: Lang) {
node(id: $sceneId, type: SCENE) {
id
... on Scene {
Expand Down Expand Up @@ -285,7 +285,7 @@ export const UPDATE_WIDGET_ALIGN_SYSTEM = gql`
`;

export const MOVE_INFOBOX_FIELD = gql`
mutation moveInfoboxField($layerId: ID!, $infoboxFieldId: ID!, $index: Int!, $lang: String) {
mutation moveInfoboxField($layerId: ID!, $infoboxFieldId: ID!, $index: Int!, $lang: Lang) {
moveInfoboxField(input: { layerId: $layerId, infoboxFieldId: $infoboxFieldId, index: $index }) {
layer {
id
Expand All @@ -298,7 +298,7 @@ export const MOVE_INFOBOX_FIELD = gql`
`;

export const REMOVE_INFOBOX_FIELD = gql`
mutation removeInfoboxField($layerId: ID!, $infoboxFieldId: ID!, $lang: String) {
mutation removeInfoboxField($layerId: ID!, $infoboxFieldId: ID!, $lang: Lang) {
removeInfoboxField(input: { layerId: $layerId, infoboxFieldId: $infoboxFieldId }) {
layer {
id
Expand All @@ -311,7 +311,7 @@ export const REMOVE_INFOBOX_FIELD = gql`
`;

export const GET_BLOCKS = gql`
query getBlocks($sceneId: ID!, $lang: String) {
query getBlocks($sceneId: ID!, $lang: Lang) {
node(id: $sceneId, type: SCENE) {
id
... on Scene {
Expand All @@ -337,10 +337,10 @@ export const GET_BLOCKS = gql`
export const ADD_INFOBOX_FIELD = gql`
mutation addInfoboxField(
$layerId: ID!
$pluginId: PluginID!
$extensionId: PluginExtensionID!
$pluginId: ID!
$extensionId: ID!
$index: Int
$lang: String
$lang: Lang
) {
addInfoboxField(
input: { layerId: $layerId, pluginId: $pluginId, extensionId: $extensionId, index: $index }
Expand Down
Expand Up @@ -50,10 +50,10 @@ export const GET_INSTALLED_PLUGINS = gql`
export const ADD_LAYER_GROUP_FROM_DATASET_SCHEMA = gql`
mutation addLayerGroupFromDatasetSchema(
$parentLayerId: ID!
$pluginId: PluginID
$extensionId: PluginExtensionID
$pluginId: ID
$extensionId: ID
$datasetSchemaId: ID
$lang: String
$lang: Lang
) {
addLayerGroup(
input: {
Expand Down
6 changes: 3 additions & 3 deletions src/components/organisms/EarthEditor/OutlinePane/queries.ts
Expand Up @@ -163,7 +163,7 @@ export const ADD_LAYER_GROUP = gql`
`;

export const GET_WIDGETS = gql`
query GetWidgets($sceneId: ID!, $lang: String) {
query GetWidgets($sceneId: ID!, $lang: Lang) {
node(id: $sceneId, type: SCENE) {
id
... on Scene {
Expand Down Expand Up @@ -209,7 +209,7 @@ export const GET_WIDGETS = gql`
`;

export const GET_CLUSTERS = gql`
query GetClusters($sceneId: ID!, $lang: String) {
query GetClusters($sceneId: ID!, $lang: Lang) {
node(id: $sceneId, type: SCENE) {
id
... on Scene {
Expand All @@ -228,7 +228,7 @@ export const GET_CLUSTERS = gql`
`;

export const ADD_CLUSTER = gql`
mutation AddCluster($sceneId: ID!, $name: String!, $lang: String) {
mutation AddCluster($sceneId: ID!, $name: String!, $lang: Lang) {
addCluster(input: { sceneId: $sceneId, name: $name }) {
cluster {
id
Expand Down
Expand Up @@ -3,7 +3,7 @@ import { gql } from "@apollo/client";
import { layerFragment } from "@reearth/gql/fragments";

export const GET_PRIMITIVES = gql`
query GetPrimitives($sceneId: ID!, $lang: String) {
query GetPrimitives($sceneId: ID!, $lang: Lang) {
node(id: $sceneId, type: SCENE) {
id
... on Scene {
Expand All @@ -27,13 +27,13 @@ export const GET_PRIMITIVES = gql`
export const ADD_LAYER_ITEM_FROM_PRIMITIVE = gql`
mutation addLayerItemFromPrimitive(
$parentLayerId: ID!
$pluginId: PluginID!
$extensionId: PluginExtensionID!
$pluginId: ID!
$extensionId: ID!
$name: String
$lat: Float
$lng: Float
$index: Int
$lang: String
$lang: Lang
) {
addLayerItem(
input: {
Expand Down

0 comments on commit 8d9e75d

Please sign in to comment.