Skip to content

Commit df17760

Browse files
author
crazycoder.io
committed
initial release
0 parents  commit df17760

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+3524
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

Readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# COMMT React Native SDK

Services/Axios.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import axios from "axios";
2+
3+
// Axios Create Instance
4+
const instance = axios.create({
5+
baseURL: "https://service.commt.co",
6+
timeout: 3000,
7+
});
8+
9+
// Axios Request Interceptor
10+
instance.interceptors.request.use(
11+
(request) => {
12+
return request;
13+
},
14+
(error) => {
15+
Promise.reject(error);
16+
},
17+
);
18+
19+
// Axios Response Interceptor
20+
instance.interceptors.response.use(
21+
(response) => {
22+
return response;
23+
},
24+
(error) => {
25+
Promise.reject(error);
26+
},
27+
);
28+
29+
export default instance;

Services/index.ts

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import { UserProps } from "../context/reducers/usersReducer";
2+
import axios from "./Axios";
3+
import { ConfigsProps } from "../context/reducers/appReducer";
4+
import { RoomProps } from "../context/reducers/roomsReducer";
5+
6+
interface AuthKeysProps {
7+
apiKey: string;
8+
subscriptionKey: string;
9+
}
10+
11+
export interface InitiateProps extends AuthKeysProps {
12+
tenantId: string;
13+
}
14+
15+
interface OnlineInfoProps extends AuthKeysProps {
16+
userIds: string;
17+
}
18+
19+
type OnlineInfoReturnProps = Pick<
20+
UserProps,
21+
"chatAuthId" | "socketId" | "online"
22+
>;
23+
24+
interface ReadTokenProps extends AuthKeysProps {
25+
roomIds: string;
26+
}
27+
28+
type ReadTokenReturnProps = Pick<
29+
RoomProps,
30+
"chatRoomAuthId" | "lastMessageReadToken"
31+
>;
32+
33+
export const initiate = async (props: InitiateProps) => {
34+
const { tenantId, apiKey, subscriptionKey } = props;
35+
36+
try {
37+
const response = await axios.get<ConfigsProps>(
38+
`/api/v1/tenant/config/${tenantId}`,
39+
{
40+
params: {
41+
tenantId,
42+
plugin: true, // This is for backend compatibility
43+
},
44+
headers: {
45+
apiKey,
46+
subscriptionKey,
47+
},
48+
},
49+
);
50+
51+
if (response.data.tenantId === tenantId) {
52+
return response.data;
53+
}
54+
55+
return;
56+
} catch {
57+
// TODO: Log error
58+
/* empty */
59+
}
60+
};
61+
62+
export const getUsersOnlineInfo = async (props: OnlineInfoProps) => {
63+
const { userIds, apiKey, subscriptionKey } = props;
64+
65+
try {
66+
const response = await axios.get<OnlineInfoReturnProps[]>(
67+
`/api/v1/user/active-users`,
68+
{
69+
params: {
70+
userIds,
71+
},
72+
headers: {
73+
apiKey,
74+
subscriptionKey,
75+
},
76+
},
77+
);
78+
79+
return response.data;
80+
} catch {
81+
// TODO: Log error
82+
/* empty */
83+
}
84+
};
85+
86+
export const getRoomsReadToken = async (props: ReadTokenProps) => {
87+
const { roomIds, apiKey, subscriptionKey } = props;
88+
89+
try {
90+
const response = await axios.get<ReadTokenReturnProps[]>(
91+
`/api/v1/room/active-rooms`,
92+
{
93+
params: {
94+
roomIds,
95+
},
96+
headers: {
97+
apiKey,
98+
subscriptionKey,
99+
},
100+
},
101+
);
102+
103+
return response.data;
104+
} catch {
105+
// TODO: Log error
106+
/* empty */
107+
}
108+
};

assets/icons/svg/Dots.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as React from "react";
2+
import Svg, { SvgProps, Path } from "react-native-svg";
3+
4+
const Dots = (props: SvgProps) => (
5+
<Svg width={16} height={5} {...props}>
6+
<Path
7+
fill="#B3B6B7"
8+
d="M1.333.167C.6.167 0 .767 0 1.5s.6 1.333 1.333 1.333c.734 0 1.334-.6 1.334-1.333S2.067.167 1.333.167Zm13.334 0c-.734 0-1.334.6-1.334 1.333s.6 1.333 1.334 1.333C15.4 2.833 16 2.233 16 1.5S15.4.167 14.667.167ZM8 .167c-.733 0-1.333.6-1.333 1.333S7.267 2.833 8 2.833s1.333-.6 1.333-1.333S8.733.167 8 .167Z"
9+
/>
10+
</Svg>
11+
);
12+
export default Dots;

assets/icons/svg/EmojiIcon.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as React from "react";
2+
import Svg, { SvgProps, Path } from "react-native-svg";
3+
4+
const EmojiIcon = (props: SvgProps) => (
5+
<Svg width={14} height={14} {...props}>
6+
<Path
7+
fill="#B3B6B7"
8+
d="M14 6.048a7.024 7.024 0 0 0-6.599 2.725 3.501 3.501 0 0 1-2.711-.877L3.75 8.944a4.907 4.907 0 0 0 2.824 1.233A7.012 7.012 0 0 0 6.048 14a7.036 7.036 0 0 1 .986-14C10.584 0 13.52 2.63 14 6.048Zm-.022 1.42a5.62 5.62 0 0 0-5.602 2.357 5.598 5.598 0 0 0-.99 3.189c0 .328.028.65.082.964l6.51-6.51Zm-9.406-.785a1.055 1.055 0 1 0 0-2.11 1.055 1.055 0 0 0 0 2.11Zm4.924 0a1.055 1.055 0 1 0 0-2.11 1.055 1.055 0 0 0 0 2.11Z"
9+
/>
10+
</Svg>
11+
);
12+
export default EmojiIcon;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import * as React from "react";
2+
import Svg, { SvgProps, Path } from "react-native-svg";
3+
4+
interface FilledDoubleCheckProps extends SvgProps {
5+
color?: string;
6+
}
7+
8+
const FilledDoubleCheck = ({ color, ...props }: FilledDoubleCheckProps) => (
9+
<Svg width={14} height={8} {...props}>
10+
<Path
11+
fill={color || "#1B9C32"}
12+
d="m6.986 5.39.869.87 5.21-5.21.87.87L7.855 8 3.939 4.084l.87-.87L6.117 4.52l.87.87Zm.001-1.74L10.035.603l.868.868-3.048 3.047-.868-.867Zm-1.74 3.48L4.379 8 .462 4.084l.87-.87.87.87H2.2L5.248 7.13Z"
13+
/>
14+
</Svg>
15+
);
16+
export default FilledDoubleCheck;

assets/icons/svg/PaperPlane.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as React from "react"
2+
import Svg, { SvgProps, Path } from "react-native-svg"
3+
const PaperPlane = (props: SvgProps) => (
4+
<Svg width={14} height={14} {...props} >
5+
<Path
6+
fill="#fff"
7+
d="M.763 4.888c-.362-.12-.365-.316.008-.44L14.009.035c.366-.122.577.083.474.443L10.7 13.716c-.104.367-.316.38-.47.031l-2.494-5.61 4.162-5.548L6.35 6.75.763 4.888Z"
8+
/>
9+
</Svg>
10+
);
11+
export default PaperPlane;

assets/icons/svg/SearchIcon.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as React from "react";
2+
import Svg, { SvgProps, Path } from "react-native-svg";
3+
4+
const SearchIcon = (props: SvgProps) => (
5+
<Svg width={14} height={14} {...props}>
6+
<Path
7+
fill="#B3B6B7"
8+
d="m10.518 9.693 2.498 2.498-.825.825-2.498-2.498a5.252 5.252 0 0 1-8.526-4.101 5.252 5.252 0 0 1 5.25-5.25 5.252 5.252 0 0 1 4.101 8.526Zm-1.17-.433a4.082 4.082 0 0 0-2.931-6.927 4.082 4.082 0 0 0-4.084 4.084 4.082 4.082 0 0 0 6.927 2.93l.088-.087Z"
9+
/>
10+
</Svg>
11+
);
12+
export default SearchIcon;

assets/icons/svg/SingleCheck.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as React from "react";
2+
import Svg, { SvgProps, Path } from "react-native-svg";
3+
4+
const SingleCheck = (props: SvgProps) => (
5+
<Svg width={11} height={7} {...props}>
6+
<Path
7+
fill="#676D6F"
8+
d="m4.855 5.26-.869-.87-.87-.869L1.81 2.214l-.87.87L4.855 7l6.08-6.08-.87-.87-5.21 5.21Z"
9+
/>
10+
</Svg>
11+
);
12+
export default SingleCheck;

0 commit comments

Comments
 (0)